*&---------------------------------------------------------------------*
*& Report Z_BARRY_HIERSEQ_LIST *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT z_barry_hierseq_list .
TABLES: sscrfields,mara.
TYPE-POOLS: slis, kkblo.
DATA: BEGIN OF w_head ,
matnr LIKE mara-matnr,
ersda LIKE mara-ersda,
ernam LIKE mara-ernam,
chk TYPE c,
expand TYPE c,
END OF w_head,
BEGIN OF w_item ,
matnr LIKE marc-matnr,
werks LIKE marc-werks,
pstat LIKE marc-pstat,
lights TYPE slis_fieldname,
END OF w_item,
i_head LIKE TABLE OF w_head,
i_item LIKE TABLE OF w_item.
DATA: w_vari TYPE disvariant,
w_layo TYPE slis_layout_alv,
i_fcat TYPE slis_t_fieldcat_alv,
w_fcat TYPE slis_fieldcat_alv,
i_evts TYPE slis_t_event,
i_evts_exit TYPE slis_t_event_exit,
w_keyinfo TYPE slis_keyinfo_alv.
DATA g_program_name TYPE sy-cprog VALUE sy-repid.
CONSTANTS: cns_x TYPE c VALUE 'X'.
SELECT-OPTIONS s_matnr FOR mara-matnr.
START-OF-SELECTION.
SELECT matnr ersda ernam
FROM mara
INTO TABLE i_head
WHERE matnr IN s_matnr.
SELECT matnr werks pstat
FROM marc
INTO TABLE i_item
FOR ALL ENTRIES IN i_head
WHERE matnr EQ i_head-matnr.
LOOP AT i_item INTO w_item.
IF sy-tabix EQ 1.
w_item-lights = '1'.
ENDIF.
IF sy-tabix EQ 2.
w_item-lights = '2'.
ENDIF.
IF sy-tabix EQ 3.
w_item-lights = '3'.
ENDIF.
MODIFY i_item FROM w_item INDEX sy-tabix.
ENDLOOP.
w_vari-report = g_program_name.
PERFORM f_set_fcat: USING 'W_HEAD',
USING 'W_ITEM'.
PERFORM f_set_layo.
PERFORM f_set_keyinfo.
PERFORM f_call_alv.
*&---------------------------------------------------------------------*
*& Form f_set_fcat
*&---------------------------------------------------------------------*
FORM f_set_fcat USING l_tabname TYPE lvc_fname.
DATA: w_fcat TYPE slis_fieldcat_alv,
i_fcat_tmp TYPE slis_t_fieldcat_alv WITH HEADER LINE.
FIELD-SYMBOLS: TYPE slis_fieldcat_alv.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = g_program_name
i_internal_tabname = l_tabname
i_inclname = g_program_name
CHANGING
ct_fieldcat = i_fcat_tmp[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
APPEND LINES OF i_fcat_tmp TO i_fcat.
CHECK l_tabname EQ 'W_HEAD'.
READ TABLE i_fcat ASSIGNING
WITH KEY fieldname = 'EXPAND'.
-no_out = cns_x.
ENDFORM. " f_set_fcat
*&---------------------------------------------------------------------*
*& Form F_SET_LAYO
*&---------------------------------------------------------------------*
FORM f_set_layo .
w_layo-zebra = cns_x.
w_layo-lights_fieldname = 'LIGHTS'.
w_layo-lights_tabname = 'W_ITEM'.
w_layo-box_fieldname = 'CHK'.
w_layo-box_tabname = 'W_HEAD'.
w_layo-get_selinfos = cns_x.
* W_LAYO-GROUP_CHANGE_EDIT = CNS_X.
w_layo-expand_fieldname = 'EXPAND'.
* W_LAYO-DETAIL_INITIAL_LINES = CNS_X.
w_layo-expand_all = cns_x.
ENDFORM. " F_SET_LAYO
*&---------------------------------------------------------------------*
*& Form F_SET_KEYINFO
*&---------------------------------------------------------------------*
FORM f_set_keyinfo .
w_keyinfo-header01 = 'MATNR'.
w_keyinfo-item01 = 'MATNR'.
ENDFORM. " F_SET_KEYINFO
*&---------------------------------------------------------------------*
*& Form F_CALL_ALV
*&---------------------------------------------------------------------*
FORM f_call_alv .
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = g_program_name
* I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
* I_CALLBACK_USER_COMMAND =
is_layout = w_layo
it_fieldcat = i_fcat[]
i_default = cns_x
i_save = 'A'
is_variant = w_vari
i_tabname_header = 'W_HEAD'
i_tabname_item = 'W_ITEM'
is_keyinfo = w_keyinfo
TABLES
t_outtab_header = i_head[]
t_outtab_item = i_item[]
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. " F_CALL_ALV
*---------------------------------------------------------------------*
* FORM F_SET_STATUS
*---------------------------------------------------------------------*
FORM f_set_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'GUI'.
SET TITLEBAR 'STANDARD'.
ENDFORM. " F_SET_STATUS
阅读(3778) | 评论(0) | 转发(0) |