1.定义
DATA: lt_fieldcat TYPE lvc_t_fcat,
lw_fieldcat TYPE lvc_s_fcat,
lw_layout TYPE lvc_s_layo.
2.layout赋值
lw_layout-zebra = ‘X’.
lw_layout-cwidth_opt = ‘X’.
lw_layout-sel_mode = ‘A’.
3.fieldcat赋值
FORM frm_build_fcat.
DEFINE def_fieldcat.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = &1.
lw_fieldcat-scrtext_m = &2.
lw_fieldcat-hotspot = &3.
lw_fieldcat-checkbox = &4.
lw_fieldcat-edit = &5.
lw_fieldcat-ref_table = &6.
lw_fieldcat-ref_field = &7.
lw_fieldcat-no_zero = &8.
lw_fieldcat-decimals_o = &9.
APPEND lw_fieldcat TO lt_fieldcat.
END-OF-DEFINITION.
REFRESH lt_fieldcat[].
IF pv_flag = '0'.
def_fieldcat 'AUFNR ' '生产订单' '' '' '' '' '' '' '' .
def_fieldcat 'MATNR ' '物料编码' '' '' '' '' '' '' '' .
def_fieldcat 'CHARG ' '批次' '' '' '' '' '' '' '' .
def_fieldcat 'MENGE ' '数量' '' '' '' '' '' 'X' '0' .
def_fieldcat 'VFDAT ' '有效期' '' '' '' '' '' '' '' .
def_fieldcat 'DATSY ' '剩余有效期' '' '' '' '' '' '' '' .
ENDIF.
ENDFORM.
4.函数调用
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC’
EXPORTING
i_callback_program = lv_repid
i_callback_pf_status_set = ‘FRM_SET_PF’
i_callback_user_command = ‘FRM_USER_COMMAND’
is_layout_lvc = lw_layout
it_fieldcat_lvc = lt_fieldcat
TABLES
t_outtab = lt_charg
EXCEPTIONS
program_error = 1
OTHERS = 2.
5.GUI状态
FORM frm_set_pf USING rt_extab TYPE slis_t_extab.
DATA: rs_extab TYPE slis_extab.
REFRESH rt_extab.
rs_extab-fcode = '&SAVE'.
APPEND rs_extab TO rt_extab.
rs_extab-fcode = '&PROC'.
APPEND rs_extab TO rt_extab.
SET PF-STATUS 'STATUS' EXCLUDING rt_extab.
ENDFORM.
6.user_command
FORM frm_user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&PROC'.
PERFORM frm_proc_assign.
PERFORM frm_dis_assign. "显示分配结果
WHEN '&SAVE'.
PERFORM frm_save_data. "保存数据到后续表
WHEN OTHERS.
ENDCASE.
ENDFORM.