Sie sind auf Seite 1von 10

ECC 6.

0
Exercises: Enhancement

SAP Development ABAP Training

1. Exercise on User-Exit (Function-Exit)


Implement an User-Exit that will fire whenever you change any Customer details. Code an
Information message inside the User Exit code, so that when you run XD02 after Activating the
Project (thus the User Exit) this message is displayed in a popup.

Solution:
Steps :1. Run transaction XD02. The Change Customer initial screen will appear.

2. Select a customer number from the search help provided, and press the green Continue
button.
3. From the screen that appears, click on the Menu Item System Status.

Dec-2008
Page 1

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

4. Double-click on the Program (GUI) name SAPMF02D.

Dec-2008
Page 2

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

5. Click the Find button


.
6. In the Search window, look for the string customer-function in the Main Program.

7. Double-click on the hit list.

Dec-2008
Page 3

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

8. Now double-click on CALL CUSTOMER-FUNCTION '001'.


9. Youll be taken inside the Function Module (Function-Exit) EXIT_SAPMF02D_001.

10. This is the User-Exit for Change Customer. Notice that there is an Include program in the
User-Exit. Double-click on this Include program name.
11. There will be a pop-up asking you to create the Include ZXF04U01. Click Yes and create the
Include if it is not already created.
12. You can write your custom code within this Include program as shown below :-

Dec-2008
Page 4

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

13. It is a good practice to write your User-Exit code within IF SY-UNAME = ENDIF.
This is to prevent inadvertent firing of the Exit by other users while you are still testing. After
testing is complete, do not forget to remove the IF ENDIF before submitting the code
to the client !
Use your SAP user ID provided for the training. The User name should be written in Capital
letters. E.g. IF SY-UNAME = SANGRAMC.
14. Activate the Include program.
15. Now go to table MODSAP to find the Enhancement for the Function-Exit
EXIT_SAPMF02D_001. It is SAPMF02D in this case.

16. Now go to transaction CMOD and create a Project YXXPROJ. (Replace XX with the last 2
digits of your SAP User ID)
17. Include the Enhancement SAPMF02D in the Enhancement Assignment screen. Save and
Activate the project. The components of Enhancement SAPMF02D will now be active.

Dec-2008
Page 5

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

18. Execute transaction XD02 again and the information message will be displayed when you
change a Customer and press save.

Dec-2008
Page 6

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

Dec-2008
Page 7

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

2. Exercise on Business AddIn (BAdi)


Add New custom tab in Delivery transaction Code at item level. New Custom tab having one
custom field name as Lot Number as text field.
New field is to be added in LIPS table.
Enter value in new field should save in LIPS table.
If delivery is open again field , value gets populated from LIPS table on screen.

Solution:
Steps :1. Go to SE11 and open LIPS in Display mode.
2. Append structure ZALIPS to add new custom field Lot Number ZZLOTNO

3. Create New screen using SE51 and add ZZLOTNO in screen. Give reference to field from
LIPS-ZZLOTNO.
4. New Screen, Program Name: SAPLZ_DEL_TAB and screen 9001.

5.
6.
7.
8.

Now Add this custom screen to Delivery Item level.


To add custom screen in delivery item level, activate BADI LE_SHP_TAB_CUST_ITEM.
Go to SE19.
Create an Implementation (ZIM_ACTIVATE_DEL_TAB_XX, where XX is the last 2
digits of your User ID) of the BAdi.
9. Inside the method ACTIVATE_TAB_PAGE write the following code to activate new tab
in delivery item screen.
************************************************************************
* 1/ Method Name: ACTIVATE_TAB_PAGE
************************************************************************
*
************************************************************************

Dec-2008
Page 8

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

constants: c_caption type char40 value 'Lot Number',


" Tab name
c_program type syrepid value 'SAPLZ_DEL_TAB', " Program name
c_screen type sydynnr value '9001'.
" screen number
* Assign custom tab to delivery at item level

ef_caption = c_caption.
ef_program = c_program.
ef_dynpro = c_screen.
ENDMETHOD.
10. Inside the method TRANSFER_DATA_TO_SUBSCREEN write the following code to
transfer data from LIPS table to screen. Here gv_lotno is name of field define in custom
screen 9001.
************************************************************************
* 1/ Method Name: TRANSFER_DATA_TO_SUBSCREEN
************************************************************************
*
************************************************************************

gv_lotno = it_xlips zzlotno.


ENDMETHOD.
11. Inside the method TRANSFER_DATA_FROM_SUBSCREEN write the following code
to transfer data from screen to LIPS table. Here gv_lotno is name of field define in custom
screen 9001.
************************************************************************
* 1/ Method Name: TRANSFER_DATA_FROM_SUBSCREEN
************************************************************************
*
************************************************************************

It_xlips zzlotno = gv_lotno


ENDMETHOD.
12. Activate the BAdi Implementation.
13. Now when u open Delivery in Create/Change/Display mode, go to item level. New tab is
appeared at item level

Dec-2008
Page 9

ECC 6.0
Exercises: Enhancement

SAP Development ABAP Training

14. Enter any value in new field and save Delivery. Same value should save in LIPS table against
that delivery. Open Delivery again in change mode, same entered lot number should populate
new custom field.

Dec-2008
Page 10

Das könnte Ihnen auch gefallen