Technical Articles
How to get quickly OpenSQL queries for your ABAP programs
As impossible as it may seem, we sometimes forget the way in which a query should be constructed in openSQL. Have you ever wondered if there is an easy way to build queries to use in your programs?
Well, the answer is YES, in this post I will show you how to get simple queries (nothing too complex) for your programs.
After reading this post you easily will build your SELECT statements and you could also modify it for UPDATE or INSERT statements.
Let’s get into that.
Step 1: Go to transaction SE16N
Transaction SE16N
Step 2: Choose your table
Choosing table
For this example let’s use SFLIGHT
Step 3: Choose your fields for filtering (in this case I’m using the field date)
Choosing Fields
Press F8
Step 4: Visualize your data
Visualize data
Step 5: Visualize your script
Now just click the Display selection Criteria button or SHIFT + F1
Click the button
And visualize your script
Visualize script
Now just copy the script and use it where you need it.
With this few steps yo can now get simple queries for your programs in no time.
IMPORTANT: the key is to know the fields of the table that you want to use in your program (for correct filtering).
I hope this information can be useful for your projects as it has been for me.
Share this post with whoever needs it
See you next time.
Thanks!
By the way, SE16N is only for S/4HANA (as far as I know). In other ABAP-based applications (CRM, etc.), there is now the transaction code S416N (documented in SAP notes). There is also the same feature as you mention.
I was not aware of S416N - thanks!
Hi Sandra,
Thanks for you comment, it can be useful for so much people.
Only for your information. SE16N is also available on ERP 6.0 systems (Ehp 8), not only for SAP S/4HANA.
And especially on HANA systems there is transaction SE16H where you can select millions of business partners in a second
Besides the well known SE16 and SE16N, there is also SE16H as well as S416N (another alias is S4H16N) and S416H (with its alias S4H16H).
These 'new' transactions are not necessarily limited to HANA, but are part of ‘newer’ SAP application releases: SE16 -> SE16N -> SE16H -> S416N/S416H. In general, these programs work on any SAP application, if available, however, there might be included functions that are strictly supported only for a HANA database (however, I am currently not aware of functions striclty limited to a HANA applications in SE16H or S416N and S416H, other then possible performance issues).
SE16H is actually based on the same FM ‘SE16N_START’ as SE16N is, just the new flag parameter I_HANA is checked
same with S416H which is based on FM ‘GTB_START’ as S416N is, and again, just the flag parameter I_HANA is checked