Category: ABAP

Useful ABAP code snippets that can be used in real life projects.

Index is not Used in SELECT

If you realize that index is not used in select, you need to force database to use it. For this, you need to use database hints in your code.  Hints depend on database server. In the following example, here is how to force database to use index when using SAP Trial system (with MaxDB): SELECT *       FROM zaa_bd_wpo_vol...

How to Run ABAP Program in Background Manually? (Easy Way)

Sometimes your program may contain logic that must run long time. In such case, you can’t easily run it by pressing ‘Execute’ program, because SAP has defined maximum number of seconds that is able to run any programs this way (it’s called foreground processing). In such case, you must execute the program differently. You have...

How to Run ABAP Program in Background Manually?

Sometimes your program may contain logic that must run long time. In such case, you can’t easily run it by pressing ‘Execute’ program, because SAP has defined maximum number of seconds that is able to run any programs this way (it’s called foreground processing). In such case, you must execute the program differently. You have...

Hello World! in ABAP for SAP Developers

Do you want to create your first ABAP program? Watch this video ” Hello World in ABAP for SAP Developers” and learn it by yourself. If you need a system, where you can practice your ABAP knowledge, download instructions on how to install your free local SAP system here: http://abapacademy.com/howtoinstallsaptrial/

How to trigger DATA_CHANGED event in CL_GUI_ALV_GRID

If you have problem getting changed data in ALV from DATA_CHANGED event, you must do the following:

Get class or interface definition information

Get information of class definiton: SEO_CLASS_TYPEINFO_GET Get information of interface definiton: SEO_INTERFACE_TYPEINFO_GET Get method definiton: SEO_METHOD_SIGNATURE_GET

Exit screen when obligatory fields are not filled

Define function button in GUI status with functional type ‘E’ – Exit command. In Process after input call module at exit command as follows: PROCESS AFTER INPUT.MODULE cancel AT EXIT-COMMAND. And implement module: MODULE cancel INPUT.* Just leave the screen without checking any obligatory fields  LEAVE TO SCREEN 0.ENDMODULE. ” CANCEL_POPUP INPUT

Dynamic SORT of dynamic internal table

Use the following example in your program: * Dynamically sort data using table keyDATA: ls_sort_key_field TYPE abap_sortorder. DATA: lt_sort_key_field TYPE abap_sortorder_tab.LOOP AT it_key INTO ls_key.  ls_sort_key_field-name = ls_key-fieldname.  APPEND ls_sort_key_field TO lt_sort_key_field.ENDLOOP.TRY.  SORT BY (lt_sort_key_field).   CATCH cx_sy_dyn_table_ill_comp_val.*    Unable to process dynamic sort ENDTRY.

Dynamic call FOR ALL ENTRIES

How to dynamically call FOR ALL ENTRIES DATA: lt_table TYPE STANDARD TABLE OF fieldname. CONCATENATE lv_key_field ‘= lt_table-table_line’   INTO lv_where SEPARATED BY space.   APPEND lv_where TO lt_where. SELECT fieldname   FROM (lv_table)   INTO TABLE lt_output   FOR ALL ENTRIES IN lt_table   WHERE (lt_where).

Dump CX_RSR_X_MESSAGE during 3.x load into InfoCube

Problem During 3.x load into InfoCube (DataSource -> PSA -> InfoCube), loading status stays in the yellow status. Looking into ST22, the following short dump comes up with the exception CX_RSR_X_MESSAGE. Diagnosis The data update was not finished. A short dump has probably been logged in BI. This provides information about the error. System Response “Caller...