Skip to Content
-1
Nov 26, 2011 at 01:33 PM

Output of two ALV lists in background

1364 Views

HI ALV experts,

[Soory I just saw that I posted this yesterday with a wrong subject]

I'm currently working with an existing reports which is quite complex. The report creates an ALV grid and uses a couple of write statements to create some statistics.

Running the report, we get the ALV grid. Then using BACK/F3 we leave the grid and get the list showing statistics.

I would like to create an ALV for the statistics. This works fine online: After leaving the grid the statistics ALV is started. But in background, I got just one list.

I tried this sample:

FORM batchtest .
  DATA:
    lr_data TYPE REF TO data,
    lo_salv TYPE REF TO cl_salv_table.
  FIELD-SYMBOLS:
    <table>  TYPE table.
* dynamic table fpr T000
  CREATE DATA lr_data TYPE TABLE OF t000.
  ASSIGN lr_data->* TO <table>.
  SELECT * INTO TABLE <table> FROM t000.
* show table in grid
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_structure_name = 'T000'
    TABLES
      t_outtab         = <table>
    EXCEPTIONS
      program_error    = 1
      OTHERS           = 2.
  IF sy-subrc  0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
* create another table
  TRY.
      CREATE DATA lr_data TYPE TABLE OF t100.
      ASSIGN lr_data->* TO <table>.
      SELECT * INTO TABLE <table> FROM t100 UP TO 100 ROWS.
      cl_salv_table=>factory(
        EXPORTING
          list_display   = if_salv_c_bool_sap=>true
        IMPORTING
          r_salv_table   = lo_salv
        CHANGING
          t_table        = <table> ).
* display list
      lo_salv->display( ).
    CATCH cx_salv_msg .
      ASSERT 1 = 2.
  ENDTRY.
ENDFORM.                    " BATCHTEST

Online, it works fine. In batch, I get only the second table as list. If I exit after calling FUNCTION 'REUSE_ALV_GRID_DISPLAY', I get the first list only. How to get both lists printed in sequence? I will not use ALV block list display, because this would mean major restructuring of the program and no grid online. SUBMIT ist no good idea as well.

Thanks in advance

Regards

Clemens