Anda di halaman 1dari 13

ABAP Workbench Delta Guide (3.1-4.

6)

%XVLQHVV $GG,QV
As of release 4.6 a new enhancement technique has been established in R/3: Business Add Ins (BAdIs). The goal of this enhancement technique is to avoid the insufficient parts of the older techniques, customer exits and SD user exits. This unit is divided into three sections. In the first section we want to motivate the necessity of a new technique. The second section will deal with creating Business Add Ins. Then, in the subsequent section we will learn how to implement Business Add Ins. Finally, a short summary will conclude this unit.

,QWURGXFWLRQ
This section summarizes the insufficient aspects of the older enhancement techniques to explain the need for Business Add Ins. One thing that has changed is the software delivery chain. 6RIWZDUH 'HOLYHU\ &KDLQV <HVWHUGD\ $QG 7RGD\

l \HVWHUGD\ 6$3 &XVWRPHU &XVWRPHU ([LWV

l WRGD\ 6$3 6$3 LQGXVWU\ VROXWLRQ 3DUWQHU &XVWRPHU

%XVLQHVV
DGGLQ

1HZ $%$3 /DQJXDJH /DQJXDJH $%$3 2EMHFWV

SAP AG 1999

Originally, the software delivery chain consisted of two components, the customer and SAP itself. Today, the situation has completely changed. In most cases SAP does not deliver the software directly to the customer; instead, there are several participants in the delivery chain. A typical situation is depicted in the graphic: SAP delivers the Standard R/3 system to a SAP Industry Solution, which is developing industry-specific components. Together, Standard R/3 and the industry-specific components are delivered to a company that produces a complementary software product (CSP). Finally, the customer gets the complete software bundle.

SAP AG

29

ABAP Workbench Delta Guide (3.1-4.6)

'LVDGYDQWDJHV RI WKH 2OG (QKDQFHPHQW 7HFKQLTXHV


There were several disadvantages to the old enhancement techniques: Customer exits can be used only by one link in the chain User exits provide only enhancements of source code; technically, they are modifications Also, business transaction events only enable you to enhance source code. There is no administrative layer in either user exits or business transaction events.

Business add-ins have been developed to address these shortcomings.

$GYDQWDJHV RI %XVLQHVV $GG ,QV


The main advantage of this concept is the capacity for reuse. Once implemented, a business add-in can be reimplemented using other links in the software chain. Further advantages are: Administrative layer to manage business add-ins Implementation using techniques of ABAP Objects All enhancement types available (this will be implemented in a future release).

%XVLQHVV $GG,QV $UFKLWHFWXUH

6$3

,6

3DUWQHU

&XVWRPHU

&XVWRPHU HQKDQFH

,QGXVWU\ ,QWHUIDFH VROXWLRQ ,6

$GG,Q DGDSWHU

&25( 5

$GG,Q DGDSWHU

PHQW

&XVWRPHU HQKDQFH PHQW

DQRWKHU ,QWHUIDFH

SAP AG 1999

SAP AG

30

ABAP Workbench Delta Guide (3.1-4.6)

Business add-ins, unlike customer exits, take into account the changes to the software delivery process. The top part of the graphic illustrates the typical delivery process: It no longer merely consists of provider and user. Instead, it can now contain a whole chain of intermediate providers. Below this is a diagram explaining how business add-ins work. Enhancements are made possible using SAP application programs. This requires at least one interface and an adapter class that implements it. The interface is implemented by the user. The main advantage of this concept is the capacity for reuse. Once implemented, a business add-in can be reimplemented by other links in the software chain (further to the right in the graphic). Furthermore, an implementation can also offer its own business add-ins.

&UHDWLQJ D %XVLQHVV $GG,Q


Business add-ins use the interface concept of ABAP Objects. There is a new transaction SE18 to create business add-ins. You can find it in the ABAP Workbench following the path 8WLOLWLHV %XVLQHVV $GG,QV 'HILQLWLRQ. Alternatively, you can start with the Object Navigator. Here, choose :RUNEHQFK 2WKHU 2EMHFW . In the popup window, select the %XVLQHVV (QJLQHHULQJ tab. Here you find menu items for defining and implementing business add-ins. 'HILQLQJ %XVLQHVV $GG,QV ,QLWLDO 6FUHHQ

7vr6qqD)9rsvvvHhvrhprDvvhyTprr

'HILQLWLRQ QDPHBB 'LVSOD\ &KDQJH &UHDWH

%XVLQHVV DGGLQ GHILQLWLRQ QDPH &UHDWH

SAP AG 1999

In the initial screen of Transaction SE18, enter the name of the business add-in definition and choose &UHDWH. On the next screen, enter a short description for the business add-in definition.

SAP AG

31

ABAP Workbench Delta Guide (3.1-4.6) This next screen consists of a tabstrip. The first tab is the $WWULEXWHV tab. Here you can define whether the Business Add-In can be single use or multiple use. Moreover, you can define a filter dependence for the business add-in. You can also define a function code for your business add-in. Using this, you can let the user display an additional menu entry in the corresponding application. However, the most important component of a business add-in is the ,QWHUIDFH. Using this, you can define the methods that will contain the additional source code when a business add-in is implemented. %XVLQHVV $GG,Q 'HILQLWLRQ ,QWHUIDFH 0HWKRGV

A Af@Yf1i Gf@Yf1i 3 3

,QWHUIDFH QDPH 1DPH RI JHQHUDWHG %$G, FODVV

8yh7vyqr)8uhtrDrshprDAf@Yf1ihqv3

3DUDPHWHUV
Hruq 1ruq3 Ur

([FHSWLRQV
9rpvv 76qDruq

6WDWLF ,QVWDQFH

SAP AG 1999

Choose the ,QWHUIDFH Tab to define these methods. Doubleclick the name of the interface. The system displays the Class Builder where you can define the methods that should be provided in that business add-in. To find out how to create the methods, see the Class Builder documentation. Class Builder When you activate the interface, the system generates a class ("Adapter Class") which processes the implementations of the business add-in. Advantage of the adapter class: Multiple use of business add-ins Adapter class analyses which implementation is passed.

Overall, a business add-in consists of the components depicted in the following graphic:

SAP AG

32

ABAP Workbench Delta Guide (3.1-4.6) %XVLQHVV $GG,QV &RPSRQHQWV

%XVLQHVV DGGLQ
96U6)h  H@UCP9T H@UCP9T)  @YQPSUDIB rfh rfh! DHQPSUDIB vfh  H@UCP9T! @I9DIU@SA68@
)XQFWLRQ FRGH QDPHVSDFH[[[
SAP AG 1999

8G6TT8Gf@Yf1ihqv39@ADIDUDPI QV7GD8T@8UDPI QV7GD8T@8UDPI   DIU@SA68@T)DAf@Yf1ihqv3   @I98G6TT 8G6TTpyfrf1ihqv3DHQG@H@IU6UDPI H@UCP9vsfrfihqv  @I9H@UCP9 H@UCP9vsfrf1ihqv3! @I9H@UCP9 @I98G6TT

The following constraints apply to the definition of business add-ins: A business add-in cannot have a function code as one of its components if you define a filter dependency. A business add-in cannot be filter-dependent if you define a function code as one of its components. A business add-in can have only one active implementation, if you define it filter specific or if you define a function code as one of its components.

%XVLQHVV $GG,QV 1DPLQJ &RQYHQWLRQV

SAP AG

$GG,Q DGDSWHU

DIU@SA68@ DAf@Yf1ihqv3

33

ABAP Workbench Delta Guide (3.1-4.6) %XVLQHVV $GG,Q 'HILQLWLRQ 1DPLQJ &RQYHQWLRQV

l %XVLQHVV $GG,Q 'HILQLWLRQ DQ\ QDPH DOORZHG

n EDGL! n EDGL! n =EDGL! n ,)B(;BEDGL! n ,)B(;BEDGL! n =,)B(;BEDGL!

6$3 QDPH UDQJH 3DUWQHU QDPH VSDFH &XVWRPHU QDPH UDQJH 6$3 QDPH UDQJH 3DUWQHU QDPH VSDFH &XVWRPHU QDPH UDQJH

l ,QWHUIDFH DQ\ QDPH DOORZHG

l 0HWKRGV DQ\ QDPHV DOORZHG l *HQHUDWHG %XVLQHVV $GGLQ &ODVV $GDSWHU &ODVV  QRW WR EH FKDQJHG

n &/B,0BEDGL! n &/B(;BEDGL! n =&/B(;BEDGL!

6$3 QDPH UDQJH 3DUWQHU QDPH VSDFH &XVWRPHU QDPH UDQJH

SAP AG 1999

The naming conventions depicted in the slide apply to business add-ins: Thus, for business add-in definitions, you only have to take into account the corresponding name space or customer name range. The name of the interface is derived from the name of the business add-in using the following rule: The name space prefix first IF_EX_ by default name of the business add-in without name space prefix

The name of the interface can be changed arbitrarily. You only have to take into account the name-space rules. The methods are not Repository Objects. So their name is arbitrary, too. The name of the generated class is fixed, and is composed as follows: The name space prefix CL_(;_ The name of the business add-in without name space prefix.

SAP AG

34

ABAP Workbench Delta Guide (3.1-4.6) %$G, ,PSOHPHQWDWLRQ 1DPLQJ &RQYHQWLRQV

l %XVLQHVV DGGLQ LPSOHPHQWDWLRQ DQ\ QDPH DOORZHG

n LPSO! n LPSO! n =LPSO!

6$3 QDPH UDQJH 3DUWQHU QDPH VSDFH &XVWRPHU QDPH UDQJH

l ,QWHUIDFH QDPH GHILQHG LQ %XVLQHVV DGGLQ GHILQLWLRQ l 0HWKRGV QDPH GHILQHG LQ %XVLQHVV DGGLQ GHILQLWLRQ l ,PSOHPHQWLQJ FODVV DQ\ QDPH DOORZHG

n &/B,0BLPSO! n &/B,0BLPSO! n =&/B,0BLPSO!

6$3 QDPH UDQJH 3DUWQHU QDPH VSDFH &XVWRPHU QDPH UDQJH

SAP AG 1999

The name of the business add-in implementation can be chosen freely within the corresponding name-space or name range, respectively. The same holds for the name of the class that is created when you implement a business add in. the system makes the following proposal for the class: The name space prefix CL_,0_ The name of the implementation without name space prefix.

&UHDWLQJ D )LOWHU'HSHQGHQW %XVLQHVV $GG,Q


You can create a filter dependent BAdI by marking the corresponding flag in the $WWULEXWH Tab.

SAP AG

35

ABAP Workbench Delta Guide (3.1-4.6) &UHDWLQJ D )LOWHU 'HSHQGHQW %$G,

Qth

Apvpqr

9rpvv

S A

)LOWHU W\SH

19

SAP AG 1999

The filter type has to be a data element defined in the ABAP Dictionary. Because a data element refers to a domain which itself refers to a value table or fixed single values, the values for the filter are predefined. The methods defined in the BAdI-Interface have an additional fixed parameter: FLT_VAL, which has the type of the data element. We will see in the implementation part how this filter value is used to select a specific implementation.

6DPSOH &DOOLQJ D %XVLQHVV $GG,Q


This section describes an ABAP Program that provides an enhancement as a business add-in by discussing the program flow, before providing the code itself.

SAP AG

36

ABAP Workbench Delta Guide (3.1-4.6) 3URJUDP IRU 3URYLGLQJ $ %XVLQHVV $GG,Q )ORZ

6yvphvth Trvpr8yh 8Gf@YDUC6I9G@S

Qprvtshpvr Dyrrhv

6qhr8yh 8Gf@Yf1ihqv3

7vr6qqD) Dyrrhv8yh Dyrrhv8yh

