Вы находитесь на странице: 1из 7

GettingStarted Store

CommunityWIKI SAPCommunity Welcome,Guest Login Register SearchtheCommunity


ABAPDevelopment

DetailedexplanationaboutBADIandthewaystofindtheBADIwithan
example(ME23ntransaction)
CreatedbyGuest,lastmodifiedbyBretHalfordonJul18,2013

DetailedexplanationaboutBADIwithanexample(ME23ntransaction)

Def:

BADI(BusinessAddIn)isanewSAPObjectOrientedenhancementtechniquewhichisusedtoaddourownbusinessfunctionalitytotheexistingSAPstandardfunctionality.
BADI'sareavailableinSAPR/3fromthesystemrelease4.6c

WhyBADI?

Incontrasttotheearlierenhancementtechniques,BADIfollowsObjectOrientedapproachtomakethemreusable.ABADIcanbeusedanynumberoftimeswhereasstandardenhancementtechniques
canbeusedonlyonce.
Forexampleifweassignanenhancementtoonecustomproject,thenthatenhancementcannotbeassignedtoanyothercustomprojects.ToovercomethisdrawbackSAPhasprovidedanew
enhancementtechniquecalledBADI.

TransactioncodeforBADIDefinition:

SE18
WhenyoucreateaBAdIdefinition,aclassinterfacewillbeautomaticallycreatedandyoucandefineyourmethodsintheinterface.TheimplementationofthemethodscanbedoneinSE19transaction.
WhenaBAdiiscreatedfollowingareautomaticallygenerated:

Aninterfacewith'IF_EX_'insertedbetweenthefirstandsecondcharactersoftheBAdiname
Anadapterclasswith'CL_EX_'insertedbetweenthefirstandsecondcharactersoftheBAdiname.

TransactioncodetoImplementBADI:

SE19

TypesofBADI's:

WhilecreatingaBADIusingtheTcodeSE18,itprovidesthepopupscreentoselectthetypeofBADItobeusedisasshownbelow.

TherearetwotypesofBADI's.

1)MultiuseBADI:

Withthisoption,anynumberofactiveimplementationscanbeassignedtothe
samedefinitionBADI.Bydefaultthisoptionischecked.
IfwewanttheBADIformultipleuse

IfyouhavemultipleuseBADIdefinitions,thesequencemustnotplayanyrole.

ThedrawbackinMultipleuseBADIis,itisnotpossibletoknowwhichBADIis
activeespeciallyincountryspecificversion.

2)FilterdependentBADI:

UsingthisoptionwecandefinetheBADI'saccordingtothefiltervaluestocontrol
theaddinimplementationonspecificcriteria.

Ex:Specificcountryvalue.

HowtoFindBADI'sinSAPsystem:

Method1:
StepstofindBADI:
1.GotoSE24transaction,typeCL_EXITHANDLERandthenclickondisplay.

2.DoubleclickonGET_INSTANCEmethod.

3.PutabreakpointonclassmethodCL_EXITHANDLER=>GET_CLASS_NAME_BY_INTERFACE.

4.RunanytransactiononwhichwewantfindtheBADI'ssayVA01.

5.GivethetransactionnameVA01andpressenter.
6.ItwillautomaticallytakeyoutothebreakpointwhichwehavesettheintheSE24transaction.EachtimeifyoupressF8alistBADInameswillbedisplayed.

7.YoucanfindtheBADInameinfieldEXIT_NAMEandifyoudoubleclickonit,wecangetthecorrespondingBADInamebeforehitthecorrespondingscreen.BasedontherequirementfindtheBADIname
andaccordinglyimplementyourfunctionalityusingthetransactionse19.

Method2:

GototransactionSE84andclickonEnhancements.ThendoubleclickonBusinessAddIns.
Forexample,ifyouwanttofindtheBADI'sforthestandardtransactionME22n,theprocedureisasfollows.Thisexampleshows,findingthewayofBADInamesbyprovidingthePackageofME22n.
1)GototransactionME22n.SelecttheSystemoptionfromthemenuandthenclickonStatus.Itdisplaysthefollowinginformation.

