Skip to Content
avatar image
-1
Former Member

How to call a subroutine from another program and get a internal table as return value?

I need to get the lcl4 internal table with the values populated in program RPUAUD00 into my custom program by calling the subroutine START-OF-SELECTION. I tried calling the entire program using SUBMIT statement, but the issue with the program produces output in different for foreground and background. in Foreground a proper internal table can be fetched. But in background, the spool output is different from which fetching the required data is difficult. Kindly guide me to resolve the issue.

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jan 24, 2017 at 06:51 AM
    -1

    Hi, you can use below code get to return table. (<gt_data> submit program return table )

    DATA: rspar       TYPE TABLE OF rsparams,
          rspar_wa    TYPE rsparams,
          lr_data     TYPE REF TO data,
          lr_tabdescr TYPE REF TO cl_abap_structdescr,
          lr_data2    TYPE REF TO data.
    
    DATA: gt_fc TYPE  ddfields,
          gs_fc TYPE  dfies.
    
    FIELD-SYMBOLS <gt_data> TYPE STANDARD TABLE.
    FIELD-SYMBOLS <gs_data> TYPE any.
    
    CLEAR rspar_wa.
    rspar_wa-kind = 'S'.
    rspar_wa-selname = 'SO_VKORG'.
    rspar_wa-low = '1300'.
    rspar_wa-sign = 'I'.
    rspar_wa-option = 'EQ'.
    
    APPEND rspar_wa TO rspar.
    
    cl_salv_bs_runtime_info=>set( EXPORTING display  = abap_false
                                            metadata = abap_false
                                            data     = abap_true ).
    
    SUBMIT zsd_irsaliye_rapor
    WITH SELECTION-TABLE rspar AND RETURN.
    
    TRY.
    
        cl_salv_bs_runtime_info=>get_data_ref(  IMPORTING r_data = lr_data ).
        ASSIGN lr_data->* TO <gt_data>.
    
        CREATE DATA lr_data2 LIKE LINE OF <gt_data>.
        lr_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data2 ).
        gt_fc   = cl_salv_data_descr=>read_structdescr( lr_tabdescr ).
    
      CATCH cx_salv_bs_sc_runtime_info.
        MESSAGE 'Program Not Read' TYPE 'E'.
    
    ENDTRY.
    
    cl_salv_bs_runtime_info=>clear_all( ).
    
    Add comment
    10|10000 characters needed characters exceeded

  • Jan 24, 2017 at 06:37 AM

    This report allows an ALV report, so you should use class cl_salv_bs_runtime_info to deactivate ALV display and get the generated internal table back.

    Regards,
    Raymond

    Add comment
    10|10000 characters needed characters exceeded