8rhr Piwrprsrrpr

SAP AG 1999

The graphics shows the flow of an application program that provides a business add-in enhancement. First, declare a reference variable that is a reference to the business add-in interface. The following example shall provide you with the necessary code for calling a business add-in method. Assume that we have created a business add-in with the name <%$',7(67 already. We let the name of the interface be <,)B(;B%$',7(67. Furthermore, we have declared a method %$',B0(7+2' within the interface. PROGRAM badi_provider. '$7$ UHIHUHQFBYDULDEOH 7<3( 5() 72 ,)B(;B%$',7(67 Now, we have declared the reference variable. In a second step, we have to instantiate an object of the Adapter class. This is done by calling the method *(7B,167$1&( of the existing class &/B(;,7+$1'/(5. We advise calling this method as seldom as possible. So it is a good choice to call it at the ABAP event LOAD-OF-PROGRAM. The code should look as follows: LOAD-OF-PROGRAM. &$// 0(7+2' FOBH[LWKDQGOHU !JHWBLQVWDQFH &+$1*,1* LQVWDQFH UHIHUHQFHBYDULDEOH That is all the preparation we need. In the next step we can call the methods of the enhancement. The provider determines where the enhancement is called: &$// 0(7+2' UHIHUHQFHBYDULDEOH!EDGLBPHWKRG LQWHUIDFH RI WKH EDGL PHWKRG! With this statement the method is called in the generated adapter class, as depicted in the graphic above. The enhancements are called from within that method of the adapter class. Thus, the adapter class looks for active implementations and executes them.

SAP AG

37

ABAP Workbench Delta Guide (3.1-4.6)

,PSOHPHQWLQJ D %XVLQHVV $GG,Q


Transaction SE19 is used to implement business add-ins. ,PSOHPHQWLQJ %XVLQHVV $GG,QV ,QLWLDO 6FUHHQ

7vr6qqD)DyrrhvHhvDvvhyTprr

,PSHPHQWDWLRQ QDPH 'LVSOD\

1vy3

1DPH RI LPSOHPHQWDWLRQ
&UHDWH

&KDQJH

&UHDWH

7vr6qqD)8ur9rs

'HILQLWLRQ QDPH

1ihqv3

SAP AG 1999

Enter a name for the implementation. It has to comply with name space conventions. For example, to create an implementation in the customer name range, named =,03/(0(17 you would enter this name in the corresponding entry field and press the &UHDWH button. The system asks you for the business add-in you want to implement. Enter the name of the business add-in in the dialog box. The next screen displays some tabs. Here you can specify more details for the implementation of the interface method.

SAP AG

38

ABAP Workbench Delta Guide (3.1-4.6) ,PSOHPHQWLQJ %XVLQHVV $GG,QV 0HWKRGV

6

Drshpr

A8qr DAf1vrshpr3 8GfDHf1vy3

,QWHUIDFH QDPH 1DPH RI LPSOHPHQWLQJ FODVV


Hruq 1ruq3

9rpvv 7vrhqqvruq

8yh7vyqr)@qvHruqDA1vrshpr313

H@UCP9vsf1vrshpr31ruq3



@I9H@UCP9

SAP AG 1999

When you double click the name of the interface method, the system navigates to the editor where you can enter your source code. Technically, the system creates a new class, the LPSOHPHQWLQJ FODVV =&/B,0B,03/(0(17, which implements the interface that has been defined in the business add-in definition. If you wish, you can change the name of the class. Within this method you are free to do anything you can do within a class. For instance, you could call other private methods within the class. To be performed, the implementation has to be activated! You can deactivate an active implementation. It will then be no longer carried out.

,PSOHPHQWLQJ D )LOWHU'HSHQGHQW %XVLQHVV $GG ,Q


To implement a filter-dependent business add-in, you must specify the filter value for the business add-in. Therefore, you must insert specific values for the filter in the $WWULEXWHV field. In the following graphic, the implementation is only performed when the implementation is called with filter value "AA" or "LH".

SAP AG

39

ABAP Workbench Delta Guide (3.1-4.6) )LOWHU'HSHQGHQW ,PSOHPHQWDWLRQ

$WWULEXWHV

,QWHUIDFH

5HXVDEOH )LOWHUVSHFLILF

)LOWHU W\SH 6B&$55B,'


9DOXHV $$ /+

SAP AG 1999

SAP AG

40

ABAP Workbench Delta Guide (3.1-4.6)

0RGLILFDWLRQ $VVLVWDQW
After reviewing the following topics, you will be able to: Explain the concept of Modification Assistant Use the Modification Browser Understand the upgrade procedure Explain how to do adjustments with Modification Assistant Explain how to do adjustments without Modification Assistant
2000 SAP AG. All rights reserved.

SAP AG

41

Anda mungkin juga menyukai