2008 Apr 30 6:48 AM
Hi
i have in my output three parts
first part is the header which i call in the top of page event
second part is the messages which also is there in the top of page event
third part is the alv list output
Now my req is that i want to print all these three parts in separate pages of the SAME SPOOL.
remember that the first two parts is in the top of page event
2008 May 07 6:59 AM
please go through the following code
this will write each block on a new page
*&---------------------------------------------------------------------*
*& Report ZTSK_TRIAL_PROG_BLOCK_LIST *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZTSK_TRIAL_PROG_BLOCK_LIST .
TYPE-POOLS : slis.
TYPES : BEGIN OF ts_data,
data TYPE string,
END OF ts_data.
DATA : lt_lfa1 TYPE TABLE OF lfa1,
ls_lfa1 TYPE lfa1,
lt_data1 TYPE TABLE OF ts_data,
lt_data2 TYPE TABLE OF ts_data,
ls_data TYPE ts_data,
lt_event TYPE slis_t_event,
ls_event TYPE slis_alv_event,
lt_fieldcat1 TYPE slis_t_fieldcat_alv,
lt_fieldcat2 TYPE slis_t_fieldcat_alv,
lt_fieldcat3 TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
ls_layout TYPE slis_layout_alv.
ls_data-data = 'Hello this is page 1'.
APPEND ls_data TO lt_data1.
ls_data-data = 'Hello this is page 2'.
APPEND ls_data TO lt_data2.
SELECT * FROM lfa1 INTO TABLE lt_lfa1 UP TO 10 ROWS.
ls_fieldcat-fieldname = 'DATA'.
ls_fieldcat-tabname = 'LT_DATA1'.
ls_fieldcat-seltext_l = 'BLOCK1'.
APPEND ls_fieldcat TO lt_fieldcat1.
ls_fieldcat-fieldname = 'DATA'.
ls_fieldcat-tabname = 'LT_DATA2'.
ls_fieldcat-seltext_l = 'BLOCK2'.
APPEND ls_fieldcat TO lt_fieldcat2.
ls_fieldcat-fieldname = 'LIFNR'.
ls_fieldcat-tabname = 'LT_LFA1'.
ls_fieldcat-seltext_l = 'Vendor number'.
APPEND ls_fieldcat TO lt_fieldcat3.
ls_event-name = 'TOP_OF_PAGE'.
APPEND ls_event TO lt_event.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = sy-repid.
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING =
.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat1
i_tabname = 'LT_DATA1'
it_events = lt_event
* IT_SORT =
* I_TEXT = ' '
TABLES
t_outtab = lt_data1[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* MAXIMUM_OF_APPENDS_REACHED = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat2[]
i_tabname = 'LT_DATA2'
it_events = lt_event
* IT_SORT =
* I_TEXT = ' '
TABLES
t_outtab = lt_data2[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* MAXIMUM_OF_APPENDS_REACHED = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat3[]
i_tabname = 'LFA1'
it_events = lt_event
* IT_SORT =
* I_TEXT = ' '
TABLES
t_outtab = lt_lfa1[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* MAXIMUM_OF_APPENDS_REACHED = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* IS_PRINT =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
* 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.
2008 May 02 5:59 AM
2008 May 02 6:32 AM
NEW-PAGE.
WRITE 'main block'.
WRITE:/ sy-pagno.
NEW-PAGE.
WRITE 'second block'.
WRITE:/ sy-pagno.
NEW-PAGE.
Use FM to have the list display here.
Reward points.
2008 May 02 6:57 AM
hi
thanks for the reply
but only alv list is getting displayed
the first two blocks are no where to bee seen.
2008 May 07 6:04 AM
2008 May 07 6:10 AM
Hi,
As far as my knowledge goes, u cannot use the FM for the table display. Only possible option is to use WRITE statements to build the table instead of the FM and follow the same procedure as suggested by Taher kanchwala.
Thank You..
Reward points if found useful.
2008 May 07 6:08 AM
Use NEW PAGE.
After displaying the header.
So that the list output will go to the second page.
Regards,
Madan.
2008 May 07 6:12 AM
thanks madan,
i did the same thing
but in my output only the alv list is coming in the spool.
the messages which i have added in the top_of_list event is not going to the spool.
2008 May 07 6:59 AM
please go through the following code
this will write each block on a new page
*&---------------------------------------------------------------------*
*& Report ZTSK_TRIAL_PROG_BLOCK_LIST *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZTSK_TRIAL_PROG_BLOCK_LIST .
TYPE-POOLS : slis.
TYPES : BEGIN OF ts_data,
data TYPE string,
END OF ts_data.
DATA : lt_lfa1 TYPE TABLE OF lfa1,
ls_lfa1 TYPE lfa1,
lt_data1 TYPE TABLE OF ts_data,
lt_data2 TYPE TABLE OF ts_data,
ls_data TYPE ts_data,
lt_event TYPE slis_t_event,
ls_event TYPE slis_alv_event,
lt_fieldcat1 TYPE slis_t_fieldcat_alv,
lt_fieldcat2 TYPE slis_t_fieldcat_alv,
lt_fieldcat3 TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
ls_layout TYPE slis_layout_alv.
ls_data-data = 'Hello this is page 1'.
APPEND ls_data TO lt_data1.
ls_data-data = 'Hello this is page 2'.
APPEND ls_data TO lt_data2.
SELECT * FROM lfa1 INTO TABLE lt_lfa1 UP TO 10 ROWS.
ls_fieldcat-fieldname = 'DATA'.
ls_fieldcat-tabname = 'LT_DATA1'.
ls_fieldcat-seltext_l = 'BLOCK1'.
APPEND ls_fieldcat TO lt_fieldcat1.
ls_fieldcat-fieldname = 'DATA'.
ls_fieldcat-tabname = 'LT_DATA2'.
ls_fieldcat-seltext_l = 'BLOCK2'.
APPEND ls_fieldcat TO lt_fieldcat2.
ls_fieldcat-fieldname = 'LIFNR'.
ls_fieldcat-tabname = 'LT_LFA1'.
ls_fieldcat-seltext_l = 'Vendor number'.
APPEND ls_fieldcat TO lt_fieldcat3.
ls_event-name = 'TOP_OF_PAGE'.
APPEND ls_event TO lt_event.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = sy-repid.
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING =
.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat1
i_tabname = 'LT_DATA1'
it_events = lt_event
* IT_SORT =
* I_TEXT = ' '
TABLES
t_outtab = lt_data1[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* MAXIMUM_OF_APPENDS_REACHED = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat2[]
i_tabname = 'LT_DATA2'
it_events = lt_event
* IT_SORT =
* I_TEXT = ' '
TABLES
t_outtab = lt_data2[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* MAXIMUM_OF_APPENDS_REACHED = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat3[]
i_tabname = 'LFA1'
it_events = lt_event
* IT_SORT =
* I_TEXT = ' '
TABLES
t_outtab = lt_lfa1[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* MAXIMUM_OF_APPENDS_REACHED = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* IS_PRINT =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
* 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.