Kategorie: ABAP

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

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: [sociallocker id=”1121″] Call method CHECK_CHANGED_DATA in PAI module. This method automatically triggers the DATA_CHANGED event. Example: go_alv_grid->check_changed_data( ). [/sociallocker]

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...

How to debug dynamically called program in background?

There might be a problem when you need to debug such a program, because you never know, when your code will be called.Here is the trick:     DATA: lv_counter TYPE i. *   Call neverending loop in your code    WHILE lv_counter = 0.           “this will stop, when you change lv_counter            “to s/thing else in debugger    ...

How to get database size in DB6 using ABAP

After long research of searching function modules,... here is the example:      DATA lt_db6 TYPE STANDARD TABLE OF db6pmdb02. FIELD-SYMBOLS: <ls_db6> LIKE LINE OF lt_db6.  CALL FUNCTION 'DB6_HIS_OVERVIEW'* EXPORTING* CONNECTION = TABLES it_db6pmdb02 = lt_db6 EXCEPTIONS no_history_found = 1 invalid_parameter_set = 2 adbc_error = 3 system_error = 4 OTHERS = 5.  READ TABLE lt_db6...

How to delete BW Query from ABAP code?

BW Query is stored as component(reusable element) in database table RSZCOMPDIR. To delete it, you need to search for query’s component UID (COMPUID) for existing query’s technical name saved in COMPID field. DATA: lv_compuid TYPE sysuuid_25, lv_subrc TYPE sysubrc. CALL FUNCTION ‘RSZ_X_COMPONENT_DELETE’  EXPORTING   i_compuid = lv_compuid          “hashed UID   i_delete_variables = rs_c_false “delete all related variables ...

How to debug BEx (Query designer)

To be able to debug external application, which uses RFC functions, you have to use external degugging. Sometime, this external breakpoint does not work. If so, firstly start RSRTRACE transaction, and now the breakpoint will work. QD uses class CL_RSZA_QUERY and its methods.Method that loads the query -> LOAD_QUERY (FM that loads the query element...