《SAP动态配置程序-Dialog-ALV-报表(下).docx》由会员分享,可在线阅读,更多相关《SAP动态配置程序-Dialog-ALV-报表(下).docx(19页珍藏版)》请在第壹文秘上搜索。
1、INCLUDEINCLUDEINCLUDEINCLUDEINCLUDESAP动态配置程序DialogALV报表(下)-AuthorzSUNZKQQ:1131341075WEIXIN:DreamSunlight88REPORTYMPSR9010MESSAGE-IDYMCANOSTANDARDPAGEHEADING.YMPSR9010_TOP.YMPSR9010_CLS.YMPSR9010_001.YMPSR9010_I01.YMPSR9010_F01.START-OF-SELECTION.CALLSCREEN1.00.DATA:ok_codesave_okg_errorTYPEsy-ucommz
2、TYPEsy-ucomm,TYPEc,l_answer TYPE c,“弹框返回值,1创建、2、修改3、显示DATA:gt_cs009TYPETABLEOFympstcs009,gs_cs009TYPEympstcs009,gt.cs010TYPETABLEOFyrpstcs010,gs_cs010TYPEympstcs010.g_actionTYPEcVALUE3.DATA:gc_alvlOOTYPEREFTOcl_gui_alv_grid,用户角色ALVgc_containerlOOTYPEREFTOcl_gui_custom_container,ALV容器gs_layoutlOOTYPE
3、lvc_s_layo,ZkLV布局结构gt_fieldcatlOOTYPElvc_t_fcat.标题头DATA:gc_alv200TYPEREFTOcl_gui_alv_grid,用户角色ATNgc_container200TYPEREFTOcl_gui_custom_container,ALV容器gs_layout200TYPElvc_s_layo,ALV布局结构gt_fieldcat200TYPElvc_t_fcat,”标题头gs_lvc_s_stblTYPElvc_s_stblVALUE,XX.CLASSlcl_event_handlerDEFINITION.PUBLICSECTION.
4、METHODS:handle_double_clickFOREVENTdouble_clickOFcl_gui_alv_gridIMPORTINGe_rowe_columnes_row_nosender.ENDCLASS.CLASSlcl_event_handlerIMPLEMENTATION.METHODhandle_double_click.*双击事务PERFORMhandle_double_clicklOOCHANGINGe_columnes_row_no.ENDMETHOD.ENDCLASS.MODULEstatus_0100OUTPUT.SETPF-STATUS,100,.SETTI
5、TLEBAR,100,.PERFORMfrm_disp_alvl00.ENDMODULE.STATUS_0100OUTPUTModuleSTATUS_0200OUTPUTtextMODULEstatus_0200OUTPUT.SETPF-STATUS,200.SETTITLEBAR,200,.PERFORMfrm_disp_alv200.ENDMODULE.”STATUS_0200OUTPUTMODULEuser_command_0100INPUT.CALLMETHODgc_alvl00-check_changed_data.save_ok=ok_code.CLEARok_code.CASEs
6、ave_ok.WHEN,DISP,.g_action=,3,.WHENMODIFY,.g_action=,2.WHEN,BACK,.1.EAVETOSCREEN0.WHEN,CREAT,.gaction=,1.PERFORMfrm_create_datelOO.WHEN,DELE.PERFORMfrm_delete_datelOO.WHEN,SAVE,.PERFORMfrm_save_datelOO.WHENOTHERS.ENDCASE.CALLMETHODgc_alvlOO-check_changed_data.CALLMETHODgc_aIvl00-refresh_table_displa
7、yEXPORTINGis_stable=gs_lvc_s_stbl.ENDMODULE.USER_COMMAND_01OOINPUTModuleUSER_COMMAND_0200INPUTtextMODULEuser_command_0200INPUT.CALLMETHODgc_alv200-check_changed_data.save_ok=ok_code.CLEARok_code.CASEsave_ok.WHENDISP.g_action=3,.WHENMODIFY,.g_action=2.WHEN,BACK,.g_action=3,.1.EAVETOSCREEN0.WHENCREAT,
8、.g_action=,1,.PERFORMfrm_create_date200.WHEN,DELE.PERFORMfrm_delete_date200.WHENSAVE,.PERFORMfrmsavedate200.WHENOTHERS.ENDCASE.CALLMETHODgc_alv200-check_changed_data.CALLMETHODgc_alv200-refresh_table_displayEXPORTINGis_stable=gs_lvc_s_stbl.ENDMODULE.USER_COMMAND_0200INPUT*&包含YMPSR9010_F01*力&FormFRM_
9、DISP_ALV100*&*text-pltextp2textFORMfrm_disp_alvlOO.DATA:l_event_receiverTYPEREFTOlcl_event_handler.gs_layoutlOO-sel_mode=A.*gs_layoutlOO-zebra=abap_true.gs_layoutlOO-no_toolbar=X.gs_layoutlOO-cwidth_opt=X,.IFgt_cs009ISINITIAL.PERFORMfrm_getdatalOO.ENDIF.IFgc_containerlOOISINITIAL,createacontainerfor
10、thesplittercontrolCREATEOBJECTgc_containerlOOEXPORTINGcontainer_name=ALVlOOEXCEPTIONScntl_error=1cntl_system_error=2create_error=3lifetime_error=41ifetime_dynpro_dynpro_link=5OTHERS=6.IFsy-subrc0.-ExceptionhandlingMESSAGEIDsy-msgidTYPEsy-msgtyNUMBERsy-msgnoWITHsy-msgvlsy-msgv2sy-msgv3sy-msgv4.ENDIF.
11、createaninstanceofalvcontrolCREATEOBJECTgc_alvl00EXPORTINGi_parent=gc_containerlOOgc_containerl00EXCEPTIONSerror_cntl_create=1error_cntl_init=2error_cntl_link=3error_dp_create=4OTHERS=5.IFsy-subrc0.MESSAGEIDsy-msgidTYPEsy-msgtyNUMBERsy-msgnoWITHsy-msgvlsy-msgv2sy-msgv3sy-msgv4.ENDIF.CLEARgt_fieldcat
12、lOO.PERFORMfm_add_fieldcat_alvl00USING,SXFL,项目属性分类编号I15IIIIIIIIPERFORMfm_add_fieldcat_alvlOOUSING,SXFLT,项目属性分类描述,20PERFORMfm_add_fieldcat_alvl00USING,WBSCJ,层级维护,20,YMPSTCS007,WBSCJ,=WBSCJ,.CALLMETHODgc_alvl00-register_edit_eventEXPORTINGi_event_id=cl_gui_alv_grid=mc_evt_modifiedEXCEPTIONSerror=1OTHE
13、RS=2.CREATEOBJECTgceventlOO.SETHANDLERgc_eventlOO-handle_double_clickFORgc_alvlOO.CREATEOBJECTl_event_receiver.SETHANDLERl_event_receiver-handle_double_clickFORgc_alvl00.CALLMETHODgc_alvlOO-set_table_for_first_displayEXPORTINGis_layout=gs_layoutlOOit_toolbar_excluding=IJeXCIUdeCHANGINGit_outtab=gt_c
14、s009it_fieldcatalog=gt_fieldcatlOO.ELSE.IFg_action=,3,.CLEARgt_fieldcatlOO.PERFORM fm_add_fieldcat_alvlOO 15PERFORM fm_add_fieldcat_alvlOO ,20PERFORM fm_add_fieldcat_alvlOOUSING SXFL,USING ,SXFLT,USING ,WBSCJ,20 ,YMPSTCS007, WBSCJ, ,=WBSCJ,.ELSE.CLEAR gt_fieldcatlOO .PERFORM fm_add_fieldcat_alvlOO 15PERFORM fm_add_fieldcat_alvlOO ,20, ,XPERFORM fm add fieldcat alvlOOUSING SXFL,USING ,SXFLT,USING ,WBSCJ,,项目属性分类编号,项目属性分类描述,层级维护,项目属性分类编号,项目属性分类描述,层级维护,2