Wednesday, July 18, 2018

ABAP Submit Program Options

Submit program can be used to run one ABAP program from another one. There are different options on how to use a submit Program.

Calling a submit program , with out actually showing the selection screen of the called program

SUBMIT <program_name>  WITH p_paramter/s_option = lv_single_value
                                               WITH p_version = lv_value
                                               AND RETURN.

SUBMIT RSBKDTPDELETE WITH p_dtp = lv_dtp
                                                  AND RETURN.

Calling a submit program and showing the selection screen of the called program.

SUBMIT RSBKDTPDELETE WITH p_dtp = s_dtp-low                                                                                                                          VIA SELECTION-SCREEN AND RETURN.

Calling a submit program and reading the output of the submitted program to a table 
Running the program from single value. For multiple values, run the code in a loop. ( not sure how to pass internal table to selection screen)

DATA                       :  lr_data   TYPE REF TO data.
FIELD-SYMBOLS  : <lt_data> TYPE ANY TABLE ,
                                   <lw_data> TYPE ANY.
custom declarations
DATA : lt_output TYPE STANDARD TABLE OF ztest_table,
              lw_output TYPE ztest_table.

*& Setting up runtime info
cl_salv_bs_runtime_info=>set(    EXPORTING display  = abap_false
                                                                             metadata = abap_false
                                                                            data     = abap_true ).
*& Submit program
SUBMIT RSBKDTPDELETE WITH p_dtp = lv_dtp AND RETURN.

*& Read the data from other program to here
TRY.
    cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_data ).
    ASSIGN lr_data->* TO <lt_data>.
  CATCH cx_salv_bs_sc_runtime_info.
    MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).

*& Move the output from other program to current program
LOOP AT <lt_data> ASSIGNING  <lw_data>.
MOVE-CORRESPONDING  <lw_data> TO lw_output
APPEND lw_output to lt_output.
ENDLOOP.

No comments:

Post a Comment