Skip to Content
Technical Articles
Author's profile photo Carlos Salamanca

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%20SE16N

Transaction SE16N

 

Step 2: Choose your table

Choosing%20table

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%20Fields

Choosing Fields

 

Press F8

 

Step 4: Visualize your data

Visualize%20data

Visualize data

Step 5: Visualize your script

Now just click the Display selection Criteria button or SHIFT + F1

Click%20the%20button

Click the button

 

And visualize your script

Visualize%20script

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.

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi

      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.

      Author's profile photo Bartosz Ziólkowski
      Bartosz Ziólkowski

      I was not aware of S416N - thanks!

      Author's profile photo Carlos Salamanca
      Carlos Salamanca
      Blog Post Author

      Hi Sandra,

      Thanks for you comment, it can be useful for so much people.

      Author's profile photo Oliver Butz
      Oliver Butz

      Only for your information. SE16N is also available on ERP 6.0 systems (Ehp 8), not only for SAP S/4HANA.

      Author's profile photo Markus Greutter
      Markus Greutter

      And especially on HANA systems there is transaction SE16H where you can select millions of business partners in a second

      Author's profile photo Michael Piesche
      Michael Piesche

      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 and S416H – lets you define joins for table selects as well as aggregate functions
        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
      • The parameter I_HANA is a little misleading, since the inner / outer join functions as well as the aggregate functions are also available and work on Oracle and MaxDB databases.
      • The transactions S4* (S416N, S416H, S4H16N, S4H16H) are also a little misleading, as these transactions are also present on a recent CRM system, whereas SE16N and SE16H where not present.