2)Doubleclickontheprogramnamei.e.SAPLMEGUI.Itwilltakeyouintothe
programandclickonGototabfromtheMenu.Therewecanfindthepackage
nameofthestandardtransactionME22n.Copyandpasteitinthepackagefiled.

3)NowPressF8,alistofBADInameswillbedisplayedasshownbelow.
SelecttheappropriateBADInameandimplementitbasedonthebusiness
requirementusingthetransactionSE19.

Method3:

FindingtheBADInamesusingSE18transaction
1)GototransactionSE18.SelectF4helpforthedefinitionnameandclickonInformationSystembutton
asshownbelow.

2)ApopupscreenwillbedisplayedandgivethepackagenameforanystandardtransactionsayVA02.
Findingthepackageisexplainedabove.Pleasereferabovemethodtofindthepackagename.Thepackage
nameforVA02transactionis'VA.'

3)AlistofBADInameswillbedisplayedforthetransactionVA02.SelecttheappropriateBADInameand
implementitusingTcodeSE19.

Example:

ThisExampleexplainshowtoimplementBADI's.HereIamtryingtoshowhowtoaddcustomscreentotheME23NTransactionsusingBADI's.
Theprocedureisasexplainedbelow.

FindtheBADIusingthemethod1asshownabove.
TheBADInametoaddthecustomscreentoME23nis'ME_GUI_PO_CUST'.

GotoTcodeSE19andcreateanimplementationZME_GUI_PO_CUSTandthenclickoncreatebutton
GivetheDefinitionname"ME_GUI_PO_CUST"andcontinue,giveshorttext,save
ClickonInterfaceTab,youcanfindtheimplementationclassnameas
ZCL_IM_ME_GUI_PO_CUST2.
ClickonZCL_IM_ME_GUI_PO_CUST2,whichwilltakeyoutoSE24.
Add"MMMFD"intheTypeGroupSectionofpropertiestab.
GotoAttributessectionanddeclarethefollowingattribute
SUBSCREEN1ConstantPublicTypeMEPO_NAMENameofaView
'ITEMSCREEN1'.
GotoMethodssection,youcanfindtheBADIinterfacemethods.
Doubleclickonthemethod"IF_EX_ME_GUI_PO_CUST~SUBSCRIBE",
thismethodishaving3parameters

Gotothecodesectionofthemethodandaddthefollowingcodethere.

CodeforIF_EX_ME_GUI_PO_CUST~SUBSCRIBE:

DATA:ls_subscriberLIKELINEOFre_subscribers.
*FIRSTSCREENPOPULATION

*wewanttoaddacustomersubscreenontheitemdetailtab

CHECKim_application='PO'.

CHECKim_element='ITEM'.
*eachlineinre_subscribersgeneratesasubscreen.Weaddonesubscreen

*inthisexample

CLEARre_subscribers[].

*thenameisauniqueidentifierforthesubscreenanddefinedinthis

*classdefinition

ls_subscribername=subscreen1.
*thedynpronumbertouse

ls_subscriberdynpro='0002'.
*theprogramwherethedynprocanbefound

ls_subscriberprogram='ZME_GUI_PO_CUST_SCREEN'.
*eachsubscreenneedsitsownDDICStructure

ls_subscriberstruct_name='ZMARA'.
*alabelcanbedefined

ls_subscriberlabel='CustBADI'.
*thepositionwithinthetabstribcanbedefined

ls_subscriberposition=7.

*theheightofthescreencanbedefinedhere.Currentlywesupporttwo

*screensizes:

*value<=7asevellinesubscreen

*value>7a16linesubscreen

