Using the output of a Standard/Already Developed ALV report

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 .

  1. 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 : <fs_data> TYPE ANY TABLE .

                  TRY.
CALL METHOD cl_salv_bs_runtime_info=>get_data_ref
IMPORTING
r_data = obj_data.

                                ASSIGN obj_data->* TO <fs_data>.

                                CATCH cx_salv_bs_sc_runtime_info .
ENDTRY.

                  IF <fs_data> IS ASSIGNED.
it_final[] = <fs_data>.
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 : <fs_data> 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 <fs_data>.

CATCH cx_salv_bs_sc_runtime_info .
ENDTRY.

IF <fs_data> IS ASSIGNED.
it_final[] = <fs_data>.
ENDIF.

 

2,604 total views, 1 views today

Share this OnShare on FacebookTweet about this on TwitterShare on LinkedInShare on Google+

Leave a Reply