《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 1
15、5PERFORM fm_add_fieldcat_alvlOO ,20, ,XPERFORM fm add fieldcat alvlOOUSING SXFL,USING ,SXFLT,USING ,WBSCJ,,项目属性分类编号,项目属性分类描述,层级维护,项目属性分类编号,项目属性分类描述,层级维护,20,X,YMPSTCS007,WBSCJ,=WBSCJENDIF.CALLMETHODgc_alvlOO-set_frontend_fieldcatalogEXPORTINGit_fieldcatalog=gt_fieldcatlOO.CALLMETHODgc_alvlOO-refresh_
16、table_displayEXPORTINGis_stable=gs_lvc_s_stbl.ENDIF.FormFMADDFIELDCATALVtextP 0117textP 0118textP 0119textP 0120textFORM fm_add_fieldcat_alvl00 USING pl p2 p3 p4 p5 p p7.DATA ls_fcat TYPE lvc_s_fcat.ls_fcat-fieIdname = pl. ls_fcat-scrtext_s = pl. ls_fcat-scrtext_m = pl. ls_fcat-scrtext_l = pl. ls_fc
17、at-coltext = p2. ls_fcat-outputIen = p3. ls_fcat-edit = p4 . IF p5 IS NOT INITIAL.ls_fcat-ref_table = p5.ENDIF.IF p IS NOT INITIAL. ls_fcat-ref_field = p.ENDIF.ls_fcat-edit_mask = p7.APPEND ls_fcat TO gt_fieldcatlOO.ENDFORM.” FM_ADD_FIELDCAT_ALV1 OO*& Form FRM_DISP_ALV200text* 一 pltexttextFORMfrm_di
18、sp_alv200.gs_layout200-sel_mode=,A,.*gs_layout200-zebra=abap_true.gs_layout200-no_toolbar=,X,.gs_layout200-cwidth_opt=,X,.IFgc_container200ISINITIAL.*createacontainerforthesplittercontrolCREATEOBJECTgc_container200EXPORTINGcontainer_name=,ALV200,EXCEPTIONScntl_error=1cntl_system_error=2create_error=
19、3lifetime_error=41ifetime_dynpro_dynpro_link=5OTHERS=6.IFsy-subrc0.*一ExceptionhandlingMESSAGEIDsy-msgidTYPEsy-msgtyNUMBERsy-msgnoWITHsy-msgvlsy-msgv2sy-msgv3sy-msgv4.ENDIF.*createaninstanceofalvcontrolCREATEOBJECTgc_alv200EXPORTINGi_parent=gc_container200ugc_containerlOOEXCEPTIONSerror_cntl_create=1
20、error_cntl_init=2error_cntl_link=3error_dp_create=4OTHERS=5.IFsy-subrc0.MESSAGEIDsy-msgidTYPEsy-msgtyNUMBERsy-msgnoWITHsy-msgvlsy-msgv2sy-msgv3sy-msgv4.ENDIF.CLEARgt_fieldcat200.项目属性编码项目属性描述PERFORMfm_add_fieldcat_alv200USING,XMSX,20,.PERFORMfmaddfieldcatalv200USINGXMSXT,20CALLMETHODgc_alv200-registe
21、r_edit_eventEXPORTINGi_event_id=cl_gui_alv_grid=mc_evt_modifiedEXCEPTIONSerror=1OTHERS=2.CALLMETHODgc_alv200-set_table_for_first_displayEXPORTINGis_layout=gs_layout200CHANGINGit_outtab=gt_cs010it_fieldcatalog=gt_fieldcat200.ELSE.IF g_action,3,.CLEAR gt_fieldcat200.PERFORM fm_add_fieldcat_alv200USING
22、XMSX属性编码20PERFORM fm add fieldcat alv200USING,XMSXT目属性描述20ELSE.CLEAR gt_fieldcat200.PERFORM fm add fieldcat alv200USING,XMSX目属性编码20PERFORM fm add fieldcat alv200USING,XMSXT,,项目属性描述20X,.ENDIF.CALLMETHODgc_alv200-set_frontend_fieldcatalogEXPORTINGit_fieldcatalog=gt_fieldcat200.CALLMETHODgc_alv200-refr
23、esh_table_displayEXPORTINGis_stable=gs_lvc_s_stbl.ENDIF.ENDFORM.FRM_DISP_ALV2OOFormFM_ADD_FIELDCAT_ALV200text-P_0359textP_0360text-P_0361text-P_0362textFORMfm_add_fieldcat_alv200USINGplp2p3p4.DATAls_fcatTYPElvc_s_fcat.ls_fcat-fieIdname=pl.ls_fcat-scrtext_s=pl.ls_fcat-scrtext_m=pl.ls_fcat-scrtext_l=p
24、l.ls_fcat-coltext=p2.ls_fcat-outputIen=p3.ls_fcat-edit=p4.APPENDls_fcatTOgt_fieldcat200.ENDFORM.”FM_ADD_FIELDCAT_ALV200*&FormHANDLE_DOUBLE_CLICK100text-P_E_COLUMNtextpltextpltextpltext*get_selected_rowsIMPORTINGet_row_no=lt_row_no.IFlines(lt_row_no)=0.MESSAGEs000WITHtext-003DISPLAYLIKEE,.RETURN.ENDI
25、F.1.OOPATlt_row_noINTOls_row_no.READTABLEgt_cs009INTOgs_cs009INDEX1s_row_no-row_id.SELECT*INTOTABLEgt_cs010FROMympstcs010WHEREsxfl=gs_csO09-sxf1.* READTABLEgt_cs010INTOgs_cs010INDEX1.* IFgs_cs010-sxflspace.* MESSAGESOOOWITHtet-OO4DISPLAYLIKE,E,.* EXIT.ENDIF.* CLEAR:gt_cs010fgs_cs010.IFgs_Cs009ISNOTI
26、NITIAL.SELECT*INTOTABLElt_tjg005FROMympstjg005WHEREsxfl=gs_cs009-sxf1.IFlt_tjg005ISNOTINITIAL.MESSAGEsll(ymca)WITHgs_cs009-sxf1DISPLAYLIKE,E,.RETURN.ENDIF.DELETEFROMympstcs009WHEREsxfl=gs_cs009-sxf1.MESSAGEs000WITHtext-005DISPLAYLIKES.CLEARgs_cs009.ENDIF.ENDLOOP.PERFORMfrm_getdatal00.ENDFORM.“FRM_DE
27、LETE_DATE1OOFormFRM_SAVE_DATE1OOtext* -pltext* -p2textFORMfrm_save_date100.DATA:lt_cs009TYPETABLEOFympstcs009,lt_cs009_iTYPETABLEOFympstcs009,ls_cs009TYPEympstcs009,ls_cs009_temTYPEympstcs009,lv_sxflTYPEiVALUE1.SELECT * FROM ympstcs009INTO TABLE lt_CsOO9.”自动编码1.OOPATgt_cs009INTOgs_cs009.IFgscs009-sx
28、flISINITIAL.DO.READTABLElt_Cs009INTOls_Cs009WITHKEYsxfl=lv_sxf1.IFsy-subrc0.gs_cs009-sxf1=lv_sxf1.lv_sxf1=lv_sxf1+1.EXIT.ELSE.lv_sxf1=lv_sxf1+1.ENDIF.ENDDO.ENDIF.APPENDgs_cs009TOlt_cs009_i.ENDLOOP.CLEARlv_sxf1.IFlt_Cs009_iISINITIAL.MESSAGEsOOOWITHtext-006DISPLAYLIKE,E,.RETURN.ENDIF.保存校验DATA:lt_009TY
29、PETABLEOFympstcs009,ls_009TYPEympstcs009.REFRESHlt_009.1.OOPATlt_cs009_iINTOgs_cs009.1.OOPATlt_009INTOls_009.IFls_009-sxfIt=gs_cs009-sxfIt.MESSAGEeOOO(ymca)WITHls_009-sxflttext-007DISPLAYLIKE,ECLEARls_009.RETURN.ENDIF.ENDLOOP.APPENDgs_cs009TOlt_009.ENDLOOP.PERFORMfrm_popup_messageUSINGtext-008text-0
30、09CHANGINGl_answer.MODIFYympstcs009FROMTABLElt_cs009_i.MESSAGEs000WITHtext-010DISPLAYLIKES.PERFORMfrm_getdatalOO.ENDFORM.FRM_SAVE_DATE1OOFormFRM_CREATE_DATE200text*-pltext*pltext*get_selected_rowsIMPORTINGet_row_no=lt_row_no.IFlines(lt_row_no)=0.MESSAGEs000WITHtext-003DISPLAYLIKE,E,.RETURN.ENDIF.1.O
31、OPATlt_row_noINTOls_row_no.READTABLEgt_cs010INTOgs_cs010INDEXls_row_no-row_id.IFgs-cslISNOTINITIAL.SELECT*INTOTABLElt_tjg005FROMympstjg005WHEREsxfl=gs_cs010-sxf1ANDxmsx=gs_cs010-xmsIFlt_tjg005ISNOTINITIAL.MESSAGEsll7(ymca)WITHgs_cs010-xmsxDISPLAYLIKEE,.RETURN.ENDIF.DELETEFROMympstcs010WHEREsxfl=gs_c
32、s010-sxf1.MESSAGEs000WITHtext-005DISPLAYLIKE,S,.CLEARgs_csOlO.ENDIF.ENDLOOP.PERFORMfrm_getdata200.MESSAGEs000WITHtext-005DISPLAYLIKE,S,.ENDFORM.FRM_DELETE_DATE200FormFRM_SAVE_DATE200texttext-P2textFORMfrm_save_date200.DATA:lt-cslTYPETABLEOFympstcsl,lt_cs010_iTYPETABLEOFympstcs010,ls_cs010TYPEympstcs
33、010,ls_cs010_temTYPEympstcs010,lv_xmsxTYPEiVALUE.SELECT*FROMympstcslINTOTABLElt_cs010WHEREsxf1=gs_cs009-sxf1.”自动编码1.OOPATgt_cs010INTOgs_cs010.lv_xmsx.IFgs_cs010-xmsxISINITIAL.DO.READTABLElt_Cs010INTOls_Cs010WITHKEYxmsxIFsy-subrc0.lv_xmsx=gs_cs009*IO+1.gs_cs010-xmsx=lv_xmsx.gs_cs010-sxf1=gs_cs009-sxf
34、1.lv_xmsx=lv_xmsx+1.EXIT.ELSE.lv_xmsx=lv_xmsx+1gs_cs010-xmsx=lv_xmsx.gs_cs010-sxf1=gs_cs009-sxf1.ENDIF.ENDDO.ENDIF.APPENDgs_cs010TOlt_cs010_i.ENDLOOP.CLEARlv_xmsx.IFlt_Cs010_iISINITIAL.MESSAGEsOOOWITHtext-006DISPLAYLIKE,E,.RETURN.ENDIF.保存校验DATA:lt_010TYPETABLEOFympstcsl,ls_010TYPEympstcs010.REFRESHI
35、tOlO.1.OOPATlt_cs010_iINTOgs_cs010.1.OOPATlt_010INTOls_010.IFls_010-xmsxt=gs_cs010-xmsxt.MESSAGEe000(ymca)WITHls_010-xmsxttext-007DISPLAYLIKEECLEARls_010.RETURN.ENDIF.ENDLOOP.APPENDgs_cs010TOlt_010.ENDLOOP.PERFORMfrm_popup_messageUSINGtext-008text-009CHANGINGl_answer.CHECK1answerMODIFYympstcs010FROMTABLElt_Cs010_i.MESSAGEs000WITHtext-010DISPLAYLIKES.PERFORMfrm_getdata200.ENDFORM.FRM_SAVE_DATE200FormFRM_POPUP_MESSAGEtext-P_TEXT_001text-P_TEXT_002textpltext*-p2textFORMfrm_getdata200.SELECT*INTOCORRESPONDINGFIELDSOFTABLEgt_cs010FROMympstcs010WHEREsxf1=gs_cs009-sxf1.FRM GETDATA200ENDFORM.
链接地址:https://www.desk33.com/p-480304.html