Skip to Content
h3. Introduction  This blog describes how to develop fully functional ABAP reports in “no time” with the help of +SAP Controls Report Simulator+ implemented in ABAP Objects using MVC paradigm The whole development process starts with using MS Excel or MS Notepad to create in few minutes a report template that includes several sample lines of report data. The +Report Simulator+ converts it to report layout and saves it in SAP database in INDX table with the help of +EXPORT TO DATABASE+ ABAP statement. Once the template is created, you have to write an ABAP program containing data retrieval procedure and optional event response procedures; e.g., to drill down to other reports or standard SAP transactions. The complete step by step example with full source code for 2 reports is presented below.   The +Report Simulator+ was described in a separate SDN blog published on Jan 16, 2010:  +                   Enhance Your Documentation with SAP Controls Report Simulator+                     Enhance Your Documentation with SAP Controls Report Simulator  (Enhance Your Documentation with SAP Controls Report Simulator)     It contains the link to the full source code that you would need to make your ABAP reports working. Please, refer that that blog to learn more about +Report Simulator+ and to get its source code.   This document shows step by step process for the development of 2 +Report Simulator+ based ABAP reports that:  ** List of Sales Order Line Items  When clicking of sales order number in the first report – +List of Sales Orders+, the second report – +List of Sales Order Line Items+ – is displayed. Clicking on *Display Sales Order* button in the second report, a standard SAP transaction VA03 is called to display Sales Order data.   With the +Report Simulator+ you could create fully functional ABAP reports that use the ALV Grid for displaying tabular data, an optional SAP Picture for showing e.g., company logo and the SAP Dynamic Documents for free text; e.g, title, selection screen parameters, etc… You could develop reports quickly, basically in as much time as it takes to develop data retrieval procedure; i.e., ABAP Form. Often you could get the complete solution in less than one hour. You do not have to be concerned with a tedious process of data formatting and displaying it with ALV Grid, SAP Picture and SAP Dynamic Documents ABAP Objects based SAP Controls. All of it is handled automatically by +Report Simulator+ template that you could create in 5 minutes.   The +SAP Controls Report Simulator+ ABAP Objects source code was developed using MVC programming model. In the next SDN blog coming soon, the MVC programming model for simple SAP Controls based applications will be discussed. The blog will show how to build and test independently a reusable library of MVC Models and MVC Views and how to put them together, with MVC Controllers, as building blocks of fully functional ABAP applications – Stay Tuned.   Now let us start with Rapid ABAP Development using the +Report Simulator+. Follow steps 1 to 10 to master it.  h3. Step 1 – Define List of Sales Orders Template with Report Simulator Let us create a sample report layout to display a list of sales orders as shown on the following screen: As you could see, the layout was created as TAB delimited MS Excel file and it contains report column headers with simple formatting information and sample report data. It is enough to have 2 or 3 sample data lines in a template file. For details of column formatting, please refer to +Enhance Your Documentation with SAP Controls Report Simulator+ blog – Enhance Your Documentation with SAP Controls Report Simulator  (Enhance Your Documentation with SAP Controls Report Simulator).  The report header simulation is defined with the following script: Run the +Report Simulator+ with the following selection screen parameters:  Click on *EXECUTE* button. The report simulation is displayed as shown on the following screen:    h3. Step 2 – Develop Data Retrieval Procedure for List of Sales Orders Now it is time to create ABAP program ZAWB_SOLIST. The program will contain the data retrieval procedure – ABAP Form – for the list of sales orders. Its source code is displayed in the following table:  PROGRAM  zawb_solist. *-Type for display, note _TYP field for ICON & _PAID for checkmark- TYPES: BEGIN OF vbak_t,          vbeln  TYPE vbak-vbeln,          auart  TYPE vbak-auart,          _typ   TYPE char4,          erdat  TYPE vbak-erdat,          erzet  TYPE vbak-erzet,          ernam  TYPE vbak-ernam,          vkorg  TYPE vbak-vkorg,          _paid  TYPE char1,          netwr  TYPE vbak-netwr,          color  TYPE char4,        END OF vbak_t. TYPES: vbak_tt TYPE TABLE OF vbak_t.  DATA: vbak TYPE vbak. *-Selection screen for List of Sales Orders report—————- SELECT-OPTIONS:   o_vbeln FOR vbak-vbeln. PARAMETERS:   p_maxrec TYPE char6  DEFAULT ‘200’,   p_simvar TYPE char18,          ” Report Simulator Template Id   p_title  TYPE char50,          ” report title   p_aprog  TYPE char45 DEFAULT sy-cprog NO-DISPLAY. *-Labels to be used in Docuument Header section——————- PARAMETERS:   otvbeln  TYPE char45 DEFAULT ‘Sales Orders’   NO-DISPLAY,   ptmaxrec TYPE char45 DEFAULT ‘Maximum Record’ NO-DISPLAY. *-Required includes———————————————– INCLUDE:   zawb_pso__m,        ” macros definition   z0awb_1rptsim__t,   ” ZReport Simulator model types   zawb_grid_i.        ” utility subroutine to notmalize table *-Start program initializing data and calling Report Simulator—- START-OF-SELECTION.   PERFORM appl_initialize.  *&——————————————————————– * *&      Form  APPL_INITIALIZE – to initialize Report Simulator *&——————————————————————– * FORM   appl_initialize . *——————————————————————— *   DATA:     lt_selpar TYPE rsparams_tt,     lt_script TYPE string_table. *-Build script for Dynamic Document——————————-   APPEND:     ‘*$HEADER        Selection Screen Parameters     ‘ TO lt_script,     ‘*$TABLE-ADD     2                               ‘ TO lt_script,     ‘*$COLUMN-ADD    50%                             ‘ TO lt_script,     ‘*$SELECT-OPTION O_VBELN                         ‘ TO lt_script,     ‘*$COLUMN-ADD    50%                             ‘ TO lt_script,     ‘*$PARAMETER     P_MAXREC                        ‘ TO lt_script. *-Get program parameters——————————————   CALL FUNCTION ‘RS_REFRESH_FROM_SELECTOPTIONS’     EXPORTING       curr_report     = sy-cprog     TABLES       selection_table = lt_selpar. *-Export program parameters and script—————————-   EXPORT title  = p_title          selopt = lt_selpar          script = lt_script TO MEMORY ID ‘CALLBACK’.   EXPORT so_list = o_vbeln          max_rec = p_maxrec TO MEMORY ID ‘SELSCR’. *-Call Report Simulator——————————————-   SUBMIT z0awb_4rptsimx__sac          with p_templ = p_simvar          and return. ENDFORM.                    ” APPL_INITIALIZE  *&——————————————————————– * *&      Form  eh4_model_rptsim_data_get – CALLBACK form to get data *&——————————————————————– * FORM   eh4_model_rptsim_data_get USING   uc_test      TYPE char1   xp_appl_data TYPE REF TO data   xc_ok        TYPE char1. *——————————————————————— *   FIELD-SYMBOLS:        TYPE z0awb_1rptsim__t. ” application data *-Assign data object reference to application data record———   ASSIGN xp_appl_data->* TO . *-Import selection screen SO list———————————   IMPORT so_list = o_vbeln          max_rec = p_maxrec  FROM MEMORY ID ‘SELSCR’.   FREE MEMORY ID ‘SELSCR’.   xc_ok = ‘X’. *-Data definition————————————————-   DATA:     li_odd    TYPE syindex,     lt_vbak   TYPE vbak_tt,     lr_vbak   TYPE vbak_t.   FIELD-SYMBOLS:      TYPE vbak_t. *-Retrieve data—————————————————   SELECT *          INTO CORRESPONDING FIELDS OF TABLE lt_vbak          UP TO p_maxrec ROWS          FROM vbak          WHERE vbeln IN o_vbeln.   EXPORT solist = lt_vbak TO MEMORY ID ‘SOLIST’. *-Populate ICON and checkmark fields——————————   LOOP AT lt_vbak ASSIGNING -_paid = ‘X’.     ENDIF.   ENDLOOP. *-Normalize data————————————————–   REFRESH Selection screen parameters and options. Notice NO-DISPLAY parameters used to transfer essential information to +Report Simulator;+ i.e., P_APROG for name of CALLBACK program, OTVBELN and PTMAXREC for labels in Document Header section of report – the names of theses parameters are the same as the names of data selection parameters/options O_VBELN and P_MAXREC with underscore substituted by letter T0.1.  INCLUDE sections with macro definitions, +Report Simulator+ model types and utility subroutine to normalize retrieved data to STRING_TABLE format0.1. Initialization section with APPL_INITIALIZE subroutine call and ABAP code. Notice initialization of Document Header in LT_SCRIPT internal table, EXPORT of selection screen parameters and document header script 0.2.  CALLBACK subroutine EH4_MODEL_RPTSIM_DATA_GET. The name of ABAP data retrieval procedure and its signature must be exactly as shown in the example. It gets dynamically Report Simulator data reference, imports this report selection screen parameters, retrieves data, adds icons and checkmarks and normalizes data to +Report Simulator+ STRING_TABLE format As you could see, the program calls the +Report Simulator+. The +Report Simulator+ would call back dynamically data retrieval procedure in ZAWB_SOLIST program to get for displaying the real report data rather than sample data from the template.   Notice that report parameters for retrieving sales order selection criteria are not passed to data retrieval procedure as ABAP form parameters. Rather than that, the RS_REFRESH_FROM_SELECTOPTIONS function module is called to retrieve them. This way the signature of data retrieval procedure does not change and it can be called from the +Report Simulator+ for any report and any selection criteria.  h3. Step 3 – Test List of Sales Orders Report Now it is time to run ZAWB_SOLIST report. Enter selection criteria; e.g., as shown on the following screen: Click on the *EXECUTE* button and the list of sales orders is displayed as shown on the following screen: h3. Step 4 – Define List of Sales Order Line Items Template with Report Simulator Let us create a sample report layout to display list of sales order items as shown on the following screen: As you could see, the layout was created as SEMI-COLON delimited text file and it contains report column headers with simple formatting information and sample report data. The report header simulation is defined with the following script: Run the +Report Simulator+ with the following selection screen parameters: Click on *EXECUTE* button. The report simulation is displayed as shown on the following screen: h3. Step 5 – Develop Data Retrieval Procedure for List of Sales Order Items Now it is time to create ABAP program ZAWB_SOITEMS. The program will contain the data retrieval procedure – ABAP Form – for the sales order line items. Its source code is displayed in the following table:  PROGRAM  zawb_soitems. *-Type for display, note _TYP field for ICON & _PAID for checkmark- TYPES: BEGIN OF vbap_t,          posnr  TYPE vbap-posnr,          matnr  TYPE vbap-matnr,          arktx  TYPE vbap-arktx,          umzin  TYPE vbap-umzin,          zieme  TYPE vbap-zieme,          netwr  TYPE vbap-netwr,          _total TYPE vbap-netwr,          color  TYPE char4,        END OF vbap_t. TYPES: vbap_tt TYPE TABLE OF vbap_t.  *-Selection screen parameters————————————- PARAMETERS:   p_vbeln  TYPE vbak-vbeln  DEFAULT ‘0000004970’,   p_simvar TYPE char18,          ” Report Simulator Template Id   p_title  TYPE char50,          ” report title   p_aprog  TYPE char45 DEFAULT sy-cprog NO-DISPLAY. *-Labels to be used in Docuument Header section——————- PARAMETERS:   ptvbeln  TYPE char45 DEFAULT ‘Sales Order #’   NO-DISPLAY. *-Required includes———————————————– INCLUDE:   zawb_pso__m,        ” macros definition   z0awb_1rptsim__t,   ” Report Simulator model types   zawb_grid_i.        ” utility subroutine to notmalize table *-Start program initializing data and calling Report Simulator—- START-OF-SELECTION.   PERFORM appl_initialize.  *&——————————————————————– * *&      Form  APPL_INITIALIZE – to initialize Report Simulator *&——————————————————————– * FORM   appl_initialize . *——————————————————————— *   DATA:     lt_selpar TYPE rsparams_tt,     lt_script TYPE string_table. *-Build script for Dynamic Document——————————-   APPEND:     ‘*$PARAMETER     P_VBELN                         ‘ TO lt_script. *-Get program parameters——————————————   CALL FUNCTION ‘RS_REFRESH_FROM_SELECTOPTIONS’     EXPORTING       curr_report     = sy-cprog     TABLES       selection_table = lt_selpar. *-Export program parameters and script—————————-   EXPORT title  = p_title          selopt = lt_selpar          script = lt_script TO MEMORY ID ‘CALLBACK’.   EXPORT so_number = p_vbeln TO MEMORY ID ‘SELSCR’. *-Call Report Simulator——————————————-   SUBMIT z0awb_4rptsimx__sac          WITH p_templ = p_simvar          AND RETURN. ENDFORM.                    ” APPL_INITIALIZE  *&——————————————————————– * *&      Form  eh4_model_rptsim_data_get – CALLBACK form to get data *&——————————————————————– * FORM   eh4_model_rptsim_data_get USING   uc_test      TYPE char1   xp_appl_data TYPE REF TO data   xc_ok        TYPE char1. *——————————————————————— *   FIELD-SYMBOLS:        TYPE z0awb_1rptsim__t. ” application data *-Assign data object reference to application data record———   ASSIGN xp_appl_data->* TO . *-Import selection screen SO list———————————   IMPORT so_number = p_vbeln FROM MEMORY ID ‘SELSCR’.   FREE MEMORY ID ‘SELSCR’.   xc_ok = ‘X’. *-Data definition————————————————-   DATA:     li_odd    TYPE syindex,     lt_vbap   TYPE vbap_tt,     lr_vbap   TYPE vbap_t,     ln_vbeln  TYPE num10,     lf_total  TYPE vbap-netwr.   FIELD-SYMBOLS:      TYPE vbap_t. *-Retrieve data—————————————————   ln_vbeln = p_vbeln.   SELECT *          INTO CORRESPONDING FIELDS OF TABLE lt_vbap          FROM vbap          WHERE vbeln = ln_vbeln.   EXPORT so_items  = lt_vbap          so_number = ln_vbeln TO MEMORY ID ‘SODOC’. *-Populate ICON and checkmark fields——————————   LOOP AT lt_vbap ASSIGNING -color = ‘C410’.     ENDCASE.   ENDLOOP.   clear lr_vbap.   lr_vbap-arktx  = ‘T O T A L’.   lr_vbap-_total = lf_total.   lr_vbap-color = ‘C310’.   append lr_vbap to lt_vbap. *-Normalize data————————————————–   REFRESH Selection screen parameters and options. Notice NO-DISPLAY parameters used to transfer essential information to +Report Simulator;+ i.e., P_APROG for name of CALLBACK program, PTVBELN for label in Document Header section of report – the names of this parameter is the same as the names of data selection parameter P_VBELN with underscore substituted by letter T0.1.  INCLUDE sections with macro definitions, +Report Simulator+ model types and utility subroutine to normalize retrieved data to STRING_TABLE format0.1. Initialization section with APPL_INITIALIZE subroutine call and ABAP code. Notice initialization of Document Header in LT_SCRIPT internal table, EXPORT of selection screen parameters and document header script 0.2.  CALLBACK subroutine EH4_MODEL_RPTSIM_DATA_GET. The name of ABAP data retrieval procedure and its signature must be exactly as shown in the example. It gets dynamically Report Simulator data reference, imports this report selection screen parameters, retrieves data, adds icons and checkmarks and normalizes data to +Report Simulator+ STRING_TABLE format As you could see, the program calls the +Report Simulator+. The +Report Simulator+ would call back dynamically data retrieval procedure in ZAWB_SOITEMS program to get for displaying the real report data rather than sample data from the template.   Notice that report parameters for retrieving sales order selection criteria are not passed to data retrieval procedure as ABAP form parameters. Rather than that, the RS_REFRESH_FROM_SELECTOPTIONS function module is called to retrieve them. This way the signature of data retrieval procedure does not change and it can be called from the +Report Simulator+ for any report and any selection criteria.  h3. Step 6 – Test List of Sales Order Line Items Report Now it is time to run ZAWB_SOITEMS report. Enter selection criteria; e.g., as shown on the following screen: Click on the *EXECUTE* button and the list of sales order line items is displayed as shown on the following screen: h3. Step 7 – Develop Event Procedure to Handle Click on Button for VA03 Call  Now let us add an event procedure – ABAP Form – in the ZAWB_SOITEMS report that would call VA03 transaction upon user clicking on *Display All Sales Order Data* button. Its source code is shown in the following table:   *&——————————————————————– * *&      Form  eh4_grid_main_fc_dspl – CALLBACK for DSPL pushbutton click *&——————————————————————– * FORM   eh4_grid_main_fc_dspl USING   un_row TYPE num10   xc_ok  TYPE char1. *——————————————————————— *   DATA:     li_row    TYPE syindex,     lt_vbap   TYPE vbap_tt,     ln_vbeln  TYPE num10.   FIELD-SYMBOLS:     The name of ABAP form implementing it must confirm with Report Simulator template; e.g., EP4_GRID_MAIN_FC_DSPL. It is called dynamically from the +Report Simulator+.  h3. Step 8 – Test Click on Button for VA03 Call Now it is time to run ZAWB_SOITEMS report. Enter selection criteria; e.g., as shown on the following screen: Click on the *EXECUTE* button and the list of sales order line items is displayed as shown on the following screen: Select any line item and click on the *Display Sales Order* button and VA03 screen for the sales order is displayed as shown on the following screen: h3. Step 9 – Develop Event Procedure to Handle Hotspot Click on Sales Order Number Let us add an event procedure in ZAWB_SOLIST program to handle hotspot click on sales order number. Its source code is shown in the following table:  *&——————————————————————– * *&      Form  eh4_grid_main_hs_col_000001 – CALLBACK for hotspot click *&——————————————————————– * FORM   eh4_grid_main_hs_col_000001 USING   un_row TYPE num10   xc_ok  TYPE char1. *——————————————————————— *   DATA:     li_row    TYPE syindex,     lt_vbak   TYPE vbak_tt,     lc_title  TYPE char80 VALUE ‘Sales Order & Items’.   FIELD-SYMBOLS:     The name of ABAP form implementing it must confirm with Report Simulator template; e.g., EP4_GRID_MAIN_HS_COL_000001. It is called dynamically from the +Report Simulator+.  h3. Step 10 – Test Complete Solution Now let us test the complete application consisting of 2 Report Simulator based reports: 0.1. ZAWB_SOLIST – display list of sales orders 0.2. ZAWB_SOITEMS – display list of sales order items Let us start ZAWB_SOLIST program. Enter selection criteria; e.g., as shown on the following screen: Click on the *EXECUTE* button and the list of sales orders is displayed as shown on the following screen:  Click once on any sales order number hotspot cell as shown above. The following screen displaying sales order line items appears: Select any item and click on the *Display Sales Order* button as shown above and VA03 screen for the sales order is displayed as shown on the following screen:
To report this post you need to login first.

