2011 Nov 25 11:37 PM
HI ALV experts,
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
2011 Nov 26 4:00 AM
Hi Clemens,
I tried your code , it gives both list one after another in all three Scenarios
1) BACK button
2) Exit
3) Cancel
Ohhh Sorry Clemens , i think misread your Query : You want both list in Background .
regards
Deepak.
Edited by: Deepak Dhamat on Nov 26, 2011 5:28 AM
2011 Nov 26 4:55 AM
hi ,
FORM batchtest .
DATA: ls_params TYPE pri_params,
lv_valid,
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.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
no_dialog = 'X'
IMPORTING
out_parameters = ls_params
valid = lv_valid
EXCEPTIONS
OTHERS = 1.
NEW-PAGE PRINT ON PARAMETERS ls_params NO DIALOG.
* 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.
NEW-PAGE PRINT OFF.
COMMIT WORK.
* 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.
After executing in BAtch tell me what happens : i think it should give both list to spool .
WHile executing foreground it will sedn first list to print and another it will display .
Regards
deepak.
Edited by: Deepak Dhamat on Nov 26, 2011 5:55 AM