BADI's Customer Enhancements

Embed Size (px)

Citation preview

  • 8/13/2019 BADI's Customer Enhancements

    1/16

    Business Add-Ins

    Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAPSystem to accommodate user requirements too specific to be included in the standard deliery. Since specific industriesoften require special functions! SAP allows you to predefine these points in your software.

    As with customer e"its #S$O%&'$O%(! two different iews are aailable)

    In the definition iew! an application pro*rammer predefines e"it points in a source that allow specific industry

    sectors! partners! and customers to attach additional software to standard SAP source code without hain* tomodify the ori*inal object.

    In the implementation iew! the users of Business Add-Ins can customi+e the lo*ic they need or use a standard

    lo*ic if one is aailable.

    In contrast to customer e"its! Business Add-Ins no lon*er assume a two-system infrastructure #SAP and customers(! butinstead allow for multiple leels of software deelopment #by SAP! partners! and customers! and as country ersions!industry solutions! and the li,e(. %efinitions and implementations of Business Add-Ins can be created at each leel withinsuch a system infrastructure.

    SAP *uarantees the upward compatibility of all Business Add-In interfaces. elease up*rades do not affect enhancementcalls from within the standard software nor do they affect the alidity of call interfaces. ou do not hae to re*isterBusiness Add-Ins in SS'.

    The Business Add-In enhancement technique differentiates between enhancements that can only be implemented onceand enhancements that can be used actiely by any number of customers at the same time.

    In addition! Business Add-Ins can be defined accordin* to filter alues. This allows you to control add-in implementationand ma,e it dependent on specific criteria #on a specific Country alue! for e"ample(.

    All ABAP sources! screens! /0Is! and table interfaces created usin* this enhancement technique are defined in a mannerthat allows customers to include their own enhancements in the standard.

    A sin*le Business Add-In contains all of the interfaces necessary to implement a specific tas,. In elease 1.2A! pro*ramand menu enhancements can be made with Business Add-Ins.The actual pro*ram code is enhanced usin* ABAP Objects. In order to better understand the pro*rammin* techniques

    behind the Business Add-In enhancement concept! SAP recommends readin* the section on ABAP Objects.

    $ore information about Business Add-Ins is contained in the followin* sections)

    Business Add-Ins) Architecture

    A 'omparison of %ifferent 3nhancement Techniques

    %efinin* Business Add-Ins

    'allin* Add-Ins from Application Pro*rams

    Implementin* Business Add-Ins

    4ilter-%ependent Business Add-Ins

    $ultiple 0se Business Add-Ins

    $enu 3nhancements

  • 8/13/2019 BADI's Customer Enhancements

    2/16

    Business Add-Ins) Import Procedure

    Customer Enhancements (BC-DWB-CEX)

    5ocation in a pro*ram defined by the deeloper at which deliered software layers #industries! partners! customers! etc.(can insert codin* without modifyin* the ori*inal object.

    Business Add-Ins can be created at eery leel of a multi-leel system infrastructure #SAP! country ersions! IS solutions!partners! customers! etc(. Implementations can also be created and deliered in all software layers.

    The enhancement technique with Business A%d-Ins distin*uishes between enhancements that can hae at most oneimplementation and those that can be actiely used by any number of customers at the same time. Business Add-Ins canalso be defined independently of a filter alue.

    3nhancements to the pro*ram codin* are implemented with ABAP objects.

    Business Add-Ins: Architecture

    In order to enhance a pro*ram! a Business Add-In must first be defined. Application deelopers create an interface for theadd-in. 3nhancement mana*ement ta,es this interface and *enerates an adapter class for implementin* it! thus openin*a path for implementations created by partners or customers. our deeloper then creates an instance of the adapterclass in the application pro*ram and calls the correspondin* method at the appropriate time.

    'ustomers can find the enhancements present in their system in the I$/ and in the component hierarchy. 6heneer theywant to use a Business Add-In! they must create their own implementation of the add-in. 'ustomers must first implementmethods and user interface enhancements! and then actiate their implementations of the enhancement. Theenhancement7s actie components are then called at runtime.

    8ormally! a Business Add-In contains an interface and other additional components such as function codes for menuenhancements. Startin* with the ne"t release! Business Add-Ins will also include enhancements for screens and tables.

    The enhancement! interface! and associated classes *enerated all lie in the appropriate application deelopmentnamespace. Business Add-In implementations lie in the respectie namespaces of the people who created them.

  • 8/13/2019 BADI's Customer Enhancements

    3/16

    The followin* sections contain e"amples of both pro*ram enhancements and menu enhancements.

    A Comparison of Different Enhancement Techniques

    %ue to the necessity of adjustin* &9 to meet the specific needs of a ariety of customers! seeral different enhancementtechniques were deeloped in the past. A short description of each of the arious enhancement techniques follows.

    Business Transaction Events (Open FI)

  • 8/13/2019 BADI's Customer Enhancements

    4/16

    The Open 4I enhancement technique was deeloped in the 4inancial Accountin* component. Open 4I is based upon thefollowin* principles)

    Application deelopers must define their interface in a function module! an assi*nment table is read in the accompanyin*#*enerated( code! and the customer modules assi*ned are called dynamically.

    This technique differentiates between enhancements that are only allowed to hae one implementation andenhancements that can call multiple implementations in any sequence desired. Both industry-specific and country-specific

    enhancements may be defined.

    The concepts behind the Business Add-Ins enhancement technique and Open 4I are basically the same. :oweer! thetwo enhancement techniques do differ from each other in the followin* points)

    Open 4I can only be used to ma,e pro*ram enhancements! that is! you can only enhance source code usin*

    Open 4I. ou cannot enhance user interface elements with Open 4I li,e you can with Business Add-Ins.

    Open 4I assumes that enhancement will only ta,e place on three leels #SAP - partners - customers(! whereas

    with Business Add-Ins you can create and implement enhancements in as many software layers as you li,e.

    Open 4I uses function modules for pro*ram enhancements. 6ith Business Add-Ins! ABAP Objects are used

    enhance pro*rams.

    Enhancements in Transactions !OD"C!OD

    $a,in* enhancements usin* the transactions S$O%&'$O%has the followin* disadanta*es)

    This enhancement technique assumes a two-tiered system infrastructure #SAP ; customers(.

    The namin* conentions in effect do not tolerate name e"tension.

    Ta#in$ toc# of %our Options:

    8one of the techniques mentioned aboe can easily be e"tended to fulfill the requirements of a system infrastructurecontainin* country ersions! industry solutions! partners! and customers.

    Business Add-Ins should be considered *enerali+ed Business Transaction 3ents that can be used to bundle menu andpro*ram enhancements into a sin*le add-in #and in the future! screen and table enhancements as well(. Business Add-Inscan be created and employed in each of the arious software leels.

    Definin$ Business Add-Ins

    In order for application deelopers to include Business Add-Ins in their pro*rams! they must define an interface for the

    enhancement in the SAP menu under Tools ABAP WorkbenchUtilitiesBusiness Add-Ins#transaction S3

  • 8/13/2019 BADI's Customer Enhancements

    5/16

    >. 3nter a name for your Business Add-In containin* a ma"imum of >? characters.9. 'hoose Create.1. 3nter a short description for your Business Add-In on the followin* screen.

    If this enhancement is *oin* to be used multiple times or if you want its implementation to depend on a specificfilter alue! first choose Managementand then select the appropriate chec,bo" in the cate*ory Type.$oreinformation about multiple use and filter dependency can be found in the sections $ultiple 0se Business Add-Insand4ilter-%ependent Business Add-Ins.This e"ample only deals with basic enhancements! therefore neither of these chec,bo"es should be selected.

    @. 'hoose the Interacetab.The name of the interface is *enerated automatically and now appears alon* with the name of its correspondin*class. At this time! you can chan*e the name of the interface if you so desire.

    ou can use the !codestab to create menu enhancements. 4or more information! refer to the section on $enu3nhancements.

    2. %ouble-clic, on the interface7s name field to assi*n a method to the interface.. The system branches to the 'lass Builder. A dialo* bo" appears! as,in* you if you want to sae the entries you

    hae made. Sae your entries. Assi*n your add-in to a deelopment class.

    =. 0se the 'lass Builder to assi*n a method to the interface.

  • 8/13/2019 BADI's Customer Enhancements

    6/16

    . 8ow define a parameter with the followin* attributes)

  • 8/13/2019 BADI's Customer Enhancements

    7/16

    6hen you create default or sample code! do not for*et to sae your entries to ensure that the lin,between the class and the implementation can be established.

    Ca''in$ Add-Ins from App'ication ,ro$rams

    6hen you define a Business Add-In! enhancement mana*ement *enerates a class that implements your interface.Application deelopers use factory methods to create instances of these adapter classes in their application pro*rams andcall the correspondin* method if necessary.

    The adapter class methods *enerated by add-in mana*ement decide if multiple actie implementations should be called.If necessary! these implementations are subsequently e"ecuted. The application pro*ram itself simply calls the adapterclass methodsC it does not ,now which implementations are actually bein* called.

    E&amp'e)

    :ain* created a strin* conersion Business Add-In! you would pro*ram the call of the Business Add-In into your ABAPsource code as follows)

    Report businessaddin.

    class cl_exithandler definition load. "declaration

    data exit type ref to if_ex_businessaddin. "interface referencedata word(15) type c value 'Business dd!in'. "strin you want to chane

    start!of!selection.

    call #ethod cl_exithandler$%et_instance "factory #ethod call

    chanin instance $ exit.write&'lease clic here'.

    at line!selection. write& '*riinal word& '+word.

    call #ethod exit!%#ethode "add!in callchanin para#eter $ word.

    write& ',haned word& '+word.

    In order to be able to call static methods! you must declare the correspondin* class in ABAP Objects. This is why theclass - definition loadstatement is necessary for the factory class.

    A ariable for object reference is also necessary when callin* the method. 0se datato create it and type it to theinterface.

    Application deelopers use factory methods to create instances of adapter classes durin* initiali+ation in lines and =.The instance methods are then called at the appropriate time.

    otes on .sa$e

    The instance *enerated throu*h the factory method should be declared as *lobally as possible or *enerally be passed asa parameter to ensure that the initiali+ation process must be run throu*h as rarely as possible - one time would be best. Inno case should you discard the instance as soon as it is *enerated or repeatedly run the initiali+ation process in a loop.

  • 8/13/2019 BADI's Customer Enhancements

    8/16

    6ithin the instance of the adapter class! required database accesses are buffered locally! so that each access is e"ecutedonly once. :oweer! repeated initiali+ation ma,es the buffer useless and dramatically reduces performance.

    %ue to the local bufferin*! you can call Business-Add-In methods without hain* to e"pect considerable performancerestrictions een if no actie implementations e"ist.

    In particular! you are not required to use a function module to erify if actie implementations e"ist at all.

    Also! if the definition of the Business-Add-In is filter-dependent! a sin*le instance is sufficient.

    :oweer! you should not do without initiali+ation at all. Althou*h it would be possible to call static methods of theimplementin* class of the Business-Add-In implementation without an instance! you loose the benefit of performanceimproement throu*h the Business-Add-Ins and the possibility of repeated use. Also! if you switch the method type in theinterface from static to instantiatable at any time in the future! many code adjustments are required. In addition! you canno lon*er use default code proided.

    Imp'ementin$ Business Add-Ins

    A list of the Business Add-Ins present in your system can be found either in the I$/ or in the component hierarchy. Theenhancements7 names and correspondin* documentation should help you decide which add-in you want to create animplementation for. %urin* implementation creation! a class for implementin* the enhancement7s interface is also created.Implementations are discrete transport objects and lie within the namespace of the person or or*ani+ation implementin*them.

    In order to create an implementation for the strin* conersion e"ample! the add-in #in this case! the interface7s method(needs to be filled with lo*ic that conerts the strin*. This lo*ic will be run throu*h eery time the add-in is called from theapplication pro*ram.

    To create an implementation! proceed as follows)

    1. 'hooseABAP WorkbenchUtilitiesBusiness Add-Ins #transaction S3. 3nter a name for the implementation and choose Create.9. 3nter the name of the add-in you want to create an implementation for in the dialo* bo" that appears.

    1. 3nter a short te"t describin* your implementation on the followin* screen.@. 'hoose the Interacetab.

  • 8/13/2019 BADI's Customer Enhancements

    9/16

    2. In order to implement a method for your add-in! double-clic, on the method to branch to the 'lass Builder. oumust first enter a deelopment class before the 'lass Builder is displayed.

    7. Insert the desired source code for the implementation between the#ethod if_ex_businessaddin#ethod.and end#ethod.statements automatically proided to you by the system.

    3nter the statement translate para#eter toupper case.for the strin* conersion e"ample.

    =. Sae your entries and return to the Change Implementation screen.. 'hooseActi%ate.ou may now use this implementation when the application pro*ram is e"ecuted.

    8umerous implementations may e"ist for a Business Add-In that cannot be used on a multiple basis.:oweer! only one implementation can be actie for these ,inds of Business Add-Ins at any one time.

    6hat is also important is that you must declare the instance *eneration of the implementin* class#Attributestab( as public and notas priate or een abstract. If you do this! the system will return shortdumps at runtime.

    Fi'ter-Dependent Business Add-Ins

    Business Add-Ins may be implemented dependin* on a specific filter alue. If the standard allows for an enhancement for!for e"ample! country-specific ersions! it is li,ely that arious partners will want to implement this enhancement %istinctimplementations can then be created and actiated accordin* to country.

    3nter a filter type when definin* your enhancement #a country or industry sector! for e"ample(. All methods created in theenhancement7s interface hae filter alue 745TDEA57 as their import parameter. The application pro*ram proides the filteralue to the enhancement method. The method then selects the actie implementation for that alue.

    A description follows of how a filter-dependent Business Add-In wor,s in the conte"t of the strin* conersion e"ample. Inthe followin* e"ample! different implementations will be called usin* different filter alues.

    Definin$ a Fi'ter-Dependent Business Add-In

    To define a filter-dependent Business Add-In! first create a normal Business Add-In and select the !ilterchec,bo".

  • 8/13/2019 BADI's Customer Enhancements

    10/16

    3nter the data element you want as a filter type or select a filter type usin* the possible entries help.

    4ilter types are data elements and must fulfill the followin* criteria)

    The data element7s domain may contain a ma"imum of 9? characters and must be of type Character.

    The data element must

  • 8/13/2019 BADI's Customer Enhancements

    11/16

    Report businessaddin.class cl_exithandler definition load.data flt type usa_land.data exit type ref to if_ex_businessaddin.data word(15) type c value 'Business dd!in'.

    start!of!selection.

    perfor# for#atlist. call #ethod cl_exithandler$%et_instance chanin instance $ exit. write&'lease clic here'.

    at line!selection. new!pae. write& '*riinal word& '+word.

    call #ethod exit!%#ethod exportin flt_val $ flt. ,hanin para#eter $ word

    write& ',haned word& '+word.

    The subroutine ormatlistloo,s li,e this)

    for# for#atlist.write&'/0 !% ,onversion to upper case'.flt $ '/0'.hide flt.

    write &'reland !% ,onversion to lower case'.flt $ 'reland'hide flt.

    write &'taly !% ,onversion to...'flt $ 'taly'.hide flt.endfor#.

    Imp'ementin$ a Fi'ter-Dependent Business Add-In

    If you want to use a filter-dependent Business Add-In! you will need an implementation for each releant filter alue.$ultiple filter alues may use the same implementation! howeer.

    6hen implementin* a filter-dependent Business Add-In! proceed as follows)

  • 8/13/2019 BADI's Customer Enhancements

    12/16

    Italy)translate ...

    1. epeat steps

  • 8/13/2019 BADI's Customer Enhancements

    13/16

    !u'tip'e .se Business Add-Ins

    ou can differentiate between sin*le and multiple use Business Add-Ins. Sin*le use add-ins are based on procedures!whereas multiple use add-ins hae characteristics similar to those of eents. In the first case! the pro*ram waits for theenhancement to return somethin*! usually a return code. Benefit calculation in : is a *ood e"ample of this type ofenhancement. :ere! different calculations can be performed accordin* to whicheer implementation is actie. 6ithmultiple use add-ins! an eent is processed in pro*ram flow that may be of interest for other components. Thesecomponents can then use this eent as a hoo, to han* their own additional actions on.

    Since the call sequence cannot be predicted! it does not ma,e sense to allow return alues for thissecond type.

    In addition to importin* parameters! you can also use chan*in* parameters for multiple use BusinessAdd-Ins.

    E&amp'e)

    ou want your application to continue processin* inde"es with a different component after you hae saed #in otherwords! the system should allow you to use an add-in after sain*(. Since this is a *ood callup point for numerous different

    functions! you want to create an enhancement at this juncture that can be used by multiple subscribers.

    To create a multiple use Business Add-In! proceed as follows)

  • 8/13/2019 BADI's Customer Enhancements

    14/16

  • 8/13/2019 BADI's Customer Enhancements

    15/16

    Ca''in$ a !enu Enhancement from an App'ication ,ro$ram ou pro*rammin* should loo, li,e this)

    #L(case fcode. when '0'. (-) when '3,/0'

    call #ethod -

    Imp'ementin$ a !enu Enhancement 6hen implementin* menu enhancements! proceed as follows)

  • 8/13/2019 BADI's Customer Enhancements

    16/16

    'ase > Identical interfaces were assi*ned durin* Business Add-In definition.

    'ase 9 Identical function codes were assi*ned durin* Business Add-In definition.

    6heneer such collisions occur! correspondin* error messa*es and warnin*s are created in the transport lo* at import.

    Their lon* te"ts proide you with information on how to proceed.

    If the collision described in case < occurs in your system! proceed as follows)

    1. 'hoose UtilitiesAd)ustmentMultiple acti%e implementations#in transaction S3