Skip to Content
avatar image
Former Member

Calling standard Report from a zprogram

Hi Experts,

We want to call ME5J transaction code from a zprogram using Submit statement.

We used following code to call the report

SUBMIT RM06BKPS WITH TCNT-PROF_DB EQ '000000000001' WITH CN_PROJN IN PROJECT  EXPORTING LIST TO MEMORY AND RETURN.

After using this statement we are getting output of the report. We don't need to display the result. We want to fetch data from above report using

CALL FUNCTION 'LIST_FROM_MEMORY'.

How to hide output display of ME5J?

Regards,

Sibin

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 05, 2014 at 10:30 AM

    Hello,

    you can use the class cl_salv_bs_runtime_info=>get_data_ref to get the standard report output without displaying the ALV grid.

    Check the Blog by glen simpson.

    http://scn.sap.com/community/abap/blog/2011/07/07/gain-programmatic-access-to-data-of-sapgui-alv-reports

    you would get the result in a type table declared and then do the Processing as per the requirement.

    Sample code for same.

    *&---------------------------------------------------------------------*

    *& Report  ZCALL_STANDARD*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*
    REPORT zcall_standard.
    TABLES : cdhdr.
    PARAMETERS : udate TYPE sy-datlo DEFAULT sy-datlo OBLIGATORY,
                 udate_to TYPE sy-datlo DEFAULT sy-datlo OBLIGATORY,
                 utime_fr TYPE sy-timlo DEFAULT sy-timlo OBLIGATORY,
                 utime_to TYPE sy-timlo DEFAULT sy-timlo OBLIGATORY.SELECT-OPTIONS : user FOR cdhdr-username.
    FIELD-SYMBOLS <lt_data>             TYPE ANY TABLE.DATA:          lr_data               TYPE REF TO data,
           ls_metadata TYPE cl_salv_bs_runtime_info=>s_type_metadata.DATA          lr_data_descr          TYPE REF TO cl_abap_datadescr.
    DATA: r_alv_table         TYPE REF TO cl_salv_table,
          r_func              TYPE REF TO cl_salv_functions.DATA: r_display           TYPE REF TO cl_salv_display_settings.
    DATA: r_columns           TYPE REF TO cl_salv_columns.DATA: r_column            TYPE REF TO cl_salv_column.
    DATA: lr_events           TYPE REF TO cl_salv_events_table,
          lr_functions_list   TYPE REF TO cl_salv_functions_list.

    cl_salv_bs_runtime_info=>set(
             EXPORTING display  = abap_false
                       metadata = abap_true
                       data     = abap_true ).
    SUBMIT rsvtprot  WITH cusobj = 'V_T001B'
             WITH dbeg = udate*                 WITH tbeg = utime_fr
             WITH dend = udate_to*                 WITH tend = utime_to
             WITH users = user[]
             WITH alv_grid = 'X' AND RETURN.
    TRY.


        cl_salv_bs_runtime_info=>get_data_ref(
             IMPORTING r_data_descr      = lr_data_descr ).

        CREATE DATA lr_data           TYPE HANDLE lr_data_descr.

        ASSIGN lr_data->*           TO <lt_data>.

        cl_salv_bs_runtime_info=>get_data(
          IMPORTING
            t_data      = <lt_data>
               ).
    *            TRY.
        CALL METHOD cl_salv_bs_runtime_info=>get_metadata
          RECEIVING
            value = ls_metadata.*             CATCH cx_salv_bs_sc_runtime_info .*            ENDTRY.



      CATCH cx_salv_bs_sc_runtime_info.
        MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
    ENDTRY.

    cl_salv_bs_runtime_info=>clear_all( ).
    CALL METHOD cl_salv_table=>factory
      IMPORTING
        r_salv_table = r_alv_table
      CHANGING
        t_table      = <lt_data>.
    CALL METHOD r_alv_table->get_functions
      RECEIVING
        value = r_func.
    CALL METHOD r_func->set_all
      EXPORTING
        value = abap_true.

    r_display = r_alv_table->get_display_settings( ).
    r_display->set_striped_pattern( cl_salv_display_settings=>true ).

    lr_functions_list = r_alv_table->get_functions( ).

    r_columns = r_alv_table->get_columns( ).
    r_columns->set_optimize( if_salv_c_bool_sap=>true ).
    CALL METHOD r_alv_table->display.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 29, 2014 at 12:35 PM

    I think when you use SUBMIT and RETURN, it executes all sequence of ABAP statements and then comes back. So part that is displaying the report o/p cannot be hidden.

    An alternative but a tedious job - create a copy of ME5J and then call. May be you can debug ME5J and analysis which selects are giving outputs.

    ~Lokesh

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello sibin,

      Implements the same logic that include FM06BF01_START

      dumps the contents of memory ID 'ZYX' in a variable with the same structure BAN

      You can handle as an internal table values.

      I hope you help.

      ban.png (45.0 kB)
  • avatar image
    Former Member
    Jul 29, 2014 at 09:56 PM

    Hello sibin,

    Report RM06BKPS search and export data to memory id 'ZYX.

    Then call report RM06BL00 to print or display results.

    This report IMPORT data from memory ID 'ZYX',

    You can retrieve the results from memory id 'ZYX' and use in your report.

    I hope you help.


    eban.png (23.9 kB)
    eban2.png (13.4 kB)
    eban3.png (24.4 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Jörg Wulf

      Hi Jorg,

      It is taking so muh time to execute from spool. Is there any other turn around? There is an option Rebuild frozen report data. If we select it and execute the report, we are getting

      Report data for 12KST1A saved.

      How to fetch this result? It is generating in background.

      Regards,

      Sibin

  • Jul 29, 2014 at 12:49 PM

    Hi Sibin,

    Not sure if it would work, but what about using the SUBMIT command in background task and maybe a WAIT UP TO [n] SECONDS if needed? Wouldn't it solve your problem?

    Cheers!

    Add comment
    10|10000 characters needed characters exceeded