2
Generated by Jive on 2015-07-05+02:00 1 TRM Reporting with functional module LDB_PROCESS From time to time we can't use standard reporting tools, but ABAP. And if you don't know peculiarities of TRM tables it will be quite complicated task. But functional module LDB_PROCESS (help.sap.com) can handle this situation. The module works in close connection with Logical databases which contain selection options and settings for data selection. Important feature of the LDB_PROCESS is that it allows you to analyze your result data as a whole instead of on a line-by-line basis. It is usefull, in order to agregate the result data or calculate an averge values. SAP Query can't handle such situations. TIPS: 1. You must specify technical names in uppercase letters 2. Some selection parameters are mandatory, while another group of selection paramenters dynamically turn into mandatory parameters when you select certain characteristics. 3. Callback process is carried out via a subroutine, which requires to strore the results data in global table. We can get the results from global table and work with them further. 4. Functional module LDB_PROCESS doesn't contain interface for transfering messages that are issued by called LDB. You can transfer the messages for LDB using external memory. 5. You have to react to the EXCEPTIONS of LBD_PROCESS function module. Example: ABAP code will be similar to selection screen of LDB FTI_TR_POSITIONS

SAP TRM Reporting

Embed Size (px)

DESCRIPTION

SAP TRM Reporting

Citation preview

Page 1: SAP TRM Reporting

Generated by Jive on 2015-07-05+02:001

TRM Reporting with functional moduleLDB_PROCESS

From time to time we can't use standard reporting tools, but ABAP. And if you don't know peculiarities of TRM

tables it will be quite complicated task.

But functional module LDB_PROCESS (help.sap.com) can handle this situation. The module works in close

connection with Logical databases which contain selection options and settings for data selection.

Important feature of the LDB_PROCESS is that it allows you to analyze your result data as a whole instead

of on a line-by-line basis. It is usefull, in order to agregate the result data or calculate an averge values. SAP

Query can't handle such situations.

TIPS:1. You must specify technical names in uppercase letters2. Some selection parameters are mandatory, while another group of selection paramenters dynamically

turn into mandatory parameters when you select certain characteristics.3. Callback process is carried out via a subroutine, which requires to strore the results data in global table.

We can get the results from global table and work with them further.4. Functional module LDB_PROCESS doesn't contain interface for transfering messages that are issued

by called LDB. You can transfer the messages for LDB using external memory.5. You have to react to the EXCEPTIONS of LBD_PROCESS function module.

Example: ABAP code will be similar to selection screen of LDB FTI_TR_POSITIONS

Page 2: SAP TRM Reporting

TRM Reporting with functional module LDB_PROCESS

Generated by Jive on 2015-07-05+02:002

REPORT zlbd_process_example. TYPE-POOLS rsfs. DATA: gt_positions TYPE STANDARD TABLE OF fti_ldb_tr_positions, gt_errors TYPE bapierr_t. DATA: ls_callback TYPE ldbcb, lt_callback TYPE STANDARD TABLE OF ldbcb, ls_selections TYPE rsparams, lt_selections TYPE STANDARD TABLE OF rsparams, ls_field_selection TYPE rsfs_tab_fields, lt_field_selection TYPE rsfs_fields. *Information on callback ls_callback-ldbnode = 'POSITIONS'. ls_callback-get = 'X'. ls_callback-cb_prog = 'ZLBD_PROCESS_EXAMPLE'. ls_callback-cb_form = 'CALLBACK_POSITIONS'. APPEND ls_callback TO lt_callback. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_JOTC'. ls_selections-low = 'X'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'S'. ls_selections-selname = 'S_BUKRS'. ls_selections-sign = 'I'. ls_selections-option = 'EQ'. ls_selections-low = 'NTS0'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'S'. ls_selections-selname = 'S_DATS'. ls_selections-sign = 'I'. ls_selections-option = 'EQ'. ls_selections-low = '20140501'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_RST_PB;'. ls_selections-low = '1'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_BILSTB'. ls_selections-low = '1'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_AUSWT'. ls_selections-sign = 'I'. ls_selections-option = 'EQ'. ls_selections-low = '0001'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_KURSA'. ls_selections-sign = 'I'. ls_selections-option = 'EQ'. ls_selections-low = '01'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_RANLWI'. ls_selections-sign = 'I'. ls_selections-option = 'EQ'. ls_selections-low = '01'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_ANZGW'. ls_selections-sign = 'I'. ls_selections-option = 'EQ'. ls_selections-low = 'USD'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_NUMBR'. ls_selections-sign = 'I'. ls_selections-option = 'EQ'. ls_selections-low = '001'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_CALCCY'. ls_selections-sign = 'I'. ls_selections-option = 'EQ'. ls_selections-low = 'USD'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_ERRLOG'. ls_selections-low = 'X'. APPEND ls_selections TO lt_selections. CLEAR ls_selections. ls_selections-kind = 'P'. ls_selections-selname = 'P_MEM_ID'. ls_selections-low = 'LDB_MESSAGES'. APPEND ls_selections TO lt_selections. ls_field_selection-tablename = 'POSITIONS'. APPEND 'BUKRS' TO ls_field_selection-fields. APPEND 'VALUATION_AREA' TO ls_field_selection-fields. APPEND 'BOOK_VAL_PC' TO ls_field_selection-fields. APPEND 'SBWHR' TO ls_field_selection-fields. APPEND 'BOOK_VAL_LC' TO ls_field_selection-fields. APPEND 'SHWHR' TO ls_field_selection-fields. APPEND ls_field_selection TO lt_field_selection. CALL FUNCTION 'LDB_PROCESS' EXPORTING ldbname = 'FTI_TR_POSITIONS' field_selection = lt_field_selection TABLES callback = lt_callback selections = lt_selections EXCEPTIONS ldb_not_reentrant = 1 ldb_incorrect = 2 lbd_already_running = 3 ldb_error = 4 ldb_selections_error = 5 ldb_selections_not_accepted = 6 variant_not_existent = 7 variant_obsolete = 8 variant_error = 9 free_selections-error = 10 callback_no_event = 11 callback_node_duplicate = 12 callback_no_progeam = 13 callback_no_cbform = 14 dyn_node_no_type = 15 dyn_node_invalid_type = 16 OTHERS = 17. IF sy-subrc NE 0. WRITE: / 'Exceprion:', sy-subrc. ENDIF. IMPORT p1 = gt_errors FROM MEMORY ID 'LDB_MESSAGES'. FORM callback_positions USING name TYPE ldbn-ldbnode workarea TYPE fti_ldb_tr_positions mode TYPE c selected TYPE c. DATA: ls_positions TYPE fti_ldb_tr_positions. MOVE-CORRESPONDING workarea TO ls_positions. APPEND ls_positions TO gt_positions. ENDFORM. "callback_positioinsResult is stored in global table GT_POSITIONS:

This report is limited to the logic just to show you how selection is made and you have to adopt it to your

requirement.

See more reporting possibilities