Skip to Content
How to embed ABAP progam in SAP Query

As far as we known, there are many magical functions in SAP system, today let’s talk about one from SAP query.

The application SAP Query is used to create lists not already contained in the SAP standard. It has been designed for users with little or no knowledge of the SAP programming language ABAP. SAP Query offers users a broad range of ways to define reporting programs and create different types of reports such as basic lists, statistics, and ranked lists. SAP Query’s range of functions correspond to the classical reporting functions available in the system. Needs in this area like list, statistic, or ranked list creation can be met using queries. All necessary data can be selected from various R/3 tables. To define a report, you first have to enter individual texts, such as titles, and select the fields and options which determine the report layout. Then you can edit list display in the WYS/WYG mode whenever you want using drag and drop and the other toolbox functions available.

The SAP Query comprises five components as follows:

  • Queries
  • InfoSets
  • User Groups
  • Translation

Today my blog will focus on the magical function of InfoSets, how to embed ABAP progam in SAP query. Go straight to my point, if we want to embed ABAP program, we should create an “Extras” in InfoSets at first, it can be an additional table, additional field, additional structure, or add the ABAP codes directly, then we can embed simple ABAP program in it. Herein I took the ‘additional field’ as the example.

Please see the following steps:

  1. I created one additional field “Week”, defined the relevant format as I want,

    Additional field Week

  2. Embedded the ABAP program codes, it called a function which is used to get the calendar week base on the posting date in table MKPF, because my end users want to make the statistic report in accordance with calendar weeks.

    Embed ABAP Program Codes

  3. After that I created a Query using the InfoSets with additional field Week, I don’t itemize the detailed steps how to create a Query here, just post the screen snapshot of report result, you can find the field ‘Week’ in the report alreay, now my end users can freely use it to do the statistical analysis from SAP Query!

    Query Result

That’s the magical function in SAP Query, Hope my blog can help you to get more useful Query report in SAP system. Every success!

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Preeti Agarwal

    Hi Tao ,

    Can you please review your second post

    as well .

    Because when i created this i am not getting desire result . We have PO number range 2000000- 29999999 out which we have 900  PO  and through  this I am able to see only 20 Po. I have check my authorisation . No failure .

    Can you Please help .

    Many Thanks

    (0) 
    1. Tao Zhang Post author

      Hi Preeti,

      Did you check the join condition between table EKPO and RSEG? It should be left outer join, not inner join.

      Best regards

      Tao

      (0) 
  2. Preeti Agarwal

    HI tao ,

    Yes I have  .  but I looked the result once again and found that I can run report only for one company code and not getting any display for any other company code

    Many Thanks

    (0) 

Leave a Reply