User-Exit- KNA1
Dear All.
When creating a client i need to change automatically the field AUFSD off the table KNA1. I try to method:
- Via User_exit SAPMF02D,but this change is not possible using this Exit.
- Via BTE SAMPLE_INTERFACE_00001321.
Does any one have any ideia who to change this situation? Change this field KNA1-AUFSD using the transaction XD01.
Best Regards,
Thanks in advanced
Pedro Miguel Rodrigues
Hello Pedro,
sorry for the late answer.
It would be something like this:
FUNCTION Z_TEST_00001340 .
constants: fieldname(30) value '(SAPMF02D)KNA1-AUFSD'.
field-symbols: <L_FIELD>.
IF <your condition>.
Assign (fieldname) to <l_field>.
<L_FIELD> = '01'. " value according to your requirement
ENDIF.
ENDFUNCTION.
But be carefull; with this kind of programming you can change almost any value..
Regards Wolfgang
Similar Messages
-
User exit for XD01/XD02 to update KNA1 field
Hi
I have added a custom field using append structure in KNA1
I need to update it during the XD01 or XD02 transaction before it is saved
I am searching for BADIs and user exits but I am not able to update anything in KNA1
kindly help if u were having similar requirement
thanks
bHi Max,
I have tried all of the following
BADI for XD01
CUSTOMER_ADD_DATA
BADI_LAYER
CUSTOMER_ADDRSCR_CHG
GOS_SRV_SELECT
ADDRESS_SUBSCREEN
save button:
ADDRESS_CHECK
ADDR_TXJCD_CHECK
ADDRESS_UPDATE
exits
EXIT_SAPMF02D_001.
BTEs
00001320
00001321
00001330
00001340
00001350
00001360
but nowhere I have found an interface for updating KNA1 fields.
I am not able to use CUSTOMER_ADD_DATA_CS and CUSTOMER_ADD_DATA_BI . I checked it using CL_EXITHANDLER
is there any way i can store the information I need . I just need one field against the customer number
thanks
b -
A/R User Exit Spec and code
The spec -
1. Canadian tax - currently based on Freight type: Read the country(?) Ship-from (plant jurisdiction) to Ship-to(customer jurisdiction) and the inco term on the line item of the sales order and if it's not equal to 'DDP' the line item tax classification will be set to '0' exempt. (This is freight that comes into Canada from the US)
We will look at the shipto and shipfrom txjcd on the sales order document and billing document along with the inco term logic and we will tax freight when they are both Canada
Example Scenario:
For Freight charges where the Ship from is in Canada (Bedco, Artmedco, etc) and the Ship-to is in Canada the freight will always be taxable regardless of the inco term. This is freight that ships within Canada, no boarder crossing.
2. Regular Freight - US & Canada: If separate line item on sales order, it may be exempt from tax based upon state. revisit
a. D.1 Freight included on the line item
i. The freight is passed to the external system by populating the field FREIGHT. The freight amount is always included in the base amount.
ii. An example to fill the freight using the user-exit:
iii. In the customer pricing procedure (for example ZUSA01) enter 4 in the subtotal field of the freight condition type (OTC must have this configuration in the pricing procedure for the freight pricing conditions).
iv. In the customer structure CI_TAX_INPUT_USER, add the field KZWI4 as in KOMP-KZWI4.
v. In the user-exit, add the code CH_USER_CHANGED_FIELDS-FREIGHT_AM = I_INPUT_USER-KZWI4.
3. For PO Specific A/R Tax Exemptions using material tax class of 2, pass the TAXM1 field to the ACCOUNT_NO field in Taxware
oSolution:
For PO Specific Tax Exemptions CSR will go to the line item detail Billing Tab, Tax Classification field (TAXM1) and change that to 2 One-Time Exemption. Configuration complete.
CSR will go to the Text Tab, Internal Item Notice and CSR will provide a brief description as to why that line is tax exempt.
This the code----
TABLES: KNVV, KNA1, KOMK, MLAN, T001W, KNVI.
DATA: w_taxm1 LIKE mlan-taxm1,
i_kna1 LIKE kna1,
c_com_tax type com_tax,
i_komk LIKE KOMK.
*--- if this freight comes into canada from US then set TAXM1 to 0
*----otherwise set TAXM1 to 2 and apply frieght charges. Set ACCNT_CLS
*----to 'Y' each time TAXM1 is passed to ACCNT_NO.
IF KNA1-LAND1 EQ 'CA'.
IF C_COM_TAX-TXJCD_SF EQ C_COM_TAX-TXJCD_ST.
CH_USER_CHANGED_FIELDS-FREIGHT_AM = I_INPUT_USER-KZWI4.
w_taxm1 = 2.
CH_USER_CHANGED_FIELDS-ACCNT_NO = W_TAXM1.
CH_USER_CHANGED_FIELDS-ACCNT_CLS = 'Y'.
ELSEIF C_COM_TAX-TXJCD_SF NE C_COM_TAX-TXJCD_ST.
C_COM_TAX-TXJCD_SF = C_COM_TAX-TXJCD_ST.
C_COM_TAX-TXJCD_POA = C_COM_TAX-TXJCD_ST.
SELECT SINGLE * FROM KNVV
WHERE INCO1 = KOMK-INCO1
AND INCO1 NE 'DDP'.
IF SY-SUBRC EQ 0.
w_taxm1 = 0.
CH_USER_CHANGED_FIELDS-ACCNT_NO = W_TAXM1.
CH_USER_CHANGED_FIELDS-ACCNT_CLS = 'Y'.
ENDIF.
ENDIF.
ENDIF.
SELECT SINGLE taxkd FROM knvi INTO knvi-taxkd
WHERE kunnr = i_komk-kunwe
AND aland = i_komk-land1.
IF SY-TCODE = 'VA01' OR SY-TCODE = 'VA02' OR SY-TCODE = 'VA03' OR
SY-TCODE = 'VF01' OR SY-TCODE = 'VF02' OR SY-TCODE = 'VF03' OR SY-TCODE
= 'VF04' OR SY-TCODE = 'VF05' OR SY-TCODE = 'VF05'.
SELECT SINGLE * FROM kna1 INTO i_kna1
WHERE kunnr = i_komk-kunwe.
IF i_KNA1-land1 EQ 'CA'.
C_COM_TAX-TXJCD_SF = C_COM_TAX-TXJCD_ST.
C_COM_TAX-TXJCD_POA = C_COM_TAX-TXJCD_ST.
ENDIF.
ENDIF.
I am able to enter the user exit, but there is no value for KNA1-LAND1 or C_COM_TAX-TAXJCD_SF or C_COM_TAX-TAXJCD_ST. Does anyone what I am missing ? Please help.
Thanks in advance !!!!
NHi NP ,
which User exit ur using ? Are u talking abt MIRO or VF01.
Regards
Prabhu -
Error on reading user exit EXIT_SAPMF02D_001
Hello experts,
Iu2019m working with user exit EXIT_SAPMF02D_001 and need to check certain values which are getting populate in tables I_KNA1 and I_KNVV. I realise these are available within import parameter. When I put a break point then during customer creation/modification before saving all the changes I can come and check all the values within I_KNA1 and I_KNVV but when I tried to write a select using I_KNA1 I get the error saying.
u201CI_KNA1u201D is not defined in the ABAP Dictionary as a table, projection view or database view.
Here is my select which gives the above error
select kunnr ktokd into (v_kunnr, v_ktokd)
from I_KNA1
where kunnr = v_kunnr.
endselect.
If this is not the way Iu2019m doing in my select to fetch the values from I_KNA1 then how I can get all its values?
Thanks a lot in advance.Hi,
The importing structure I_KNA1 will contain all the fields available in KNA1. We can directly use I_KNA1-KUNNR and I_KNA1-KTOKD directly. We don't need to fire a select on KNA1 for reading KTOKD value. Just use I_KNA1-KTOKD where ever required.
Regards,
Ganga -
Hi,
I'm trying to access the address given for a new customer in user exit EXIT_SAPMF02D_001. I need Street4, which is not available on the i_kna1 object, and therefore I'm trying to play with the i_addrhandle parameter.
Can this be used with function module GET_ADDR to read addresses before the customer is saved, the following code gives me exception 1.
ls_addr1-addrhandle = i_addrhandle.
CALL FUNCTION 'ADDR_GET'
EXPORTING
address_selection = ls_addr1
IMPORTING
address_value = ls_addr1_val
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
version_not_exist = 3
internal_error = 4
OTHERS = 5
Regards
MattiasHello,
Address handle is used for internal communication in standard program..for the customer creation let's say it would store value like "KNA1 ADRNR" and for vendor "LFA1 ADRNR"
Please use address number in ADDR_GET function module
Thanks
Krish -
User exits used in sales and distribution?
i need some user exits that we commonly used in sd. please if somebody has worked on user exits . and how are they used..
points will be awarded to all for replying...
thanks in advance
Neha.Hi refer below
It is most common that one or other time we need to use this function while configuring multi tasking & complex Prcing Architecture.
Here Iam giving a simple guide to add fields to the Pricing Field Catalogues:
For example you want to use field PSTYV ('Sales document item category') that is included in structure KOMP ('Pricing Communication Item') as a key for a condition table.
When you create a condition table (Transaction V/03), however, the system does not propose the field in the field catalog.
Condition access, field catalog, allowed fields, KOMG, KOMK, KOMP, KOMPAZ, KOMKAZ, PSTYV are the other terms which we need to know about, to add Fields.
Reason and Prerequisites
For technical reasons, field PSTYV was included in structure KOMP, however, not in structure KOMG ('Allowed Fields for Condition Structures').
Proceed as follows:
1. Call up the ABAP Dictionary (Transaction SE11) and create data type ZZPSTYV. Choose PSTYV as a domain.As a short text, you can use, for example, 'ZZ - sales document item category' and as a field label, you can use the field labels of PSTYV.Save, check and activate your entries.
2. Call up structure KOMPAZ in the ABAP Dictionary (Transaction SE11) in the change mode and make the following entry:
Component Component type
ZZPSTYV ZZPSTYV
Save, check and activate the change you made.
3. Note:Because of the change in structure KOMPAZ, field ZZPSTYV is now known in structures KOMG and KOMP because structure KOMPAZ is included in both structures.
4. Call up Transaction SPRO. Navigate to 'Sales and Distribution -> Basic Functions -> Pricing -> Pricing Control' and execute 'Define Condition Tables'.
Choose 'Conditions: Allowed fields' and include ZZPSTYV as a new entry.
5. Note:Now you can use field ZZPSTYV as a key field when you create a condition table Axxx.
6. Supply the new field you defined by including the following source code line in USEREXIT_PRICING_PREPARE_TKOMP:
MOVE xxxx-PSTYV TO TKOMP-ZZPSTYV.
In order processing you find the user exit in Include MV45AFZZ, and in billing document processing you find it in Include RV60AFZZ.
Consider that you can also use this note as a help if you want to use other customer-specific fields as key fields in a condition table.
For header fields, use structure KOMKAZ instead of structure KOMPAZ and USEREXIT_PRICING_PREPARE_TKOMK instead of USEREXIT_PRICING_PREPARE_TKOMP.
For more information, see Transaction SPRO via the path 'Sales and Distribution -> System Modifications -> Create New Fields (Using Condition Technique) -> New Fields for Pricing' and OSS Note 21040.
USEREXIT
Userxits 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 userexits are generally collected in includes and attached to the standard program by the SAP.
All Userexits start with the word USEREXIT_...
FORM USEREXIT_..
z..
ENDFORM.
The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once the correct userexit is found the necessary
customer code is inserted in the customer include starting with the z..
in the form routine.
e.g. USEREXIT_SAVE_DOCUMENT_PREPARE
Certain application like SD still provide this form of enhancement using userexit but this practice is no longer being followed for newer extensions
instead they are using EXITs which come bundeled in enhancement packages . Neverthiless existing USEREXITS will be supported by SAP an all the newer versions of SAP.
HOW TO FIND USEREXITS
Userexits can be found in number of ways:
1) To find userexits in SD module , goto object navigator(SE80) and select
development class from the list and enter VMOD in it. All of the userexits in SD are contained in the development class VMOD. Press
enter and you will find all the includes which contain userexits in SD for
different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the requirement and read the comment inserted in it
and start coding .
Some examples of userexits in SD(SALES & DISTRIBUTION ) are:
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 userexits ,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 userexits.These userexits are found in include MV45AFZZ of the standard SAP sales order creation program SAPMV45A.
In the case of userexit which will be called when invoicing is done ,these
are provided in the include RY60AFZZ which is in the standard SAP
program SAPMV45A. The name of the userexits are same. i.e
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
These userexits are used for passing the data from the communication structure to the pricing procedure, for this we have to fill the newely
created field in the communication structure KOMG for this we fill the code in the above userexit 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 userexits and which is to be filled for that particular field is TKOMP or TKOMK.
Before the coding for these userexits 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. Frieght 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 userexits can be used to fill the transportation data to it.
2)The other method of finding userexit is to find the word USEREXIT in the
associated program of the transaction for which we want to determine userexit using SE38.
3)The other method of finding userexits is to find the include in case of SD/MM applications where the userexits are located ,this can be found in the SAP reference IMG generally in the subfolder under SYSTEM MODIFICATION.
Some other examples of userexits in SD are:
USEREXIT_NUMBER_RANGE
This userexit is used to assign a different internal document number to the
sales order(VA01) when it is created depending on some criteria like a different SALES ORGANIZAION(VKORG) .
USEREXIT_SAVE_DOCUMENT_PREPARE
This userexit is used to insert the ABAP code which will be called when
the document (sales order VA01) is just about to be saved.This userexit is used generally for custom checks on different fields , to display some information before the order will be saved or for making changes to certain fields before the sales order will be saved.
Exits & Enhancements
There are mainly six types of EXITs in sap which have been collected in the form of enhancement packages and attached to standard code in SAP.
These are different from USEREXIT in the way that they are implemented
in the form of FUNCTIONs while in USEREXITS we use form routines for their implementation. These are also sometimes known as function exits .
These start from the word EXIT_ followed by the program name and then followed by a three digit number.
e.g. EXIT_SAPMV45A_002
This exit is found in SD in enhancement V45A0002.
TYPES OF EXITS
1)MENU EXITS
2)FUNCTION EXITS
3)TABLE EXITS
4)SCREEN EXITS
5)KEYWORD EXITS
6)FIELD EXITS
We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit , it is required to create the project by using CMOD
selecting the enhancement e.g. V45A0002 and selecting the component
(one which fulfills our need) i.e the exit which will be implemented in SMOD and after coding has been done the project has to be activated.
An exit can be coded only once.
FUNCTION EXITS
These are used to add functionality through ABAP code . These start from the word EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any tupe of exit including function exits.
The function exits are called from the standard SAP program in the form
of ABAP statement
CALL CUSTOMER-FUNCTION 'NNN'
This is in contrast to USEREXITs where PERFORM statement is used to call
the required userexit.
To implement the FUNCTION EXITs first of all the project is created and a suitable enhancement package is selected and from its compnents the function exit to be implemented is selected and on double clicking it the exit code will appear in ABAP EDITOR(se38) where a Z include will be found and the customer code should be entered in this include.
e.g.
ADDING A DEFAULT SOLD-TO-PARTY in Sales Order Creation
To show a default sold-to-party in this field when the user creates a sales order (VA01) we can use a function exit .This function exit is located
in enhancement no V45A0002 . Before we can choose the exit we have to
create a project in CMOD after that enter V45A0002 in the enhancement field and click on the components . In the components you will see the
exit EXIT_SAPMV45A_002 . This exit is used for our purpose.
Double clicking on this exit will takes us to function builder (SE37) . This
function exit has one exporting parameters and two importing parameters, we are interested in exporting parameter which is E_KUNNR
of type KNA1-KUNNR i.e if we move the desired customer name to this
structure(E_KUNNR) it will be shown in the field as the default value when we create the sales order.
This function also contains a customer include ZXVVA04 . This include
will be used to write our custom code .
Double clicking on this include and it will prompt us that this include does not exists do you want to create this object ,select yes and the include will be created .In this include we can write our own code that will fill the field E_KUNNR.
e.g. E_KUNNR = 301.
Activate the include and Activate the project. Now when ever the SALES ORDER will be created , sold-to-party field will come up with a predefined
customer .
FIELD EXITS
The field exits are managed,created,activated through program RSMODPRF. The field exit is associated with a data element existing in ABAP dictionary and hence to the screen field using that data element.
The format of field exit is :
FIELD_EXIT_dataelement_A-Z or 0-9
If a particular screen and program name is not specified than the field exit will effect all the screens containing that data element.
The function module associated with field exit shows two parameters
INPUT and OUTPUT. Input parameter contains the data passed to the field exit when the field exit was invoked by the R/3 , We can write our own code to change the output parameter depending upon our requirements.
Before the field exit can have any effect the system profile parameter
ABAP/FIELDEXIT in all the application servers should be set to YES
ABAP/FIELDEXIT = YES. -
User Exit to change the Ship-to party address at Sales Order headder level
Hi,
I have requirement like this......
I need to change the ship-to party address at Sales Order headder level. for that which user exit i need to use and which structure i need to use to update the transaction.
I used : userexit_save_document_prepare, in that i passed data to 'xvbpa' and 'xvbadr' structures. even though it is not update the transaction.
Please let me know the answer.
Thanks,
Satish.Hi Satish,
Step1. Create new Data Copy Routine using Tcode VOFM.
Step2. *-----------------------------------Ship to Party from contract
IF CVBPA-PARVW = 'WE' OR
CVBPA-PARVW = 'SH'.
REFRESH IT_STP.
SELECT KTOKD
A~KUNNR
NAME1
NAME2
A~ADRNR
FROM VBPA AS A INNER JOIN KNA1 AS B ON A~KUNNR = B~KUNNR
INTO CORRESPONDING FIELDS OF TABLE IT_STP
WHERE VBELN = CVBPA-VBELN .
Step3.
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
ENDPOS_COL = 80
ENDPOS_ROW = 10
STARTPOS_COL = 10
STARTPOS_ROW = 5
TITLETEXT = 'Your Title'
IMPORTING
CHOISE = T_SELIDX<=====Index No of selection
TABLES
VALUETAB = IT_STP
EXCEPTIONS
BREAK_OFF = 1
OTHERS = 2.
Step4.
READ TABLE IT_STP INTO WA_STP INDEX T_SELIDX.
IF SY-SUBRC = 0.
CLEAR:CVBPA-KUNNR, CVBPA-ADRNR.
MOVE WA_STP-KUNNR TO CVBPA-KUNNR.
MOVE WA_STP-ADRNR TO CVBPA-ADRNR. <========Address ID (Change Here).
ENDIF.
Regards,
Amrendra
Moderator Message - Please do not reply to old, dormant threads.
Message was edited by: Suhas Saha -
User exits-- also ---synchronous and asynchronous struc..
dear all
pls. let me know the basics of user exits. i have gone thro williams iam unable to follow. does it require abap knowledge. i sincerely request one and all (experts) to let me know about user exits. it seems very imp as per interviews.
also what is synchronous and asynchronous structures whats the difference. can anybody share knowledge on this.
thanks in advance
regardsDear Sekhar,
Please find the info regarding User-Exit's in the following links:
http://help.sap.com/saphelp_nw04/helpdata/en/bf/ec07a25db911d295ae0000e82de14a/frameset.htm
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
Re: doubt on user exits
user exits and Badis
User exits is the enhancements provided by SAP
You can use them in transactions. Each transaction will have user exits.
If you want to use your own requirements by making your coding while the transaction is run you can use user exits.
For example if you want to run the MRP in MD02 specific to MRP controller you can user exit.
Please also refer the document below.
USEREXIT
Userxits 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 userexits are generally collected in includes and attached to the standard program by the SAP.
All Userexits start with the word USEREXIT_...
FORM USEREXIT_..
z..
ENDFORM.
The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once the correct userexit is found the necessary customer code is inserted in the customer include starting with the z.. in the form routine.
e.g. USEREXIT_SAVE_DOCUMENT_PREPARE
Certain application like SD still provide this form of enhancement using userexit but this practice is no longer being followed for newer extensions instead they are using EXITs which come bundeled in enhancement packages . Neverthiless existing USEREXITS will be supported by SAP an all the newer versions of SAP.
HOW TO FIND USEREXITS
Userexits can be found in number of ways:
1) To find userexits in SD module , goto object navigator(SE80) and select
development class from the list and enter VMOD in it. All of the userexits in SD are contained in the development class VMOD. Press enter and you will find all the includes which contain userexits in SD for different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the requirement and read the comment inserted in it and start coding .
Some examples of userexits in SD(SALES & DISTRIBUTION ) are:
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 userexits ,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 userexits.These userexits are found in include MV45AFZZ of the standard SAP sales order creation program SAPMV45A.
In the case of userexit which will be called when invoicing is done ,these
are provided in the include RY60AFZZ which is in the standard SAP program SAPMV45A. The name of the userexits are same. i.e
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
These userexits are used for passing the data from the communication structure to the pricing procedure, for this we have to fill the newely created field in the communication structure KOMG for this we fill the code in the above userexit 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 userexits and which is to be filled for that particular field is TKOMP or TKOMK.
Before the coding for these userexits 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. Frieght 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 userexits can be used to fill the transportation data to it.
2)The other method of finding userexit is to find the word USEREXIT in the
associated program of the transaction for which we want to determine userexit using SE38.
3)The other method of finding userexits is to find the include in case of SD/MM applications where the userexits are located ,this can be found in the SAP reference IMG generally in the subfolder under SYSTEM MODIFICATION.
Some other examples of userexits in SD are:
USEREXIT_NUMBER_RANGE
This userexit is used to assign a different internal document number to the
sales order(VA01) when it is created depending on some criteria like a different SALES ORGANIZAION(VKORG) .
USEREXIT_SAVE_DOCUMENT_PREPARE
This userexit is used to insert the ABAP code which will be called when
the document (sales order VA01) is just about to be saved.This userexit is used generally for custom checks on different fields , to display some information before the order will be saved or for making changes to certain fields before the sales order will be saved.
Exits & Enhancements
There are mainly six types of EXITs in sap which have been collected in the form of enhancement packages and attached to standard code in SAP.
These are different from USEREXIT in the way that they are implemented
in the form of FUNCTIONs while in USEREXITS we use form routines for their implementation. These are also sometimes known as function exits .
These start from the word EXIT_ followed by the program name and then followed by a three digit number.
e.g. EXIT_SAPMV45A_002
This exit is found in SD in enhancement V45A0002.
TYPES OF EXITS
1)MENU EXITS
2)FUNCTION EXITS
3)TABLE EXITS
4)SCREEN EXITS
5)KEYWORD EXITS
6)FIELD EXITS
We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit , it is required to create the project by using CMOD
selecting the enhancement e.g. V45A0002 and selecting the component
(one which fulfills our need) i.e the exit which will be implemented in SMOD and after coding has been done the project has to be activated.
An exit can be coded only once.
FUNCTION EXITS
These are used to add functionality through ABAP code . These start from the word EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any tupe of exit including function exits.
The function exits are called from the standard SAP program in the form
of ABAP statement
CALL CUSTOMER-FUNCTION 'NNN'
This is in contrast to USEREXITs where PERFORM statement is used to call
the required userexit.
To implement the FUNCTION EXITs first of all the project is created and a suitable enhancement package is selected and from its compnents the function exit to be implemented is selected and on double clicking it the exit code will appear in ABAP EDITOR(se38) where a Z include will be found and the customer code should be entered in this include.
e.g.
ADDING A DEFAULT SOLD-TO-PARTY in Sales Order Creation
To show a default sold-to-party in this field when the user creates a sales order (VA01) we can use a function exit .This function exit is located in enhancement no V45A0002 . Before we can choose the exit we have to create a project in CMOD after that enter V45A0002 in the enhancement field and click on the components . In the components you will see the exit EXIT_SAPMV45A_002 . This exit is used for our purpose.
Double clicking on this exit will takes us to function builder (SE37) . This
function exit has one exporting parameters and two importing parameters, we are interested in exporting parameter which is E_KUNNR of type KNA1-KUNNR i.e if we move the desired customer name to this structure(E_KUNNR) it will be shown in the field as the default value when we create the sales order. This function also contains a customer include ZXVVA04 . This include will be used to write our custom code .
Double clicking on this include and it will prompt us that this include does not exists do you want to create this object ,select yes and the include will be created .In this include we can write our own code that will fill the field E_KUNNR.
e.g. E_KUNNR = 301.
Activate the include and Activate the project. Now when ever the SALES ORDER will be created , sold-to-party field will come up with a predefined customer .
FIELD EXITS
The field exits are managed,created,activated through program RSMODPRF. The field exit is associated with a data element existing in ABAP dictionary and hence to the screen field using that data element.
The format of field exit is :
FIELD_EXIT_dataelement_A-Z or 0-9
If a particular screen and program name is not specified than the field exit will effect all the screens containing that data element.
The function module associated with field exit shows two parameters
INPUT and OUTPUT. Input parameter contains the data passed to the field exit when the field exit was invoked by the R/3 , We can write our own code to change the output parameter depending upon our requirements.
Before the field exit can have any effect the system profile parameter
ABAP/FIELDEXIT in all the application servers should be set to YES
ABAP/FIELDEXIT = YES.
Regards
Naveen. -
User exit for XD01 (Customer Creation)
Hi All Gurus,
I need to extract some data (kunnr, name1, name2, telephone, mobile etc from KNA1, KNVV, KNBK tables) when user is creating a new customer. I have used the user exit SAPMF02D - EXIT_SAPMF02D_001 for the requirement.
I am getting all the required data except KUNNR. It is always blank, and according to my guessing it is because yet the KUNNR is not created.
Is there any other alternative or user exit for this scenario?
Thank you all in advance,This was a very useful post Marcin!
For those who need detailed steps for BTE regarding customer master data:
Transaction FIBF
Environment -> Infosystem P/S
Find event code using google (debitors are 00001320)
Click "Sample Function Module" and copy it to your FM (e.g. Z_CUSTOMER_UPDATED)
Back in FIBF choose menu Settings -> Products -> ...of a customer and create one (check "Active"). Go back to FIBF
Settings -> P/S Modules -> of a customer and assign your event + product + FM
Now you can implement your FM
You can use this FM to track changes to customer master data and e.g. feed the information into interfacing systems. -
User exit for VD01 - Create Customer
I am finding user exit for VD01 - Create Customer.
I need a newly created Customer number - KNA1-KUNNR.
I found user exit EXIT_SAPMF02D_001, but if field Customer left blank on screen in VD01, the parameter I_KNA1-KUNNR is blank. Because program genereates KUNNR further.
Edited by: S S on Dec 23, 2008 7:56 AMDear SS,
What I understood is system is generating internal number range for customer in your case.
You want to know the number of customer number.
I think with this exit EXIT_SAPMF02D_001 you don't get customer number.
Try with this BADI CUSTOMER_ADD_DATA
Method MODIFY_ACCOUNT_NUMBER. use break point here.
Then create a customer in VD01 (internal number range). maintain necessary information and save.
system will take you to debugging mode. here you can see internal number of customer.
Regards,
Chandra -
Without "User Exit" how to solve the problem
Hi all,
We are using DEBMAS06 to send the data to a legacy system.The data sent will consist primarily of address and partner information extracted via IDOC based on configured change pointers. The change pointer settings in SAP R/3 will ensure that changed customer master records are included in the IDOCs sent out of R/3.
The problem is when there is a change in the KNA1 segment the Idoc doesn't come out with KNVP segment which has the partner roles. Is there any way to debug this problem without using User Exit.
Thanks in advance,
SrinivasHi,
Try out with tcode WE19.
regards,
sharath -
can any one provide the information about the User exits and how to work with user exits ?
please provide me step by step informatin.
Regards
vamsihi
USEREXIT
Userxits 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 userexits are generally collected in includes and attached to the standard program by the SAP.
All Userexits start with the word USEREXIT_...
FORM USEREXIT_..
z..
ENDFORM.
The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once the correct userexit is found the necessary
customer code is inserted in the customer include starting with the z..
in the form routine.
e.g. USEREXIT_SAVE_DOCUMENT_PREPARE
Certain application like SD still provide this form of enhancement using userexit but this practice is no longer being followed for newer extensions
instead they are using EXITs which come bundeled in enhancement packages . Neverthiless existing USEREXITS will be supported by SAP an all the newer versions of SAP.
HOW TO FIND USEREXITS
Userexits can be found in number of ways:
1) To find userexits in SD module , goto object navigator(SE80) and select
development class from the list and enter VMOD in it. All of the userexits in SD are contained in the development class VMOD. Press
enter and you will find all the includes which contain userexits in SD for
different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the requirement and read the comment inserted in it
and start coding .
Some examples of userexits in SD(SALES & DISTRIBUTION ) are:
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 userexits ,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 userexits.These userexits are found in include MV45AFZZ of the standard SAP sales order creation program SAPMV45A.
In the case of userexit which will be called when invoicing is done ,these
are provided in the include RY60AFZZ which is in the standard SAP
program SAPMV45A. The name of the userexits are same. i.e
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
These userexits are used for passing the data from the communication structure to the pricing procedure, for this we have to fill the newely
created field in the communication structure KOMG for this we fill the code in the above userexit 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 userexits and which is to be filled for that particular field is TKOMP or TKOMK.
Before the coding for these userexits 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. Frieght 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 userexits can be used to fill the transportation data to it.
2)The other method of finding userexit is to find the word USEREXIT in the
associated program of the transaction for which we want to determine userexit using SE38.
3)The other method of finding userexits is to find the include in case of SD/MM applications where the userexits are located ,this can be found in the SAP reference IMG generally in the subfolder under SYSTEM MODIFICATION.
Some other examples of userexits in SD are:
USEREXIT_NUMBER_RANGE
This userexit is used to assign a different internal document number to the
sales order(VA01) when it is created depending on some criteria like a different SALES ORGANIZAION(VKORG) .
USEREXIT_SAVE_DOCUMENT_PREPARE
This userexit is used to insert the ABAP code which will be called when
the document (sales order VA01) is just about to be saved.This userexit is used generally for custom checks on different fields , to display some information before the order will be saved or for making changes to certain fields before the sales order will be saved.
Exits & Enhancements
There are mainly six types of EXITs in sap which have been collected in the form of enhancement packages and attached to standard code in SAP.
These are different from USEREXIT in the way that they are implemented
in the form of FUNCTIONs while in USEREXITS we use form routines for their implementation. These are also sometimes known as function exits .
These start from the word EXIT_ followed by the program name and then followed by a three digit number.
e.g. EXIT_SAPMV45A_002
This exit is found in SD in enhancement V45A0002.
TYPES OF EXITS
1)MENU EXITS
2)FUNCTION EXITS
3)TABLE EXITS
4)SCREEN EXITS
5)KEYWORD EXITS
6)FIELD EXITS
We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit , it is required to create the project by using CMOD
selecting the enhancement e.g. V45A0002 and selecting the component
(one which fulfills our need) i.e the exit which will be implemented in SMOD and after coding has been done the project has to be activated.
An exit can be coded only once.
FUNCTION EXITS
These are used to add functionality through ABAP code . These start from the word EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any tupe of exit including function exits.
The function exits are called from the standard SAP program in the form
of ABAP statement
CALL CUSTOMER-FUNCTION 'NNN'
This is in contrast to USEREXITs where PERFORM statement is used to call
the required userexit.
To implement the FUNCTION EXITs first of all the project is created and a suitable enhancement package is selected and from its compnents the function exit to be implemented is selected and on double clicking it the exit code will appear in ABAP EDITOR(se38) where a Z include will be found and the customer code should be entered in this include.
e.g.
ADDING A DEFAULT SOLD-TO-PARTY in Sales Order Creation
To show a default sold-to-party in this field when the user creates a sales order (VA01) we can use a function exit .This function exit is located
in enhancement no V45A0002 . Before we can choose the exit we have to
create a project in CMOD after that enter V45A0002 in the enhancement field and click on the components . In the components you will see the
exit EXIT_SAPMV45A_002 . This exit is used for our purpose.
Double clicking on this exit will takes us to function builder (SE37) . This
function exit has one exporting parameters and two importing parameters, we are interested in exporting parameter which is E_KUNNR
of type KNA1-KUNNR i.e if we move the desired customer name to this
structure(E_KUNNR) it will be shown in the field as the default value when we create the sales order.
This function also contains a customer include ZXVVA04 . This include
will be used to write our custom code .
Double clicking on this include and it will prompt us that this include does not exists do you want to create this object ,select yes and the include will be created .In this include we can write our own code that will fill the field E_KUNNR.
e.g. E_KUNNR = 301.
Activate the include and Activate the project. Now when ever the SALES ORDER will be created , sold-to-party field will come up with a predefined
customer .
FIELD EXITS
The field exits are managed,created,activated through program RSMODPRF. The field exit is associated with a data element existing in ABAP dictionary and hence to the screen field using that data element.
The format of field exit is :
FIELD_EXIT_dataelement_A-Z or 0-9
If a particular screen and program name is not specified than the field exit will effect all the screens containing that data element.
The function module associated with field exit shows two parameters
INPUT and OUTPUT. Input parameter contains the data passed to the field exit when the field exit was invoked by the R/3 , We can write our own code to change the output parameter depending upon our requirements.
Before the field exit can have any effect the system profile parameter
ABAP/FIELDEXIT in all the application servers should be set to YES
ABAP/FIELDEXIT = YES.
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).
Execute the report, give the transaction you want to find user exit, and query.
HI
To search for a badi, go to se 24 display <b>class cl_exithandler.</b>
double click on method get_instance, get a break point on case statement.
execute and start the required transaction in new session.
look for variable <b>exit_name.</b> It would show the available badi's.
BADI
http://www.allsaplinks.com/badi.html
http://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm
http://support.sas.com/rnd/papers/sugi30/SAP.ppt
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
http://members.aol.com/_ht_a/skarkada/sap/
http://www.ct-software.com/reportpool_frame.htm
http://www.saphelp.com/SAP_Technical.htm
http://www.kabai.com/abaps/q.htm
http://www.guidancetech.com/people/holland/sap/abap/
http://www.planetsap.com/download_abap_programs.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/c2/eab541c5b63031e10000000a155106/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm
http://support.sas.com/rnd/papers/sugi30/SAP.ppt
http://support.sas.com/rnd/papers/sugi30/SAP.ppt
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
http://members.aol.com/_ht_a/skarkada/sap/
http://www.ct-software.com/reportpool_frame.htm
http://www.saphelp.com/SAP_Technical.htm
http://www.kabai.com/abaps/q.htm
http://www.guidancetech.com/people/holland/sap/abap/
http://www.planetsap.com/download_abap_programs.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm.
http://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm
http://support.sas.com/rnd/papers/sugi30/SAP.ppt
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
http://members.aol.com/_ht_a/skarkada/sap/
http://www.ct-software.com/reportpool_frame.htm
http://www.saphelp.com/SAP_Technical.htm
http://www.kabai.com/abaps/q.htm
http://www.guidancetech.com/people/holland/sap/abap/
http://www.planetsap.com/download_abap_programs.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm
/people/thomas.weiss/blog/2006/04/03/how-to-define-a-new-badi-within-the-enhancement-framework--part-3-of-the-series
/people/thomas.weiss/blog/2006/04/18/how-to-implement-a-badi-and-how-to-use-a-filter--part-4-of-the-series-on-the-new-enhancement-framework
User Exit
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sapgenie.com/abap/code/abap26.htm
http://www.sap-img.com/abap/what-is-user-exits.htm
http://wiki.ittoolbox.com/index.php/HOWTO:Implement_a_screen_exit_to_a_standard_SAP_transaction
http://www.easymarketplace.de/userexit.php
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sappoint.com/abap/userexit.pdfUser-Exit
http://www.planetsap.com/userexit_main_page.htm
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sapgenie.com/abap/code/abap26.htm
http://www.sap-img.com/abap/what-is-user-exits.htm
http://wiki.ittoolbox.com/index.php/HOWTO:Implement_a_screen_exit_to_a_standard_SAP_transaction
http://www.easymarketplace.de/userexit.php
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sappoint.com/abap/userexit.pdfUser-Exit
Please do reward if useful
Regards
Dinesh -
Configuration for writing user exits
sir provide me the configuration of user exits,purpose how to write it
thank uHi Supraja,
User exits are the enhancements provided by SAP
you can use them in transactions. Each transaction will have user exits.
If you want to use your own requirements by making your coding while the transaction is run you can use user exits.
For example if you want to run the MRP in MD02 specific to MRP controller you can user exit.
Please also refer the document below.
USEREXIT
Userxits 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 userexits are generally collected in includes and attached to the standard program by the SAP.
All Userexits start with the word USEREXIT_...
FORM USEREXIT_..
z..
ENDFORM.
The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once the correct userexit is found the necessary customer code is inserted in the customer include starting with the z. in the form routine.
e.g. USEREXIT_SAVE_DOCUMENT_PREPARE
Certain application like SD still provide this form of enhancement using userexit but this practice is no longer being followed for newer extensions instead they are using EXITs which come bundled in enhancement packages . Nevertheless existing USEREXITS will be supported by SAP an all the newer versions of SAP.
HOW TO FIND USEREXITS
Userexits can be found in number of ways:
1) To find userexits in SD module , goto object navigator(SE80) and select
development class from the list and enter VMOD in it. All of the userexits in SD are contained in the development class VMOD. Press enter and you will find all the includes which contain userexits in SD for different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the requirement and read the comment inserted in it and start coding.
Some examples of userexits in SD (SALES & DISTRIBUTION) are:
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 userexits ,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 userexits.These userexits are found in include MV45AFZZ of the standard SAP sales order creation program SAPMV45A.
In the case of userexit which will be called when invoicing is done ,these
are provided in the include RY60AFZZ which is in the standard SAP program SAPMV45A. The name of the userexits are same. i.e.
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
These userexits 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 userexit 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 userexits and which is to be filled for that particular field is TKOMP or TKOMK.
Before the coding for these userexits 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 userexits can be used to fill the transportation data to it.
2) The other method of finding userexit is to find the word USEREXIT in the
associated program of the transaction for which we want to determine userexit using SE38.
3) The other method of finding userexits is to find the include in case of SD/MM applications where the userexits are located, this can be found in the SAP reference IMG generally in the subfolder under SYSTEM MODIFICATION.
Some other examples of userexits in SD are:
USEREXIT_NUMBER_RANGE
This userexit is used to assign a different internal document number to the
sales order(VA01) when it is created depending on some criteria like a different SALES ORGANIZAION(VKORG) .
USEREXIT_SAVE_DOCUMENT_PREPARE
This userexit is used to insert the ABAP code which will be called when
the document (sales order VA01) is just about to be saved. This userexit is used generally for custom checks on different fields , to display some information before the order will be saved or for making changes to certain fields before the sales order will be saved.
Exits & Enhancements
There are mainly six types of EXITs in sap which have been collected in the form of enhancement packages and attached to standard code in SAP.
These are different from USEREXIT in the way that they are implemented
in the form of FUNCTIONs while in USEREXITS we use form routines for their implementation. These are also sometimes known as function exits.
These start from the word EXIT_ followed by the program name and then followed by a three digit number.
e.g. EXIT_SAPMV45A_002
This exit is found in SD in enhancement V45A0002.
TYPES OF EXITS
1) MENU EXITS
2) FUNCTION EXITS
3) TABLE EXITS
4) SCREEN EXITS
5) KEYWORD EXITS
6) FIELD EXITS
We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit, it is required to create the project by using CMOD
selecting the enhancement e.g. V45A0002 and selecting the component
(one which fulfills our need) i.e. the exit which will be implemented in SMOD and after coding has been done the project has to be activated.
An exit can be coded only once.
FUNCTION EXITS
These are used to add functionality through ABAP code. These start from the word EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any type of exit including function exits.
The function exits are called from the standard SAP program in the form
of ABAP statement
CALL CUSTOMER-FUNCTION 'NNN'
This is in contrast to USEREXITs where PERFORM statement is used to call
the required userexit.
To implement the FUNCTION EXITs first of all the project is created and a suitable enhancement package is selected and from its components the function exit to be implemented is selected and on double clicking it the exit code will appear in ABAP EDITOR(se38) where a Z include will be found and the customer code should be entered in this include.
e.g.
ADDING A DEFAULT SOLD-TO-PARTY in Sales Order Creation
To show a default sold-to-party in this field when the user creates a sales order (VA01) we can use a function exit .This function exit is located in enhancement no V45A0002 . Before we can choose the exit we have to create a project in CMOD after that enter V45A0002 in the enhancement field and click on the components. In the components you will see the exit EXIT_SAPMV45A_002. This exit is used for our purpose.
Double clicking on this exit will takes us to function builder (SE37) . This
function exit has one exporting parameters and two importing parameters, we are interested in exporting parameter which is E_KUNNR of type KNA1-KUNNR i.e. if we move the desired customer name to this structure(E_KUNNR) it will be shown in the field as the default value when we create the sales order. This function also contains a customer include ZXVVA04. This include will be used to write our custom code.
Double clicking on this include and it will prompt us that this include does not exists do you want to create this object, select yes and the include will be created .In this include we can write our own code that will fill the field E_KUNNR.
e.g. E_KUNNR = 301.
Activate the include and Activate the project. Now when ever the SALES ORDER will be created, sold-to-party field will come up with a predefined customer.
FIELD EXITS
The field exits are managed, created, activated through program RSMODPRF. The field exit is associated with a data element existing in ABAP dictionary and hence to the screen field using that data element.
The format of field exit is:
FIELD_EXIT_dataelement_A-Z or 0-9
If a particular screen and program name is not specified than the field exit will effect all the screens containing that data element.
The function module associated with field exit shows two parameters
INPUT and OUTPUT. Input parameter contains the data passed to the field exit when the field exit was invoked by the R/3, we can write our own code to change the output parameter depending upon our requirements.
Before the field exit can have any effect the system profile parameter
ABAP/FIELDEXIT in all the application servers should be set to YES
ABAP/FIELDEXIT = YES.
TYPES OF USER EXITS
User exits are basically 4 types,
1. Field exit,
2. Menu Exit,
3. Function module and
4. Screen exit.
These exits we can use according to a situation...
Please Reward If Really Helpful,
Thanks and Regards,
Sateesh.Kandula -
Hi Experts,
I got typical requirment.
I have to perfom some caliculation while running the Tcode XD01, sap is providng the User exit for XD01 is <b>SAPMF02D</b>, but here it is not supporting creation, its supporting only change (xd02), there is no Badi. In this case what i have to do, plelase share some ideas.
Thanks in advance.
RamsHi Pavan,
This is not valid exit for XD01(creation), it will support only change
my field is KNA1-BUBKZ(this is not in table parameters)
Thanks
Rams -
Hi SAP gurus can u explain me on user exits?
Hi Chandrakanth,
Userexits are system modifications. The requirements of the client which can be met with Standard SAP are done with help of routines or userexits.
Userexits are nothing but a provision given by sap to write your own code/logic in the standard program.
Say for example while processing a sales order you want to check certain criteria weather they are met or not then you can use userxit_save_document_prepare.Here depending on the code you write system checks the if the criteria is fulfilling if not you can set an error or warning message in the code. This userexit is being executed just before saving of document.
one more commonly used exit is adding field in field catalog
In spro check this path Sales and Distribution-System modifications-Userexits.
Read the document provided,you will find all the exits in different processing for SD with program name and their purpose.
User exits are the enhancements provided by SAP
you can use them in transactions. Each transaction will have user exits.
If you want to use your own requirements by making your coding while the transaction is run you can use user exits.
For example if you want to run the MRP in MD02 specific to MRP controller you can user exit.
Please also refer the document below.
USEREXIT
Userxits 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 userexits are generally collected in includes and attached to the standard program by the SAP.
All Userexits start with the word USEREXIT_...
FORM USEREXIT_..
z..
ENDFORM.
The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once the correct userexit is found the necessary customer code is inserted in the customer include starting with the z. in the form routine.
e.g. USEREXIT_SAVE_DOCUMENT_PREPARE
Certain application like SD still provide this form of enhancement using userexit but this practice is no longer being followed for newer extensions instead they are using EXITs which come bundled in enhancement packages . Nevertheless existing USEREXITS will be supported by SAP an all the newer versions of SAP.
HOW TO FIND USEREXITS
Userexits can be found in number of ways:
1) To find userexits in SD module , goto object navigator(SE80) and select
development class from the list and enter VMOD in it. All of the userexits in SD are contained in the development class VMOD. Press enter and you will find all the includes which contain userexits in SD for different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the requirement and read the comment inserted in it and start coding.
Some examples of userexits in SD (SALES & DISTRIBUTION) are:
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 userexits ,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 userexits.These userexits are found in include MV45AFZZ of the standard SAP sales order creation program SAPMV45A.
In the case of userexit which will be called when invoicing is done ,these
are provided in the include RY60AFZZ which is in the standard SAP program SAPMV45A. The name of the userexits are same. i.e.
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
These userexits 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 userexit 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 userexits and which is to be filled for that particular field is TKOMP or TKOMK.
Before the coding for these userexits 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 userexits can be used to fill the transportation data to it.
2) The other method of finding userexit is to find the word USEREXIT in the
associated program of the transaction for which we want to determine userexit using SE38.
3) The other method of finding userexits is to find the include in case of SD/MM applications where the userexits are located, this can be found in the SAP reference IMG generally in the subfolder under SYSTEM MODIFICATION.
Some other examples of userexits in SD are:
USEREXIT_NUMBER_RANGE
This userexit is used to assign a different internal document number to the
sales order(VA01) when it is created depending on some criteria like a different SALES ORGANIZAION(VKORG) .
USEREXIT_SAVE_DOCUMENT_PREPARE
This userexit is used to insert the ABAP code which will be called when
the document (sales order VA01) is just about to be saved. This userexit is used generally for custom checks on different fields , to display some information before the order will be saved or for making changes to certain fields before the sales order will be saved.
Exits & Enhancements
There are mainly six types of EXITs in sap which have been collected in the form of enhancement packages and attached to standard code in SAP.
These are different from USEREXIT in the way that they are implemented
in the form of FUNCTIONs while in USEREXITS we use form routines for their implementation. These are also sometimes known as function exits.
These start from the word EXIT_ followed by the program name and then followed by a three digit number.
e.g. EXIT_SAPMV45A_002
This exit is found in SD in enhancement V45A0002.
TYPES OF EXITS
1) MENU EXITS
2) FUNCTION EXITS
3) TABLE EXITS
4) SCREEN EXITS
5) KEYWORD EXITS
6) FIELD EXITS
We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit, it is required to create the project by using CMOD
selecting the enhancement e.g. V45A0002 and selecting the component
(one which fulfills our need) i.e. the exit which will be implemented in SMOD and after coding has been done the project has to be activated.
An exit can be coded only once.
FUNCTION EXITS
These are used to add functionality through ABAP code. These start from the word EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any type of exit including function exits.
The function exits are called from the standard SAP program in the form
of ABAP statement
CALL CUSTOMER-FUNCTION 'NNN'
This is in contrast to USEREXITs where PERFORM statement is used to call
the required userexit.
To implement the FUNCTION EXITs first of all the project is created and a suitable enhancement package is selected and from its components the function exit to be implemented is selected and on double clicking it the exit code will appear in ABAP EDITOR(se38) where a Z include will be found and the customer code should be entered in this include.
e.g.
ADDING A DEFAULT SOLD-TO-PARTY in Sales Order Creation
To show a default sold-to-party in this field when the user creates a sales order (VA01) we can use a function exit .This function exit is located in enhancement no V45A0002 . Before we can choose the exit we have to create a project in CMOD after that enter V45A0002 in the enhancement field and click on the components. In the components you will see the exit EXIT_SAPMV45A_002. This exit is used for our purpose.
Double clicking on this exit will takes us to function builder (SE37) . This
function exit has one exporting parameters and two importing parameters, we are interested in exporting parameter which is E_KUNNR of type KNA1-KUNNR i.e. if we move the desired customer name to this structure(E_KUNNR) it will be shown in the field as the default value when we create the sales order. This function also contains a customer include ZXVVA04. This include will be used to write our custom code.
Double clicking on this include and it will prompt us that this include does not exists do you want to create this object, select yes and the include will be created .In this include we can write our own code that will fill the field E_KUNNR.
e.g. E_KUNNR = 301.
Activate the include and Activate the project. Now when ever the SALES ORDER will be created, sold-to-party field will come up with a predefined customer.
FIELD EXITS
The field exits are managed, created, activated through program RSMODPRF. The field exit is associated with a data element existing in ABAP dictionary and hence to the screen field using that data element.
The format of field exit is:
FIELD_EXIT_dataelement_A-Z or 0-9
If a particular screen and program name is not specified than the field exit will effect all the screens containing that data element.
The function module associated with field exit shows two parameters
INPUT and OUTPUT. Input parameter contains the data passed to the field exit when the field exit was invoked by the R/3, we can write our own code to change the output parameter depending upon our requirements.
Before the field exit can have any effect the system profile parameter
ABAP/FIELDEXIT in all the application servers should be set to YES
ABAP/FIELDEXIT = YES.
User exits in the SD orders. These are program names (SE38):
MV45ATZZ
For entering metadata for sales document processing. User-specific
metadata must start with "ZZ".
MV45AOZZ
For entering additional installation-specific modules for sales
document processing which are called up by the screen and run under
PBO (Process Before Output) prior to output of the screen. The
modules must start with "ZZ".
MV45AIZZ
For entering additional installation-specific modules for sales
document processing. These are called up by the screen and run under
PAI (Process after Input) after data input (for example, data
validation). The User exits in the SD orders. These are program names (SE38):
MV45ATZZ
For entering metadata for sales document processing. User-specific
metadata must start with "ZZ".
MV45AOZZ
For entering additional installation-specific modules for sales
document processing which are called up by the screen and run under
PBO (Process before Output) prior to output of the screen. The
modules must start with "ZZ".
MV45AIZZ
For entering additional installation-specific modules for sales
document processing. These are called up by the screen and run under
PAI (Process after Input) after data input (for example, data
validation). The modules must start with "ZZ".
MV45AFZZ and MV45EFZ1
for entering installation-specific FORM routines and for using user
exits, which may be required and can be used if necessary. These
program components are called up by the modules in MV45AOZZ or
MV45AIZZ. e modules must start with "ZZ".
MV45AFZZ and MV45EFZ1
for entering installation-specific FORM routines and for using user
exits, which may be required and can be used if necessary. These
program components are called up by the modules in MV45AOZZ or
MV45AIZZ.
SMOD is the transaction to view user exits assigned to an object.
CMOD is the transaction to change the user exits according to your requirement.
You can find user exits by looking into the phrase USER_EXIT.
Check this program to find out user exits for a transaction
TABLES: tftit,
e071,
e070.
TYPES: BEGIN OF x_tstc,
tcode TYPE tcode,
pgmna TYPE program_id,
END OF x_tstc.
TYPES: BEGIN OF x_tadir,
obj_name TYPE sobj_name,
devclass TYPE devclass,
END OF x_tadir.
TYPES: BEGIN OF x_slog,
obj_name TYPE sobj_name,
END OF x_slog.
TYPES: BEGIN OF x_final,
name TYPE smodname,
member TYPE modmember,
include(15), "Include name
END OF x_final.
DATA: it_tstc TYPE STANDARD TABLE OF x_tstc WITH HEADER LINE.
DATA: it_tadir TYPE STANDARD TABLE OF x_tadir WITH HEADER LINE.
DATA: it_jtab TYPE STANDARD TABLE OF x_slog WITH HEADER LINE.
DATA: it_final TYPE STANDARD TABLE OF x_final WITH HEADER LINE.
SELECTION-SCREEN: BEGIN OF BLOCK blk01 WITH FRAME TITLE text-t01.
PARAMETERS: p_tcode LIKE tstc-tcode OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk01.
START-OF-SELECTION.
PERFORM get_tcodes. "Get Tcodes
PERFORM get_objects. "Get Objects
END-OF-SELECTION.
PERFORM display_results. "Display Results
FORM get_tcodes.
SELECT tcode
pgmna
INTO TABLE it_tstc
FROM tstc
WHERE tcode = p_tcode.
IF sy-subrc = 0.
SORT it_tstc BY tcode.
ENDIF.
ENDFORM. " get_tcodes
FORM get_objects.
DATA: l_fname LIKE rs38l-name,
l_group LIKE rs38l-area,
l_include LIKE rs38l-include,
l_namespace LIKE rs38l-namespace,
l_str_area LIKE rs38l-str_area.
DATA: v_include LIKE rodiobj-iobjnm.
DATA: e_t_include TYPE STANDARD TABLE OF abapsource WITH HEADER LINE.
DATA: l_line TYPE string,
l_tabix LIKE sy-tabix.
IF NOT it_tstc[] IS INITIAL.
SELECT obj_name
devclass
INTO TABLE it_tadir
FROM tadir FOR ALL ENTRIES IN it_tstc
WHERE pgmid = 'R3TR' AND
object = 'PROG' AND
obj_name = it_tstc-pgmna.
IF sy-subrc = 0.
SORT it_tadir BY obj_name devclass.
SELECT obj_name
INTO TABLE it_jtab
FROM tadir FOR ALL ENTRIES IN it_tadir
WHERE pgmid = 'R3TR' AND
object = 'SMOD' AND
devclass = it_tadir-devclass.
IF sy-subrc = 0.
SORT it_jtab BY obj_name.
ENDIF.
ENDIF.
ENDIF.
*- Get UserExit names
LOOP AT it_jtab.
SELECT name
member
INTO (it_final-name, it_final-member)
FROM modsap
WHERE name = it_jtab-obj_name AND
typ = 'E'.
APPEND it_final.
CLEAR it_final.
ENDSELECT.
ENDLOOP.
*- Process it_final contents.
LOOP AT it_final.
l_tabix = sy-tabix.
CLEAR: l_fname,
l_group,
l_include,
l_namespace,
l_str_area.
l_fname = it_final-member.
CALL FUNCTION 'FUNCTION_EXISTS'
EXPORTING
funcname = l_fname
IMPORTING
group = l_group
include = l_include
namespace = l_namespace
str_area = l_str_area
EXCEPTIONS
function_not_exist = 1
OTHERS = 2.
IF sy-subrc = 0.
IF NOT l_include IS INITIAL.
*- Get Source code of include.
CLEAR: v_include, e_t_include, e_t_include[].
v_include = l_include.
CALL FUNCTION 'MU_INCLUDE_GET'
EXPORTING
i_include = v_include
TABLES
e_t_include = e_t_include.
IF sy-subrc = 0.
LOOP AT e_t_include.
IF e_t_include-line CS 'INCLUDE'.
CLEAR l_line.
l_line = e_t_include-line.
CONDENSE l_line NO-GAPS.
TRANSLATE l_line USING '. '.
l_line = l_line+7(9).
it_final-include = l_line.
MODIFY it_final INDEX l_tabix TRANSPORTING include.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " get_objects
FORM display_results.
FORMAT COLOR COL_HEADING.
WRITE:/1(150) sy-uline.
WRITE:/ sy-vline,
2(23) 'Extension Name',
24 sy-vline,
25(39) 'Exit Name',
64 sy-vline,
65(74) 'Description',
140 sy-vline,
141(9) 'Include',
150 sy-vline.
WRITE:/1(150) sy-uline.
FORMAT RESET.
SORT it_final BY name member.
LOOP AT it_final.
CLEAR tftit.
SELECT SINGLE stext
INTO tftit-stext
FROM tftit
WHERE spras = 'EN' AND
funcname = it_final-member.
WRITE:/ sy-vline,
it_final-name COLOR COL_KEY, 24 sy-vline,
25 it_final-member, 64 sy-vline,
65 tftit-stext, 140 sy-vline,
141 it_final-include, 150 sy-vline.
WRITE:/1(150) sy-uline.
ENDLOOP.
ENDFORM. " display_results
Hope this Clarifies your Doubts and Please Reward If Really Helpful,
Thanks and Regards,
Sateesh.Kandula
Maybe you are looking for
-
Hi, I can not resolve my problem. On our Public site we create a course page for my unit «BENA». This welcome page name is «Sciences et technologies». My problem, we have a welcome page for «Sciences de l'éducation» and we would like to put a shortcu
-
Document Flow to Production Orders from BOM
Dear SAP Gurus, I have attached a few documents at header level of the BOM. I have also attached document at item level in the BOM. When I create a production order these documents are not flowing to Production Order. Is there any way to do that. I a
-
Is SQLPlus supported by oracle cloud?
Hi, I'm creating a database system using SQLPlus which will be stored/connected to the cloud. I've been made aware that SQLPlus is not supported by Oracle Cloud and that I should use SQL Developer, is this true or will SQLPlus be supported by Oracle
-
My mini jumps from screen to screen and then jiggles and then says "Ipad is disabled, try again in 5 minutes", and then goes black. If it lets me logon it only works properly for a minute or two. Usually it now won't let me even enter my passcode b
-
Hi! I am building a portlet that display results of a SQL query (defined on admin settings). The portlet is used by many users. Caching works fine except on occasions when the user is required to view the latest records. Is it possible to reset the p