Using the output of a Standard/Already Developed ALV report | Techbirds
Posted on: January 6, 2014 /
Categories: ABAP, SAP / Author Name: Ankit Shukla
hi Abapers ,
Recently i have faced one main problem that
“how to get the Alv output of Standard /already developed report OR output of some transaction in our function module ” .. ?
because nobody wants to write the same report code again in FM(function module ) , just to make that Alv output
data remotely enabled and accessed/display by any front end technology .
so , here i found some interesting concept to accomplish it .
- We need to call the SET method of the class CL_SALV_BS_RUNTIME_INFO as shown below :
CALL METHOD cl_salv_bs_runtime_info=>set EXPORTING display = abap_false metadata = abap_false
data = abap_true.
- What this does is to tell the system that the report has to be running with no DISPLAY no METADATA on only get the ALV DATA.
2. Z* report where i used the SUBMIT Statement so call the standard report .
SUBMIT “report_name” AND RETURN .
- The AND RETURN addition ensures that the the control is returned to the calling program .
- You can use the various other additions of the SUBMIT statement to pass on the selection screen parameters .
eg : SUBMIT “report_name” WITH parameter1 = value AND RETURN.
3. Next use the GetDataRef method of the class CL_SALV_BS_RUNTIME_INFO to get the actual data into a local object type ref’ed to DATA.
DATA obj_data TYPE REF TO data .
FIELD-SYMBOLS : TYPE ANY TABLE .
TRY. CALL METHOD cl_salv_bs_runtime_info=>get_data_ref IMPORTING
r_data = obj_data.
ASSIGN obj_data->* TO .
CATCH cx_salv_bs_sc_runtime_info .
ENDTRY.
IF IS ASSIGNED. it_final[] = .
ENDIF.
4. The data from the ALV should now be in the fs_data Field-Symbol. We can now change or do any further validations on it.
5. it_final is your output internal table in function module ( that you specify in export or table parameter ).
6. Now you have ALV output in it_final internal table ,so by making your FM remote enabled any external system can display
report ALV output data .
so here is my source code :
DATA obj_data TYPE REF TO data . FIELD-SYMBOLS : TYPE ANY TABLE . CALL METHOD cl_salv_bs_runtime_info=>set EXPORTING display = abap_false metadata = abap_false
data = abap_true.
SUBMIT “report_name” WITH parameter_name = value AND RETURN.
TRY. CALL METHOD cl_salv_bs_runtime_info=>get_data_ref IMPORTING
r_data = obj_data.
ASSIGN obj_data->* TO .
CATCH cx_salv_bs_sc_runtime_info .
ENDTRY.
IF IS ASSIGNED. it_final[] = .
ENDIF.
3,534 total views, 2 views today