Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Can any one have User Exits Documents with step by step examples?

Former Member
0 Kudos

Can any one have User Exits Documents with step by step examples?

[Removed by the moderator]

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Pon,

FUNCTION field_exit_bstnr.*"----


""Local interface:" IMPORTING" REFERENCE(INPUT)" EXPORTING" REFERENCE(OUTPUT)*"----

-


  • create field symbol FIELD-SYMBOLS: <status>.* Assign value of variable from calling prog to field symbol ASSIGN ('(SAPMM06E)RM06E-BSART') TO <status>.* Display value retrieved in message* Note: Messages of type i and w are not allowed IF sy-subrc = 0. MESSAGE e003(zr) WITH <status> 'kkk'. ENDIF.ENDFUNCTION.

Implementing Business Add-Ins (BADI)


The use of object orientated code within SAP has lead to new method of enhancing standard SAP code called Business Add-Ins or BADI's for short. Although the implementation concept is based on classes, methods and inheritance you do not really have to understand this fully to implement a BADI. Simply think of methods as a function module with the same import and export parameters and follow the simple instructions below.
Steps:1. Execute Business Add-In(BADI) transaction SE182. Enter BADI name i.e. HRPBSGB_HESA_NISR and press the display button 3. Select menu option Implementation->Create4. Give implementation a name such as Z_HRPBSGB_HESA_NISR5. You can now make any changes you require to the BADI within this implementation, for example choose the Interface tab6. Double click on the method you want to change, you can now enter any code you require.7. Please note to find out what import and export parameters a method has got return the original BADI definition (i.e. HRPBSGB_HESA_NISR) and double click on the method name for example within HRPBSGB_HESA_NISR contract is a method8. When changes have been made activate the implementation

reward pts if found usefull:)

Regards

Sathish

2 REPLIES 2

Former Member
0 Kudos

Hi,

USEREXIT

User exits allow us to add our own functionality to SAP standard program without modifying it . These are implemented in the form of subroutines and hence are also known as FORM EXITs. The user exits are generally collected in includes and attached to the standard program by the SAP.

All User exits start with the word USEREXIT_...

FORM USEREXIT_...

<User defined code>

ENDFORM.

e.g. USEREXIT_SAVE_DOCUMENT_PREPARE

Example :

1) ADDING OF NEW FIELDS IN PRICING

In Pricing in SD the fields on the basis of which pricing is done are derived from the FIELD CATALOG which is a structure KOMG .This structure is used to transfer transaction data to the pricing procedure in SD and is also known as communication structure. This structure KOMG consists of two tables KOMK for Header related fields and KOMP for item related fields.

The fields which are not in either of the two tables KOMK and KOMP

cannot be used in pricing .Sometimes a need arises when the pricing

is to be based on some other criteria which is not present in the form of fields in either of the two tables.

This problem can be solved by using USEREXITS which are provided for pricing in SD.

Pricing takes place both when the SALES ORDER (Transaction VA01) is created as well as when INVOICING (Transaction VF01) is done. Hence SAP provides 2 user exits ,one for sales order processing which is

USEREXIT_PRICING_PREPARE_TKOMP or

USEREXIT_PRICING_PREPARE_TKOMK

Depending upon which table (KOMK or KOMP) the new fields were inserted we use either of the above two user exits. These user exits are found in include MV45AFZZ of the standard SAP sales order creation program SAPMV45A.

In the case of user exit which will be called when invoicing is done, these are provided in the include RY60AFZZ which is in the standard SAP program SAPMV45A. The names of the user exits are same. i.e.

USEREXIT_PRICING_PREPARE_TKOMP or

USEREXIT_PRICING_PREPARE_TKOMK

These user exits are used for passing the data from the communication structure to the pricing procedure, for this we have to fill the newly created field in the communication structure KOMG for this we fill the code in the above user exit using the MOVE statement after the data that

has to be passed is taken from the database table by using the SELECT statement. The actual structure which is visible in these user exits and which is to be filled for that particular field is TKOMP or TKOMK.

Before the coding for these user exits is done, it is necessary to create a new field in either of the two tables KOMK or KOMP .For this purpose includes are provided in each of them .

To create the field in header data (KOMK) the include provided is KOMKAZ and to create the field in item data(KOMP) the include provided is KOMPAZ.

One possible example for the need of creating new fields can be e.g. Freight to be based upon transportation zone ,for this no field is available in field catalog and hence it can be created in KOMK and then above user exits can be used to fill the transportation data to it.

1) MENU EXITS

Menu exits allow you to add your own functionality to menus. Menu exits are implemented by SAP, and are reserved menu entries in the GUI interface. The developer can add his/her own text and logic for the menu. Function codes for menu exits all start with "+".

Example: We want to create a new menu item in the Office menu. The text for the menu should be "Run ZTEST", and the menu will run report ZTEST.

1) Go to transaction SE43 Area Menu Maintenance.

2) In Area Menu Parameter type 'S000' (S triple Zero).

3) Select Change and ignore all the warning screens.

4) Expand the office menu. In the bottom of the office tree you will find a menu named "Customer function".

