Wednesday, May 18, 2011

ALV HIERARCHICAL List Display

*&---------------------------------------------------------------------*
*& Report ZDEMO_ALVHIER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZDEMO_ALVHIER.


INCLUDE zdemo_alv_top.

START-OF-SELECTION.
PERFORM read_data.
PERFORM fill_key_info.

PERFORM fill_field_catalog using 'it_vbak' 'VBAK'.
PERFORM fill_field_catalog using 'it_vbap' 'VBAP'.

PERFORM display_heirseq_alv.

FORM read_data.
SELECT * INTO TABLE it_vbak from VBAK UP TO 10 ROWS.

if not it_vbak is INITIAL.
SELECT * INTO TABLE it_vbap FROM VBAP FOR ALL ENTRIES IN it_vbak WHERE vbeln = it_vbak-vbeln.
ENDIF.

ENDFORM.

FORM fill_field_catalog USING fp_tabnam TYPE c fp_structure TYPE c.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-cprog
I_INTERNAL_TABNAME = fp_tabnam
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 fill_key_info.
CLEAR gs_keyinfo.
gs_keyinfo-header01 = 'VBELN'.
gs_keyinfo-item01 = 'VBELN'.
gs_keyinfo-header02 = SPACE.
gs_keyinfo-item02 = 'POSNR'.
ENDFORM.

FORM display_heirseq_alv.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IS_LAYOUT =
IT_FIELDCAT = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
I_TABNAME_HEADER = 'it_vbak'
I_TABNAME_ITEM = 'it_vbap'
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
IS_KEYINFO = gs_keyinfo
* IS_PRINT =
* IS_REPREP_ID =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* IR_SALV_HIERSEQ_ADAPTER =
* IT_EXCEPT_QINFO =
* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB_HEADER = it_vbak
T_OUTTAB_ITEM = it_vbap
* 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.