1、SAPBADI屏幕增强实例MBMIGOBADI精编文档doc【最新整理,下载后即可编辑】以下根据系统实例做的最终效果:1、SE11建立数据表,主要是用于存放附加的数据;MANDT MANDT CLNT 3 0 客户端 MBLNR MBLNR CHAR 10 0 物料凭证编号MJAHR MJAHR NUMC 4 0 物料凭证年度ZEILE MBLPO NUMC 4 0 物料凭证中的项目BADI_ERFMG ERFMG QUAN 13 3 以输入单位计的数量 BADI_ERFME ERFME UNIT 3 0 条目单位2、建立结构,在屏幕数据交换时使用3、建立表类型设置关键字段:4、SE80建立函
2、数组创建屏幕1000,设计格式,插入附加字段创建function: ZJIM_BADI_EXAMPLE_GET_DATA*-*Localinterface:*EXPORTING*REFERENCE(ES_MIGO_BADI_SCREEN_FIELDS)TYPE*ZJIM_BADI_EXAMPLE_SCREEN_FIELD*-*Getalldatafromfieldsofexternalscreen*Firstmoveallcustomer-fieldsMOVE-CORRESPONDINGzjim_badi_examplTOes_migo_badi_screen_fields.*Secondmo
3、veallGOITEM-fields(displayedonexternalscreen)function: ZJIM_BADI_EXAMPLE_PUT_DATA*-*Localinterface:*IMPORTING*REFERENCE(IS_MIGO_BADI_SCREEN_FIELDS)TYPE*ZJIM_BADI_EXAMPLE_SCREEN_FIELD*-*Putalldatafromfieldstoexternalscreen*Firstfillallcustomer-fieldsMOVE-CORRESPONDINGis_migo_badi_screen_fieldsTOZJIM_
4、badi_exampl.*secondfillallGOITEM-fields(displayedonexternalscreen)function: ZJIM_BADI_EXAMPLE_UPDATE_DATA*-*Updatefunctionmodule:*Localinterface:*TABLES*IT_MIGO_BADI_EXAMPLESTRUCTUREZJIM_BADI_EXAMPL*-*Databseupdate:INSERTzjim_BADI_EXAMPLFROMTABLEIT_MIGO_BADI_EXAMPLE.IFsy-subrc0.MESSAGEa398(00)WITHEr
5、rorupdateMIGO_BADI_EXAMPL.ENDIF.INCLUDE : LZJIM_BADI001TOPTABLES:Zjim_badi_exampl.到这里增强的准备工作就做完了,下面开始创建实现:5、SE19创建实现6、创建执行类ZCL_IM_JIM_MIGO_BADI,激活ZJIM_MIGO_BADI双击类维护类属性GT_EXTDATA 用于数据交换,类型为ZJIM_TY_T_EXTDATA表类型,7、激活以下方法并维护:methodIF_EX_MB_MIGO_BADIINIT.*RegristrationofBAdI-Implementation:*Appendclassa
6、ttributeGF_CLASS_ID(=MIGO_BADI_IMPLEMENTATION1)to*regristrationtable.APPENDgf_class_idTOct_init.endmethod.METHODIF_EX_MB_MIGO_BADIPBO_DETAIL.DATA:ls_extdataTYPEzjim_badi_example_screen_field.*Thischeckisobligatory,otherwisetheprogramflowisincorrect*(IftherewouldbemorethanoneimplementationofBAdIMB_MI
7、GO_BADI,*onlyonesubscreenwouldbedisplayed).CHECKi_class_id=gf_class_id.*ShowscreenonlyifthereisanitemCHECKi_line_id0.*Externalsubscreen:*ThecontentofglobalfieldG_NO_INPUT(setinmethodMODE_SET)will*influencethenumberofexternalsubsreen:ifg_no_inputisinitial.e_cprog=SAPLZJIM_BADI001(006). 程序名为定义的函数组的名称前
8、加“SAPL“。e_dynnr=1000.Externalfields:Inpute_heading=ZJIM(004). 显示标签的名称endif.*SetG_LINE_ID(=line_idofitemdisplayedondetail-tabstrip)g_line_id=i_line_id.*ReaddataREADTABLEgt_extdataINTOls_extdataWITHTABLEKEYline_id=i_line_id.*Exportdatatofunctiongroup(fordisplayonsubscreen)CALLFUNCTIONZJIM_BADI_EXAMPLE
9、_PUT_DATAEXPORTINGis_migo_badi_screen_fields=ls_extdata.ENDMETHOD.IF_EX_MB_MIGO_BADIPBO_DETAILMETHODIF_EX_MB_MIGO_BADIPAI_DETAIL.*-*ChangingparameterE_FORCE_CHANGEcanbesettoX.Inthiscase*methodLINE_MODIFYiscalled.*ATTENTION:*DONOTSETparameterE_FORCE_CHANGE=.Inthiscaseyoumight*overwriteparameterE_FORC
10、E_CHANGEofanotherBAdIimplementation.*-DATA:ls_extdata_newTYPEzjim_badi_example_screen_field,ls_extdata_oldTYPEzjim_badi_example_screen_field.*OnlyifalineexistsCHECKi_line_id0.*GetdatafromexternalscreenCALLFUNCTIONZJIM_BADI_EXAMPLE_GET_DATAIMPORTINGes_migo_badi_screen_fields=ls_extdata_new.*Comparene
11、wdatawitholddataREADTABLEgt_extdataINTOls_extdata_oldWITHTABLEKEYline_id=i_line_id.ls_extdata_new-line_id=i_line_id.IFls_extdata_oldls_extdata_new.*Iftherewereanychanges,itsobligatorytoforceMIGOtotrigger*methodLINE_MODIFY.e_force_change=X.ENDIF.ENDMETHOD.IF_EX_MB_MIGO_BADIPAI_DETAILMETHODIF_EX_MB_MI
12、GO_BADILINE_MODIFY.DATA:ls_extdata_oldTYPEzjim_badi_example_screen_field,ls_extdata_newTYPEzjim_badi_example_screen_field,ls_migo_badi_examplTYPEzjim_badi_exampl,l_subrcTYPEsy-subrc.*Getexternaldatafrominternaltable:READTABLEgt_extdataINTOls_extdata_oldWITHTABLEKEYline_id=i_line_id.l_subrc=sy-subrc.
13、*Updatedataininternaltable:IFl_subrc0.*Lineisnew:IfGOITEMhasareferencetoamaterialdocument,*thealreadyexistingexternaldatacanberead.IFNOTcs_goitem-mblnrISINITIALANDNOTcs_goitem-mjahrISINITIALANDNOTcs_goitem-zeileISINITIAL.SELECTSINGLE*FROMzjim_badi_examplINTOls_migo_badi_examplWHEREmblnr=cs_goitem-mb
14、lnrANDmjahr=cs_goitem-mjahrANDzeile=cs_goitem-zeile.IFsy-subrc=0.MOVE-CORRESPONDINGls_migo_badi_examplTOls_extdata_new.ENDIF.ENDIF.*ls_extdata_new-sgtxt=cs_goitem-sgtxt.ls_extdata_new-line_id=i_line_id.INSERTls_extdata_newINTOTABLEgt_extdata.ELSE.*Lineexists:GetexternaldataenteredonBAdI-subscreeen,b
15、utonly*ifline_modifywascalledfortheitemdisplayedinthe*detailtabstrip.checkg_line_id=i_line_id.CALLFUNCTIONZJIM_BADI_EXAMPLE_GET_DATAIMPORTINGes_migo_badi_screen_fields=ls_extdata_new.ls_extdata_new-line_id=i_line_id.*ifls_extdata_new-sgtxtls_extdata_old-sgtxt.*Fieldwaschangedonexternalscreen*cs_goit
16、em-sgtxt=ls_extdata_new-sgtxt.*else.*TakedatafromGOITEM*ls_extdata_new-sgtxt=cs_goitem-sgtxt.*endif.MODIFYTABLEgt_extdataFROMls_extdata_new.ENDIF.ENDMETHOD.IF_EX_MB_MIGO_BADILINE_MODIFYMETHODIF_EX_MB_MIGO_BADILINE_DELETE.DELETETABLEgt_extdataWITHTABLEKEYline_id=i_line_id.ENDMETHOD.IF_EX_MB_MIGO_BADI
17、LINE_DELETEMETHODIF_EX_MB_MIGO_BADIPOST_DOCUMENT.DATA:ls_migo_badi_exampleTYPEZJIM_badi_exampl,lt_migo_badi_exampleTYPETABLEOFzjim_badi_exampl,ls_extdataTYPEzjim_badi_example_screen_field,ls_xmsegTYPEmseg.FIELD-SYMBOLS:TYPEmigo_badi_example_screen_field.*TransactionMIGOwillnowpostamaterialdocument.*
18、AnyerrorshereMUSTbeissuedasA-message(better:X-message)*CopydatafrommaterialdocumentintointernaltableLOOPATgt_extdataINTOls_extdata.IFg_cancelISINITIAL.READTABLEit_msegINTOls_xmsegWITHKEYline_id=ls_extdata-line_id.ELSE.READTABLEit_msegINTOls_xmsegWITHKEYsmbln=ls_extdata-mblnrsmblp=ls_extdata-zeilesja
19、hr=ls_extdata-mjahr.ENDIF.IFsy-subrcISINITIAL.MOVE-CORRESPONDINGls_extdataTOls_migo_badi_example.MOVE-CORRESPONDINGls_xmsegTOls_migo_badi_example.APPENDls_migo_badi_exampleTOlt_migo_badi_example.ENDIF.ENDLOOP.*Thedatafromexternaldetailscreencanbesavednow:CHECKgt_extdataISNOTINITIAL.CALLFUNCTIONZJIM_
20、BADI_EXAMPLE_UPATE_DATAINUPDATETASKTABLESit_migo_badi_example=lt_migo_badi_example.*Thedatafromexternalheaderscreencanbesavednow:*MOVE-CORRESPONDINGis_mkpfTOgs_exdata_header.*CALLFUNCTIONMIGO_BADI_EXAMPLE_UPDATE_HEADINUPDATETASK*EXPORTING*is_migo_badi_header_fields=gs_exdata_header.ENDMETHOD.IF_EX_MB_MIGO_BADIPOST_DOCUMENTMETHODIF_EX_MB_MIGO_BADIRESET.*Clearallinternaldata:CLEAR:gt_extdata,g_no_input,gs_exdata_header,g_cancel,g_line_id.ENDMETHOD.IF_EX_MB_MIGO_BADIRESET激活所有,运行T_code MIGO 就可以看到第一个图的效果了。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1