5) Double click on the text. In the pop-up screen change the text to "Run ZTEST". Note that the transaction code is +C01. Go to transaction SE93 and create transaction +C01 that calls report ZTEST.

Now you will se the menu displayed in the office tree. If you delete transaction +C01 again, the new menu will disappear.

3) SCREEN EXIT

After you have found one, do as directed in the documentation. Generally, the steps are as follows:

1. Create a project using CMOD including your enhancement.

2. Create the append structure with new fields.

3. Go to the desired function group and create a sub screen with the new fields. Write PBO and PAI for the sub screen, if required.

4. Use the function exits in the enhancement to link the PBO and PAI of the sub screen with that of the main SAP program supporting the SAP transaction.

5. Maintain necessary linkage between the sub screen area of standard SAP program with the custom sub screen developed along with the custom program name. This can be done in the project (developed by CMOD including the enhancement) or outside as a part of configuration.

6. Activate the project.

7. Test to ensure that required functionality is met

Hi

Find the available exits with the following program:::

&----


*& Report ZFINDUSEREXIT

*&

&----


*&

*&

&----


report zfinduserexit.

tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.

tables : tstct.

data : jtab like tadir occurs 0 with header line.

data : field1(30).

data : v_devclass like tadir-devclass.

parameters : p_tcode like tstc-tcode obligatory.

select single * from tstc where tcode eq p_tcode.

if sy-subrc eq 0.

select single * from tadir where pgmid = 'R3TR'

and object = 'PROG'

and obj_name = tstc-pgmna.

move : tadir-devclass to v_devclass.

if sy-subrc ne 0.

select single * from trdir where name = tstc-pgmna.

if trdir-subc eq 'F'.

select single * from tfdir where pname = tstc-pgmna.

select single * from enlfdir where funcname =

tfdir-funcname.

select single * from tadir where pgmid = 'R3TR'

and object = 'FUGR'

and obj_name eq enlfdir-area.

move : tadir-devclass to v_devclass.

endif.

endif.

select * from tadir into table jtab

where pgmid = 'R3TR'

and object = 'SMOD'

and devclass = v_devclass.

select single * from tstct where sprsl eq sy-langu and

tcode eq p_tcode.

format color col_positive intensified off.

write:/(19) 'Transaction Code - ',

20(20) p_tcode,

45(50) tstct-ttext.

skip.

if not jtab[] is initial.

write:/(95) sy-uline.

format color col_heading intensified on.

write:/1 sy-vline,

2 'Exit Name',

21 sy-vline ,

22 'Description',

95 sy-vline.

write:/(95) sy-uline.

loop at jtab.

select single * from modsapt

where sprsl = sy-langu and

name = jtab-obj_name.

format color col_normal intensified off.

write:/1 sy-vline,

2 jtab-obj_name hotspot on,

21 sy-vline ,

22 modsapt-modtext,

95 sy-vline.

endloop.

write:/(95) sy-uline.

describe table jtab.

skip.

format color col_total intensified on.

write:/ 'No of Exits:' , sy-tfill.

else.

format color col_negative intensified on.

write:/(95) 'No User Exit exists'.

endif.

else.

format color col_negative intensified on.

write:/(95) 'Transaction Code Does Not Exist'.

endif.

at line-selection.

get cursor field field1.

check field1(4) eq 'JTAB'.

set parameter id 'MON' field sy-lisel+1(10).

write the code in the right form and check by keeping a break point

Try the following link.

http://help.sap.com/saphelp_47x200/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm.

<b>Reward points</b>

Regards

Former Member
0 Kudos

Hi Pon,

FUNCTION field_exit_bstnr.*"----


""Local interface:" IMPORTING" REFERENCE(INPUT)" EXPORTING" REFERENCE(OUTPUT)*"----

-


  • create field symbol FIELD-SYMBOLS: <status>.* Assign value of variable from calling prog to field symbol ASSIGN ('(SAPMM06E)RM06E-BSART') TO <status>.* Display value retrieved in message* Note: Messages of type i and w are not allowed IF sy-subrc = 0. MESSAGE e003(zr) WITH <status> 'kkk'. ENDIF.ENDFUNCTION.

Implementing Business Add-Ins (BADI)


The use of object orientated code within SAP has lead to new method of enhancing standard SAP code called Business Add-Ins or BADI's for short. Although the implementation concept is based on classes, methods and inheritance you do not really have to understand this fully to implement a BADI. Simply think of methods as a function module with the same import and export parameters and follow the simple instructions below.
Steps:1. Execute Business Add-In(BADI) transaction SE182. Enter BADI name i.e. HRPBSGB_HESA_NISR and press the display button 3. Select menu option Implementation->Create4. Give implementation a name such as Z_HRPBSGB_HESA_NISR5. You can now make any changes you require to the BADI within this implementation, for example choose the Interface tab6. Double click on the method you want to change, you can now enter any code you require.7. Please note to find out what import and export parameters a method has got return the original BADI definition (i.e. HRPBSGB_HESA_NISR) and double click on the method name for example within HRPBSGB_HESA_NISR contract is a method8. When changes have been made activate the implementation

reward pts if found usefull:)

Regards

Sathish