Search on this Website

Thursday, April 26, 2007

Multiple ALV list on same page

Suppose we want to make three ALV block on a Page :

Creating Block one by one --

*&---------------------------------------------------------------------*
*& Form create_first_block
*&---------------------------------------------------------------------*
* Creating First BLock
*----------------------------------------------------------------------*

form create_first_block .

*Block 1:

*INITIALIZE

REFRESH t_field. CLEAR t_field.



REFRESH t_events.

PERFORM fill_fieldcatlog.


*--build table for events.

x_events-form = 'TOP_OF_LIST1'.

x_events-name = slis_ev_top_of_list.

APPEND x_events TO t_events.


CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = x_layout
it_fieldcat = t_field
i_tabname = 'T_VBAP'
it_events = t_events
* it_sort = t_sort
TABLES
t_outtab = t_vbap1
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.
endform. " create_first_block

*&---------------------------------------------------------------------*
*& Form create_second_block
*&---------------------------------------------------------------------*
* Creating Second Block
*----------------------------------------------------------------------*

form create_second_block .

*--BLOCK 2(SUMMARY REPORT)

*INITIALIZE

* REFRESH t_field. CLEAR t_field.

REFRESH t_events.


*--build table for events.

x_events-form = 'TOP_OF_LIST2'.

x_events-name = slis_ev_top_of_list.

APPEND x_events TO t_events.

* Append table block.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = x_layout
it_fieldcat = t_field
i_tabname = 'T_VBAP'
it_events = t_events
TABLES
t_outtab = t_vbap2
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.


endform. " create_second_block
*&---------------------------------------------------------------------*
*& Form create_third_block
*&---------------------------------------------------------------------*
* creating Third Block
*----------------------------------------------------------------------*

form create_third_block .

*****Block3

*--BLOCK 3(SUMMARY REPORT)

*INITIALIZE

* REFRESH t_field. CLEAR t_field.

REFRESH t_events.



*--build table for events.

x_events-form = 'TOP_OF_LIST3'.

x_events-name = slis_ev_top_of_list.

APPEND x_events TO t_events.

* Append table block.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = x_layout
it_fieldcat = t_field
i_tabname = 'T_VBAP'
it_events = t_events
TABLES
t_outtab = t_vbap3
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.



endform. " create_third_block

No comments: