Skip to Content
Author's profile photo Former Member

Modification of condition type values in CRM

Hi all,

Here I am explaining a scenario which will help us to modify a condition type value easily using java user exit. We can use eclipse 3.1 to create the java user exit and the j2sdk version should be j2sdk1.4.2.X
Setting up Java
The pricing userexits shall be compiled with the J2SE 1.4.x or a compatible java compiler of version 1.4.x. Also the used libraries must be compatible with J2SE 1.4.x. The java development kit is available for download using Old versions are also available at standard installation of the JDK is sufficient. It is important that the compiled class files are compatible to a JDK 1.4 version as well as the standard library used is only JDK 1.4. The VMC java environment of SAP BASIS 7.00 does only support 1.4 class files and libraries.
 Setting up Eclipse
Eclipse 3.1 is recommended and can be downloaded using Newer versions may also work. A simple unpacking of the downloaded file is all that is needed to install eclipse. The eclipse-IDE manages the files in projects and those in workspaces. A workspace contains all administrative data of eclipse. Project files, like java files, may lie also in that workspace but can also be outside. In this document the first approach has been chosen.
 The Prepared Eclipse Project
Setting up the prepared project keeps the effort low and helps in fastened results. An experienced user can easily adapt the project layout and location to their needs (e.g. using a source versioning system).  

1. Create an empty folder where all relevant data is stored (e.g. C:\DEV). This folder will be the workspace folder for eclipse. 
2. Unpack the ZIP file attached to the SAP note into that empty directory (e.g. C:\DEV). Then a subdirectory with the name PRC_UE_CUSTOMER should appear (C:\DEV\PRC_UE_CUSTOMER), containing the project files.
3. Start your SAP GUI on the same machine, login into the system and start transaction /SAPCND/UE_DEV(using the command field enter /n/SAPCND/UE_DEV).
4. Select the Download option and activate the option Libraries. Downloading requires a minimum authorization of exporting data from SAPGUI into the local file system (Object S_GUI, ACTVT 61)
5. Enter as path the newly created subfolder PRC_UE_CUSTOMER (e.g. C:\DEV\ PRC_UE_CUSTOMER) and hit the execute button. The downloading will take a few minutes and create some subfolder in the PRC_UE_CUSTOMER directory containing some API jars and some source jars
6. Start eclipse and select as workspace the manual created folder (C:\DEV). Eclipse will create the Meta data for an empty workspace.
7. Select File Import and Import an Existing Project into Workspace. Select the PRC_UE_CUSTOMERfolder as root directory. Eclipse should show the PRC_UE_CUSTOMER as project name
8. Now the JRE System Libraries have to be added to the build path of eclipse. Activate the context menu on the project (right mouse click) and select Build Path – Add Libraries. Select JRE System Library and use a 1.4.xversion
9. Prepare the API source and build the HTML documentation. Activate the context menu (right mouse click) on build_api_doc.xml and select Run As ->Ant Build. Please ignore the error message thrown during that process
10. Refresh the eclipse Project by right mouse clicking on the project and selecting Refresh (F5) in the context menu
Now the default project is ready to be used for custom developments. Java Documentation for all API classes is available and can be viewed by eclipse auto completion help or by opening the filePRC_UE_CUSTOMER/api_doc/index.html.

The type of user exit which we have Condition Value Formula (VAL) .This userexit can be used to replace the automatically determined condition value. This kind of userexits must be assigned, in the customizing, to the userexits type VAL – Condition Value Formula.
This userexit is called after the calculation of the condition value for each pricing condition. The userexit class must be inherited from the class ValueFormulaAdapter and overwrites at least overwriteConditionValue. If group condition processing for that condition type is enabled, also the overwriting of method overwriteGroupConditionValue is possible. Both methods can return null to indicate that the original value shall not be changed.we have to inherit ValueFormulaAdapter class to modify a normal condition type. Please see the below sample code

Sample Code(This userexit will modify the condition value to 100).

import java.math.BigDecimal;
public class ZSpecialRoundingValueFormula extends ValueFormulaAdapter {
private static UserexitLogger userexitlogger =new UserexitLogger(ZSpecialRoundingValueFormula.class);
public BigDecimal overwriteConditionValue(IPricingItemUserExit item,IPricingConditionUserExit condition)
BigDecimal result;
userexitlogger.writeLogDebug(“old cond value: “+condition.getConditionValue().getValueAsString());
Condition .getConditionValue();
result = new BigDecimal(“100”);
return result;
Defining an implementation in CRM For this userexit

Go to the transaction /SAPCND/UEASS  in CRM GUI. Select the user exit type VAL and give the complete path of the userexit which we created in the eclipse. Click the formula give a number betrween 600 and 999 select the implementation we created.
Go to eclipse create a jar file and select “create_PRC_UE_CUSTOMER_jar.jardesc” in the project explorer and right click and select the option create jar it will create a jar file in the project folder after that  go to transaction /sapcnd/ue_dev and upload this jar file.
And go to the CRM system select the pricing procedure select the condition type which we have to modify using java user exit, assign the user exit number which we create under the tab Calc.Formula.Then restart the VMC and create the order.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.