TABLES: MARA,MAKT.
TYPE-POOLS: SLIS.
TYPES: BEGIN OF ST_MARA,
EXPAND,
MATNR TYPE MATNR,
ERSDA TYPE ERSDA,
ERNAM TYPE ERNAM,
END OF ST_MARA.
TYPES: BEGIN OF ST_MAKT,
MATNR TYPE MATNR,
SPRAS TYPE SPRAS,
MAKTX TYPE MAKTX,
END OF ST_MAKT.
DATA: IT_MARA TYPE TABLE OF ST_MARA,
WA_MARA TYPE MARA,
IT_MAKT TYPE TABLE OF ST_MAKT,
WA_MAKT TYPE MAKT.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
DATA: WA_KEY TYPE SLIS_KEYINFO_ALV.
DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
SELECT-OPTIONS:S_MATNR FOR MARA-MATNR.
SELECT MATNR
ERSDA
ERNAM
FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA WHERE MATNR IN S_MATNR.
IF SY-SUBRC = 0.
SORT IT_MARA BY MATNR.
ENDIF.
IF IT_MARA IS NOT INITIAL.
SELECT MATNR
SPRAS
MAKTX
FROM MAKT INTO TABLE IT_MAKT
FOR ALL ENTRIES IN IT_MARA
WHERE MATNR = IT_MARA-MATNR.
IF SY-SUBRC = 0.
SORT IT_MAKT BY MATNR.
ENDIF.
ENDIF.
WA_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
WA_KEY-HEADER01 = 'MATNR'.
WA_KEY-ITEM01 = 'MATNR'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-TABNAME = 'IT_MARA'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-SELTEXT_M = 'MATERIAL NUMBER'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '2'.
WA_FCAT-TABNAME = 'IT_MARA'.
WA_FCAT-FIELDNAME = 'ERSDA'.
WA_FCAT-SELTEXT_M = 'CREATED ON'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '3'.
WA_FCAT-TABNAME = 'IT_MARA'.
WA_FCAT-FIELDNAME = 'ERNAM'.
WA_FCAT-SELTEXT_M = 'CREATED BY'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_MAKT'.
WA_FCAT-FIELDNAME = 'SPRAS'.
WA_FCAT-SELTEXT_M = 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_MAKT'.
WA_FCAT-FIELDNAME = 'MAKTX'.
WA_FCAT-SELTEXT_M = 'DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FCAT
* 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_MARA'
i_tabname_item = 'IT_MAKT'
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
is_keyinfo = WA_KEY
* 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_MARA
t_outtab_item = IT_MAKT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Serkan AKKAVAK
Computer Engineer BSc
SAP Department Deputy Manager
Contact : serkurumsal@yandex.com
0 Comments