9 Comments

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

    1. Adam Baryla Post author
      Hi Nisar:
      Thank you for your comments. I am working now on making SAP Controls Report Simulator source code available to SAP community. It will be probably available on SDN Code Exchange or SDN WiKi site. I have to overcome some administrative issues to make it available.
      The SAP Controls Report Simulator is a custom developed ABAP Objects program and I do not think that it will become a part  of standard SAP software.
      Best regards,
      Adam Baryla
      (0) 
    1. Adam Baryla Post author
      SAP Controls Report Simulator is a custom ABAP Objects program. Its source code will be available on SDN Code Exchange platform once I get permission to do this. The blog already contains information how to download it once it is available. SDN Code Exchange platform is available at the moment to SAP employees only. It is planned to make it public to SAP community worldwide at the end of Q1 2010.
      Best regards,
      Adam
      (0) 
  1. Krupa Janiji
    When i execute this got error like INCLUDE report “ZAWB_PSO__M” not found so pl tell what i have to write in these include zawb_pso__m,z0awb_1rptsim__t,zawb_grid_i.
    (0) 
    1. Adam Baryla Post author
      Hi Krupa:
      Yes, these includes are missing. However, you will also need SAP Controls Report Simulator program described in Enhance Your Documentation with SAP Controls Report Simulator  that is not yet available.

      SAP Controls Report Simulator is a custom ABAP Objects program. Its source code will be available on SDN Code Exchange platform once I get permission to do this. The blog already contains information how to download it once it is available. SDN Code Exchange platform is available at the moment to SAP employees only. It is planned to make it public to SAP community worldwide at the end of Q1 2010.

      I will distribute missing includes on SDN Code Exchange platform together with SAP Controls report Simulator.

      Best regards,

      Adam

      (0) 
  2. carlos valentini
    Goodnight Adam.

    I am writing this blog, first to congratulate you for your excellent work.
    Secondly would ask permission to access the link ‘ABAP Docs 2.0’.
    In http://code.google.com/p/abap-docs/.
    Because I would like to download the file in ZIP format.
    My email contact is: carlos@gati.inf.br.
    I am ABAP developer and I live in Brazil.

    Thank you.

    Ps.: English is not my mother language, forgive me the errors.

    (0) 

Leave a Reply