REPORT ZTEST.
TYPE-POOLS: SLIS.
TYPES:
BEGIN OF T_DATA,
MATNR TYPE MAKT-MATNR,
MAKTX TYPE MAKT-MAKTX,
SPRAS TYPE MAKT-SPRAS,
END OF T_DATA,
BEGIN OF T_ALV,
MATNR TYPE MAKT-MATNR,
MAKTX TYPE MAKT-MAKTX,
SPRAS TYPE MAKT-SPRAS,
DD_HANDLE TYPE INT4,
END OF T_ALV.
DATA:
GT_FIELDCATALOG TYPE LVC_T_FCAT,
GW_FIELDCATALOG TYPE LVC_S_FCAT,
*定义存储下拉列表的数据
GT_DDVAL TYPE LVC_T_DROP,
GW_DDVAL TYPE LVC_S_DROP,
GT_EVENTS TYPE SLIS_T_EVENT,
GW_EVENTS TYPE SLIS_ALV_EVENT,
GT_DATA TYPE TABLE OF T_DATA,
GW_DATA TYPE T_DATA,
GT_ALV TYPE TABLE OF T_ALV,
GW_ALV TYPE T_ALV,
G_REPID TYPE SY-REPID VALUE SY-REPID.
************************************************************************
* SELECTION SCREEN *
************************************************************************
SELECT-OPTIONS: S_MATNR FOR GW_DATA-MATNR .
************************************************************************
* START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
SELECT MATNR MAKTX SPRAS
INTO TABLE GT_DATA UP TO 50 ROWS
FROM MAKT
WHERE MATNR IN S_MATNR
AND SPRAS = 'EN'.
LOOP AT GT_DATA INTO GW_DATA.
MOVE-CORRESPONDING GW_DATA TO GW_ALV.
APPEND GW_ALV TO GT_ALV.
ENDLOOP.
PERFORM CREAT_FIELDCAT.
PERFORM CREAT_DROPDOWN_VALUES.
PERFORM CREAT_EVENT_EXITS.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IT_FIELDCAT_LVC = GT_FIELDCATALOG
IT_EVENTS = GT_EVENTS
TABLES
T_OUTTAB = GT_ALV.
*---------------------------------------------------------------------*
* 设置输出字段的格式
*---------------------------------------------------------------------*
FORM CREAT_FIELDCAT.
CLEAR GW_FIELDCATALOG.
GW_FIELDCATALOG-FIELDNAME = 'MATNR'.
GW_FIELDCATALOG-REF_FIELD = 'MATNR'.
GW_FIELDCATALOG-REF_TABLE = 'MAKT'.
APPEND GW_FIELDCATALOG TO GT_FIELDCATALOG.
CLEAR GW_FIELDCATALOG.
GW_FIELDCATALOG-FIELDNAME = 'MAKTX'.
GW_FIELDCATALOG-REF_FIELD = 'MAKTX'.
GW_FIELDCATALOG-REF_TABLE = 'MAKT'.
APPEND GW_FIELDCATALOG TO GT_FIELDCATALOG.
CLEAR GW_FIELDCATALOG.
GW_FIELDCATALOG-FIELDNAME = 'SPRAS'.
GW_FIELDCATALOG-OUTPUTLEN = '7'.
GW_FIELDCATALOG-DD_OUTLEN = '7'.
GW_FIELDCATALOG-INTLEN = '2'.
GW_FIELDCATALOG-INTTYPE = 'C'.
GW_FIELDCATALOG-COLTEXT = 'Language'.
GW_FIELDCATALOG-TOOLTIP = 'Language'.
GW_FIELDCATALOG-SELTEXT = 'Language'.
GW_FIELDCATALOG-DRDN_FIELD = 'DD_HANDLE'.
GW_FIELDCATALOG-EDIT = 'X'.
APPEND GW_FIELDCATALOG TO GT_FIELDCATALOG.
ENDFORM. " creat_fieldcat *---------------------------------------------------------------------* *根据物料的所有的语言生成不同的生成下拉列表 *---------------------------------------------------------------------* FORM CREAT_DROPDOWN_VALUES. DATA: L_SPRAS TYPE MAKT-SPRAS, L_COUNT TYPE I. LOOP AT GT_ALV INTO GW_ALV. ADD 1 TO L_COUNT. SELECT SPRAS INTO L_SPRAS FROM MAKT WHERE MATNR = GW_ALV-MATNR. CLEAR GW_DDVAL. GW_DDVAL-HANDLE = L_COUNT. GW_DDVAL-VALUE = L_SPRAS. APPEND GW_DDVAL TO GT_DDVAL. ENDSELECT. CLEAR GW_DDVAL. GW_DDVAL-HANDLE = L_COUNT. GW_DDVAL-VALUE = ' '. APPEND GW_DDVAL TO GT_DDVAL. *设置对应 GW_ALV-DD_HANDLE = L_COUNT. MODIFY GT_ALV FROM GW_ALV. ENDLOOP. ENDFORM. " creat_dropdown_values
*---------------------------------------------------------------------*
* Form creat_event_exits
*---------------------------------------------------------------------*
FORM CREAT_EVENT_EXITS .
GW_EVENTS-NAME = 'CALLER_EXIT'.
GW_EVENTS-FORM = 'CALLER_EXIT'.
APPEND GW_EVENTS TO GT_EVENTS.
ENDFORM. " creat_event_exits *---------------------------------------------------------------------* *设置下拉列表,使Grid和内表能链接上 *---------------------------------------------------------------------* FORM CALLER_EXIT USING LS_DATA TYPE SLIS_DATA_CALLER_EXIT. DATA: L_REF_ALV TYPE REF TO CL_GUI_ALV_GRID. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING E_GRID = L_REF_ALV. CALL METHOD L_REF_ALV->SET_DROP_DOWN_TABLE EXPORTING IT_DROP_DOWN = GT_DDVAL. ENDFORM. "CALLER_EXIT
另一个例子:
**=====================================================================*
*& Report ZPS_FM_13
**=====================================================================*
REPORT zps_fm_13.
**=====================================================================*
* Program ID : ZPS_FM_13
* Program Description : 项目结算资料台账
* Functional Consultant :
* Process Spec ID :
* Created By : Liu Peng Peng
* Start Date : 17.02.2016 * End Date : *======================================================================* * Modify Log History. *----------------------------------------------------------------------* * *No. Modified by Date Transport Description *--- ----------- ---- --------- ----------- *M1 *======================================================================* * Tables *======================================================================* TABLES:zps009. *======================================================================* * Constants *======================================================================* *======================================================================* * Types *======================================================================* TYPE-POOLS : abap,slis,icon. *======================================================================* * Internal Tables/work areas *======================================================================* DATA:BEGIN OF gt_wd OCCURS 0, wdbh LIKE zps011-wdbh, "文档编号 wdmc LIKE zps011-wdmc, "文档名称 checkbox TYPE c, sel(1) TYPE c, END OF gt_wd. DATA:BEGIN OF gt_out OCCURS 0, wdbh LIKE zps009-wdbh, "文档编号 wdmc LIKE zps009-wdmc, "文档名称 tjtime LIKE zps009-tjtime, "提交时间 tjry LIKE zps009-tjry, "提交人员 shry LIKE zps009-shry, "审核人员 shtime LIKE zps009-shtime, "审核时间 shqk LIKE zps009-shqk, "审核情况 bz LIKE zps009-bz, "备注 sel(1) TYPE c, dd_handle TYPE int4, END OF gt_out. DATA:BEGIN OF gt_zzhtbm OCCURS 0, zzhtbm TYPE zzhtbm, zzhtms TYPE zzhtms, END OF gt_zzhtbm. DATA: fieldcat TYPE lvc_t_fcat WITH HEADER LINE. DATA: fieldcat1 TYPE lvc_t_fcat WITH HEADER LINE. *定义存储下拉列表的数据 DATA:gt_ddval TYPE lvc_t_drop, gw_ddval TYPE lvc_s_drop. *======================================================================* * Data declarations *======================================================================* DATA: wa_layout TYPE lvc_s_layo, gt_events TYPE slis_t_event, gs_event LIKE LINE OF gt_events. DATA: g_grid TYPE REF TO cl_gui_alv_grid. DATA:is_variant LIKE disvariant. *======================================================================* * Definition *======================================================================* DEFINE fill_field. CLEAR FIELDCAT. FIELDCAT-FIELDNAME = &1. FIELDCAT-SCRTEXT_L = &2. FIELDCAT-CFIELDNAME = &3. FIELDCAT-OUTPUTLEN = &4. FIELDCAT-EDIT = &5. APPEND FIELDCAT. END-OF-DEFINITION. DEFINE fill_field1. CLEAR FIELDCAT1. FIELDCAT1-FIELDNAME = &1. FIELDCAT1-SCRTEXT_L = &2. FIELDCAT1-CFIELDNAME = &3. FIELDCAT1-OUTPUTLEN = &4. FIELDCAT1-EDIT = &5. APPEND FIELDCAT1. END-OF-DEFINITION. *======================================================================* * Range declarations *======================================================================* *======================================================================* * Input Selection Screen *======================================================================* SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001. PARAMETERS:p_pspid LIKE proj-pspid OBLIGATORY. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN:COMMENT 32(50) l_msl. "项目定义描述 SELECTION-SCREEN END OF LINE. SELECT-OPTIONS:s_zzhtbm FOR zps009-zzhtbm . PARAMETERS:p_r1 RADIOBUTTON GROUP r1 DEFAULT 'X', p_r2 RADIOBUTTON GROUP r1, p_r3 RADIOBUTTON GROUP r1. SELECTION-SCREEN END OF BLOCK bl1. *======================================================================* * Initialization *======================================================================* INITIALIZATION. *======================================================================* * At Selection Screen *======================================================================* AT SELECTION-SCREEN ON p_pspid. PERFORM frm_get_lms. AT SELECTION-SCREEN ON s_zzhtbm. PERFORM frm_zzhtbm. AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_zzhtbm-low. PERFORM frm_f4_zzhtbm. AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_zzhtbm-high. PERFORM frm_f4_zzhtbm. *======================================================================* * At Selection Screen Output *======================================================================* AT SELECTION-SCREEN OUTPUT . *======================================================================* * AT SELECTION-SCREEN ON VALUE-REQUEST *======================================================================* *======================================================================* * Start of Selection *======================================================================* START-OF-SELECTION. *======================================================================* * End of Selection *======================================================================* END-OF-SELECTION. IF p_r1 = 'X'. PERFORM frm_get_data. PERFORM frn_alv_display. ELSEIF p_r2 = 'X'. PERFORM frm_get_data1. PERFORM frm_alv_display. ELSEIF p_r3 = 'X'. PERFORM frm_get_data1. PERFORM frm_alv_display1. ENDIF. *&---------------------------------------------------------------------* *& Form FRM_GET_LMS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_get_lms . DATA:lv_msl TYPE char40. CLEAR:l_msl. IF p_pspid IS NOT INITIAL. SELECT SINGLE post1 INTO lv_msl FROM proj WHERE pspid = p_pspid. IF sy-subrc <> 0. MESSAGE '不存在此项目' TYPE 'E'. ELSE. l_msl = lv_msl. CLEAR lv_msl. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_ZZHTBM *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_zzhtbm . IF s_zzhtbm[] IS INITIAL. MESSAGE '合同编号必输,请填写合同编号!' TYPE 'E'. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_F4_ZZHTBM *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_f4_zzhtbm . SELECT zzhtbm zzhtms INTO CORRESPONDING FIELDS OF TABLE gt_zzhtbm FROM zhttz WHERE zzxmbm = p_pspid. DELETE ADJACENT DUPLICATES FROM gt_zzhtbm COMPARING zzhtbm. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'ZZHTBM' dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = 'S_ZZHTBM' value_org = 'S' TABLES value_tab = gt_zzhtbm EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_get_data . SELECT wdbh wdmc INTO CORRESPONDING FIELDS OF TABLE gt_wd FROM zps011. ENDFORM. *&---------------------------------------------------------------------* *& Form FRN_ALV_DISPLAY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frn_alv_display . CLEAR: wa_layout."它用来定义ALV报表的整体属性 wa_layout-cwidth_opt = 'X'."优化列宽选项是否设置 wa_layout-box_fname = 'SEL'. REFRESH fieldcat. fill_field 'WDBH' '文档编号' '' '20' 'X'. fill_field 'WDMC' '文档名称' '' '20' 'X'. fieldcat-fieldname = 'CHECKBOX'. fieldcat-scrtext_l = '需要'. fieldcat-cfieldname = ''. fieldcat-outputlen = '5'. fieldcat-edit = 'X'. fieldcat-checkbox = 'X'. APPEND fieldcat. CLEAR fieldcat. is_variant-report = 'ZPS_FM_13'. is_variant-handle = '1'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_callback_program = sy-repid i_callback_user_command = 'USER_COMMAND' i_callback_pf_status_set = 'PF_STATUS' is_layout_lvc = wa_layout it_fieldcat_lvc = fieldcat[] i_default = 'X' i_save = 'A' it_events = gt_events[] is_variant = is_variant TABLES t_outtab = gt_wd[] EXCEPTIONS OTHERS = 2. IF sy-subrc <> 0. ENDIF. ENDFORM. FORM pf_status USING lt_extab. SET PF-STATUS 'MENU'. ENDFORM. *&---------------------------------------------------------------------* *& Form user_command *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->UCOMM text * -->RS_SELFIELD text *----------------------------------------------------------------------* FORM user_command USING ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. "#EC CALLED CASE ucomm. WHEN 'SAVE'. PERFORM frm_save_function. WHEN 'ONEKEY'. PERFORM frm_onekey_function. WHEN 'CREAT'. PERFORM frm_create_function. WHEN 'DELETE'. PERFORM frm_delete_function. WHEN 'OK'. PERFORM frm_ok_function. ENDCASE. rs_selfield-refresh = 'X'. rs_selfield-col_stable = 'X'. rs_selfield-row_stable = 'X'. ENDFORM. "user_command *&---------------------------------------------------------------------* *& Form FRM_SAVE_FUNCTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_save_function . DATA: lv_valid TYPE char01. DATA:lv_mes TYPE string. DATA lt_save TYPE TABLE OF zps011 WITH HEADER LINE. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING e_grid = g_grid. CALL METHOD g_grid->check_changed_data IMPORTING e_valid = lv_valid. IF lv_valid IS INITIAL. EXIT. ENDIF. REFRESH lt_save. LOOP AT gt_wd. lt_save-wdbh = gt_wd-wdbh. lt_save-wdmc = gt_wd-wdmc. APPEND lt_save. CLEAR lt_save. ENDLOOP. MODIFY zps011 FROM TABLE lt_save. COMMIT WORK. IF sy-subrc = 0. MESSAGE '保存成功!' TYPE 'S'. ELSE. MESSAGE '保存失败!' TYPE 'E'. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_ONEKEY_FUNCTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_onekey_function . LOOP AT gt_wd. gt_wd-checkbox = 'X'. MODIFY gt_wd TRANSPORTING checkbox. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_CREATE_FUNCTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_create_function . APPEND INITIAL LINE TO gt_wd. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_DELETE_FUNCTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_delete_function . DATA: l_answer(1) TYPE c. READ TABLE gt_wd WITH KEY sel = 'X'. IF sy-subrc <> 0. MESSAGE '请选择要删除的行!' TYPE 'E'. ELSE. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = '删除' text_question = '是否要删除该内容?' default_button = '2' display_cancel_button = 'X' IMPORTING answer = l_answer EXCEPTIONS text_not_found = 1 OTHERS = 2. IF l_answer = '1'. LOOP AT gt_wd WHERE sel = 'X'. DELETE gt_wd. DELETE FROM zps011 WHERE wdbh = gt_wd-wdbh. IF sy-subrc = 0. MESSAGE '删除成功!' TYPE 'S'. ELSE. MESSAGE '删除失败!' TYPE 'E'. ENDIF. ENDLOOP. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_OK_FUNCTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_ok_function . DATA: l_valid TYPE char01. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING e_grid = g_grid. CALL METHOD g_grid->check_changed_data IMPORTING e_valid = l_valid. IF l_valid IS INITIAL. EXIT. ENDIF. PERFORM frm_get_wdbh. PERFORM frm_alv_display. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_WDBH *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_get_wdbh . REFRESH gt_out. READ TABLE gt_wd WITH KEY checkbox = 'X'. IF sy-subrc = 0. LOOP AT gt_wd WHERE checkbox = 'X'. gt_out-wdbh = gt_wd-wdbh. gt_out-wdmc = gt_wd-wdmc. APPEND gt_out. CLEAR gt_out. ENDLOOP. ELSE. MESSAGE '请选择需要创建的文档!' TYPE 'E'. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_ALV_DISPLAY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_alv_display . DATA: l_count TYPE i. CLEAR: wa_layout."它用来定义ALV报表的整体属性 wa_layout-box_fname = 'SEL'. REFRESH fieldcat1. fill_field1 'WDBH' '文档编号' '' '20' ''. fill_field1 'WDMC' '文档名称' '' '20' ''. fieldcat1-fieldname = 'TJTIME'. fieldcat1-coltext = '提交时间'. fieldcat1-cfieldname = ''. fieldcat1-outputlen = '15'. fieldcat1-edit = 'X'. fieldcat1-ref_table = 'BKPF'. fieldcat1-ref_field = 'BUDAT'. fieldcat1-f4availabl = 'X'. APPEND fieldcat1. CLEAR fieldcat1. fill_field1 'TJRY' '提交人员' '' '20' 'X'. fill_field1 'SHRY' '审核人员' '' '20' 'X'. fieldcat1-fieldname = 'SHTIME'. fieldcat1-coltext = '审核时间'. fieldcat1-cfieldname = ''. fieldcat1-outputlen = '15'. fieldcat1-edit = 'X'. fieldcat1-ref_table = 'BKPF'. fieldcat1-ref_field = 'BUDAT'. fieldcat1-f4availabl = 'X'. APPEND fieldcat1. CLEAR fieldcat1. fieldcat1-fieldname = 'SHQK'. fieldcat1-coltext = '审核情况'. fieldcat1-cfieldname = ''. fieldcat1-outputlen = '15'. fieldcat1-edit = 'X'. fieldcat1-drdn_field = 'DD_HANDLE'. APPEND fieldcat1. CLEAR fieldcat1. fill_field1 'BZ' '备注' '' '40' 'X'. LOOP AT gt_out. ADD 1 TO l_count. gw_ddval-handle = l_count. gw_ddval-value = '未审核'. APPEND gw_ddval TO gt_ddval. CLEAR gw_ddval. gw_ddval-handle = l_count. gw_ddval-value = '审核中'. APPEND gw_ddval TO gt_ddval. CLEAR gw_ddval. gw_ddval-handle = l_count. gw_ddval-value = '审核完成'. APPEND gw_ddval TO gt_ddval. CLEAR gw_ddval. *设置对应 gt_out-dd_handle = l_count. MODIFY gt_out TRANSPORTING dd_handle. ENDLOOP. gs_event-name = 'CALLER_EXIT'. gs_event-form = 'CALLER_EXIT'. APPEND gs_event TO gt_events. is_variant-report = 'ZPS_FM_13'. is_variant-handle = '2'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_callback_program = sy-repid i_callback_user_command = 'USER_COMMAND1' i_callback_pf_status_set = 'PF_STATUS1' is_layout_lvc = wa_layout it_fieldcat_lvc = fieldcat1[] i_default = 'X' i_save = 'A' it_events = gt_events[] is_variant = is_variant TABLES t_outtab = gt_out[] EXCEPTIONS OTHERS = 2. IF sy-subrc <> 0. ENDIF. ENDFORM. *---------------------------------------------------------------------* *设置下拉列表,使Grid和内表能链接上 *---------------------------------------------------------------------* FORM caller_exit USING ls_data TYPE slis_data_caller_exit. DATA: l_ref_alv TYPE REF TO cl_gui_alv_grid. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING e_grid = l_ref_alv. CALL METHOD l_ref_alv->set_drop_down_table EXPORTING it_drop_down = gt_ddval. ENDFORM. "CALLER_EXIT FORM pf_status1 USING lt_extab. SET PF-STATUS 'MENU1'. ENDFORM. *&---------------------------------------------------------------------* *& Form user_command *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->UCOMM text * -->RS_SELFIELD text *----------------------------------------------------------------------* FORM user_command1 USING ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. "#EC CALLED CASE ucomm. WHEN 'DELETE1'. PERFORM frm_delete1_function. WHEN 'SAVE1'. PERFORM frm_save1_function. WHEN 'BACK'. LEAVE TO SCREEN 0. ENDCASE. rs_selfield-refresh = 'X'. rs_selfield-col_stable = 'X'. rs_selfield-row_stable = 'X'. ENDFORM. "user_command *&---------------------------------------------------------------------* *& Form FRM_DELETE1_FUNCTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_delete1_function . DATA: l_answer(1) TYPE c. READ TABLE gt_out WITH KEY sel = 'X'. IF sy-subrc <> 0. MESSAGE '请选择要删除的行!' TYPE 'E'. ELSE. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = '删除' text_question = '是否要删除该内容?' default_button = '2' display_cancel_button = 'X' IMPORTING answer = l_answer EXCEPTIONS text_not_found = 1 OTHERS = 2. IF l_answer = '1'. LOOP AT gt_out WHERE sel = 'X'. DELETE gt_out. DELETE FROM zps009 WHERE pspid = p_pspid AND zzhtbm = s_zzhtbm-low AND wdbh = gt_out-wdbh AND wdmc = gt_out-wdmc. IF sy-subrc = 0. MESSAGE '删除成功!' TYPE 'S'. ELSE. MESSAGE '删除失败!' TYPE 'E'. ENDIF. ENDLOOP. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_SAVE1_FUNCTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_save1_function . DATA: lv_valid TYPE char01. DATA:lv_mes TYPE string. DATA lt_save TYPE TABLE OF zps009 WITH HEADER LINE. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING e_grid = g_grid. CALL METHOD g_grid->check_changed_data IMPORTING e_valid = lv_valid. IF lv_valid IS INITIAL. EXIT. ENDIF. REFRESH lt_save. LOOP AT gt_out. lt_save-pspid = p_pspid. lt_save-zzhtbm = s_zzhtbm-low. lt_save-wdbh = gt_out-wdbh. lt_save-wdmc = gt_out-wdmc. lt_save-tjtime = gt_out-tjtime. lt_save-tjry = gt_out-tjry. lt_save-shry = gt_out-shry. lt_save-shtime = gt_out-shtime. lt_save-shqk = gt_out-shqk. lt_save-bz = gt_out-bz. APPEND lt_save. CLEAR lt_save. ENDLOOP. MODIFY zps009 FROM TABLE lt_save. COMMIT WORK. IF sy-subrc = 0. MESSAGE '保存成功!' TYPE 'S'. ELSE. MESSAGE '保存失败!' TYPE 'E'. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_DATA1 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_get_data1 . SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_out FROM zps009 WHERE pspid = p_pspid AND zzhtbm IN s_zzhtbm. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_ALV_DISPLAY1 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_alv_display1 . DATA: l_count TYPE i. CLEAR: wa_layout."它用来定义ALV报表的整体属性 wa_layout-box_fname = 'SEL'. REFRESH fieldcat1. fill_field1 'WDBH' '文档编号' '' '20' ''. fill_field1 'WDMC' '文档名称' '' '20' ''. fieldcat1-fieldname = 'TJTIME'. fieldcat1-coltext = '提交时间'. fieldcat1-cfieldname = ''. fieldcat1-outputlen = '15'. fieldcat1-edit = ''. fieldcat1-ref_table = 'BKPF'. fieldcat1-ref_field = 'BUDAT'. fieldcat1-f4availabl = 'X'. APPEND fieldcat1. CLEAR fieldcat1. fill_field1 'TJRY' '提交人员' '' '20' ''. fill_field1 'SHRY' '审核人员' '' '20' ''. fieldcat1-fieldname = 'SHTIME'. fieldcat1-coltext = '审核时间'. fieldcat1-cfieldname = ''. fieldcat1-outputlen = '15'. fieldcat1-edit = ''. fieldcat1-ref_table = 'BKPF'. fieldcat1-ref_field = 'BUDAT'. fieldcat1-f4availabl = ''. APPEND fieldcat1. CLEAR fieldcat1. fieldcat1-fieldname = 'SHQK'. fieldcat1-coltext = '审核情况'. fieldcat1-cfieldname = ''. fieldcat1-outputlen = '15'. fieldcat1-edit = ''. fieldcat1-drdn_field = 'DD_HANDLE'. APPEND fieldcat1. CLEAR fieldcat1. fill_field1 'BZ' '备注' '' '40' ''. LOOP AT gt_out. ADD 1 TO l_count. gw_ddval-handle = l_count. gw_ddval-value = '未审核'. APPEND gw_ddval TO gt_ddval. CLEAR gw_ddval. gw_ddval-handle = l_count. gw_ddval-value = '审核中'. APPEND gw_ddval TO gt_ddval. CLEAR gw_ddval. gw_ddval-handle = l_count. gw_ddval-value = '审核完成'. APPEND gw_ddval TO gt_ddval. CLEAR gw_ddval. *设置对应 gt_out-dd_handle = l_count. MODIFY gt_out TRANSPORTING dd_handle. ENDLOOP. gs_event-name = 'CALLER_EXIT'. gs_event-form = 'CALLER_EXIT'. APPEND gs_event TO gt_events. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_callback_program = sy-repid is_layout_lvc = wa_layout it_fieldcat_lvc = fieldcat1[] i_default = 'X' i_save = 'A' it_events = gt_events[] TABLES t_outtab = gt_out[] EXCEPTIONS OTHERS = 2. IF sy-subrc <> 0. ENDIF. ENDFORM.