ls_subscriberheight=7.
APPENDls_subscriberTOre_subscribers.
Saveandcheckandback
DoubleclickonmethodIF_EX_ME_GUI_PO_CUST~MAP_DYNPRO_FIELDS".

Addthefollowingcodeinthemethod.
*giventhefieldcatalogofstructureZMARAwehaveto

*establishamappingtometafieldswhichareusedforfieldselection

*purposesanderrorhandlingStandarddefinitionscanbefoundintype

*poolMMMFD.Itisimportantforcustomerfieldstouseinteger

*constantsabove90000000forthemetafield.
FIELDSYMBOLS:<mapping>LIKELINEOFch_mapping.
LOOPATch_mappingASSIGNING<mapping>.
CASE<mapping>fieldname.
WHEN'MATNR'.<mapping>metafield=mmmfd_cust_08.
WHEN'MTART'.<mapping>metafield=mmmfd_cust_09.

WHEN'MATKL'.<mapping>metafield=mmmfd_cust_10.
ENDCASE.

ENDLOOP.

Themetafieldmappingimportantforfieldselectionanderrorhandlingpurpose.
Save,checkandback
ActivatetheImplementationclass.
ActivatetheBADIImplementation.

NowcreateastructureinSE11withthenameZMARA.

Addthefollowingfieldsinthestructure.

NowCreateaProgramwiththeName'ZME_GUI_PO_CUST_SCREEN'and
createascreenwithsubscreentypewiththenumber0002.

AddthefieldsontoscreenfromZMARAprogram
'ZME_GUI_PO_CUST_SCREEN'.

**

DecommentthePBOmoduleinscreenflowlogicandcreatethemoduleinabove
program.

AddthefollowingcodeinprogramZME_GUI_PO_CUST_SCREEN.
TABLES:ZMARA.
DATA:call_subscreenTYPEsydynnr,

call_progTYPEsyrepid,

call_viewTYPEREFTOcl_screen_view_mm,

call_view_stackTYPEREFTOcl_screen_view_mmOCCURS0.

**

*FORMSET_SUBSCREEN_AND_PROG*

**

*........*

**

*>DYNNR*

*>PROG*

*>VIEW*

*>TO*

*>CL_SCREEN_VIEW_MM*

**

FORMset_subscreen_and_progUSINGdynnrTYPEsydynnr

progTYPEsyrepid

viewTYPEREFTOcl_screen_view_mm.

call_subscreen=dynnr.

call_prog=prog.

call_view=view.

ENDFORM.
*&*

*&ModuleSTATUS_0002OUTPUT

*&*

*text

**

MODULESTATUS_0002OUTPUT.
SELECTSINGLE*FROMMARA

INTOCORRESPONDINGFIELDSOFZMARA

WHEREMATNR='100100'.
ENDMODULE."STATUS_0002OUTPUT

Thesubroutine"set_subscreen_and_prog"ismustwiththesamesignature.
ThisroutineiscalledfromBADItocallthesubscreen.
Activatethescreen&program.
NowGotoTCodeME23Ntotesttheapplication.
YoucanfindanewtabisaddedintheitemlevelwiththenameCUSTBADI.

FinalOutput:

Nolabels

5Comments
Guest
Hi,

HowtoenableBAdiME_PROCESS_PO_CUSTdefinition"MultipleUse"enable?

SId

Guest
thanxforthepost

sumanthpelluru
Thanksforpostingusefulinformationofbadi.

iwantliketoknowthat...suppose,ifwehavedone3implementationsforasinglemethod(usingMultiplebadi's),andifwehavecalledthatmethod,howdoweknowthataparticular
implementedbadiistriggeredfromthat3implementations....:)

HarkiratKaur
DetailExplanationofBADI'sprovidingclarityoftopic.

ShaveenKaushal
Veryusefulexample.Thanksforposting.

ContactUs SAPHelpPortal
Privacy TermsofUse LegalDisclosure Copyright FollowSCN

Вам также может понравиться