*&---------------------------------------------------------------------*
*& Report ZALV_XZH
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZALV_XZH.
TYPES:BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
verkf TYPE ekko-verkf,
sel TYPE c, "用來標識行選擇的欄位
F_STYLE TYPE LVC_T_STYL,
END OF ty_ekko.
DATA:it_ekko TYPE STANDARD TABLE OF ty_ekko,
wa_ekko TYPE ty_ekko.
DATA:lt_fieldcat TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF lt_fieldcat,
wa_layout TYPE lvc_s_layo.
CONSTANTS: gco_callback_user_command TYPE slis_formname VALUE 'FRM_USER_COMMAND',
gco_callback_status TYPE slis_formname VALUE 'FRM_USER_STATUS'.
START-OF-SELECTION.
SELECT ebeln
verkf
INTO CORRESPONDING FIELDS OF TABLE it_ekko
FROM ekko
UP TO 10 ROWS.
APPEND INITIAL LINE TO it_ekko.
PERFORM frm_set_catalog.
PERFORM frm_loop_itdata.
* wa_layout-zebra = 'X'.
* wa_layout-box_fname = 'SEL'. "指定行選擇欄位
wa_layout-cwidth_opt = 'X'.
wa_layout-stylefname = 'F_STYLE'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = wa_layout
it_fieldcat_lvc = lt_fieldcat
i_callback_pf_status_set = gco_callback_status
i_callback_user_command = gco_callback_user_command
TABLES
t_outtab = it_ekko[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc = 0.
ENDIF.
*&---------------------------------------------------------------------*
*& Form FRM_SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_user_status USING i_it_extab TYPE slis_t_extab.
* SET PF-STATUS '*******' .
ENDFORM. " FRM_SET_PF_STATUS
FORM frm_user_command USING i_ucomm TYPE sy-ucomm
i_wa_selfield TYPE slis_selfield.
CASE i_ucomm.
WHEN '&IC1'. "Double click
* if click on PO field, jump to me23n
* IF i_wa_selfield-fieldname = 'EBELN'.
* SET PARAMETER ID 'BES' FIELD i_wa_selfield-value.
* CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
* ENDIF.
PERFORM frm_loop_itdata .
APPEND INITIAL LINE TO it_ekko.
i_wa_selfield-refresh = 'X'.
WHEN OTHERS.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_set_catalog .
DEFINE mac_fieldcat.