Wednesday, May 18, 2011

ALV Block List

*&---------------------------------------------------------------------*
*& Report ZDEMO_ALVBLOCK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZDEMO_ALVBLOCK.

INCLUDE zdemo_alv_top.

sTART-OF-SELECTION.
list_layout-colwidth_optimize = 'X'.
PERFORM read_data.

end-of-SELECTION.
PERFORM initalize_alv_block.

PERFORM fill_field_catalog using 'IT_T001' 'T001'.
PERFORM append_data_to_alv_block USING 'IT_T001' IT_T001.

REFRESH it_fieldcat.

PERFORM fill_field_catalog using 'IT_KNB1' 'KNB1'.
PERFORM append_data_to_alv_block USING 'IT_KNB1' IT_KNB1.

PERFORM display_blocked_alv.

FORM initalize_alv_block.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = sy-cprog
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING =
.
ENDFORM.

FORM fill_field_catalog USING fp_itab TYPE c fp_structure TYPE c.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-cprog
I_INTERNAL_TABNAME = fp_itab
I_STRUCTURE_NAME = fp_structure
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = it_fieldcat
* EXCEPTIONS
* INCONSISTENT_INTERFACE = 1
* PROGRAM_ERROR = 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.

FORM read_data.
SELECT * INTO TABLE it_t001 from t001 UP TO 10 ROWS.

if not it_t001 is INITIAL.
SELECT * INTO TABLE it_knb1 FROM knb1 FOR ALL ENTRIES IN it_t001 WHERE bukrs = it_t001-bukrs.
ENDIF.

ENDFORM.

FORM append_data_to_alv_block USING fp_tnam TYPE c fp_data TYPE STANDARD TABLE.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = list_layout
IT_FIELDCAT = it_fieldcat
I_TABNAME = fp_tnam
IT_EVENTS = it_events
* IT_SORT =
* I_TEXT = ' '
TABLES
T_OUTTAB = fp_data
* 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.


FORM display_blocked_alv.
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.
ENDFORM.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.