Wednesday, January 28, 2015

How to debug the IPC

Pricing might seem simple from an end-user's perspective, but in practice can be quite complex as the price determination may depend on many factors (customer class, location, contracts, VAT, delivery type, payment method, sales organisation, material, etc).

To support all this complexity, SAP CRM uses condition techniques similar to SAP ECC, but leaves the actual calculation to a - for most people - black box... The Internet Pricing and Configurator (IPC). After reading this blog you no longer belong to 'most people'.
We will be showing how to take a peek inside the IPC.

As the IPC is a JAVA based component, you cannot debug the processes inside the IPC with a normal SAP ABAP debugger.

To debug the IPC, a couple of prerequisites are required as described in the pricing userexit manual in note 809820.


Install software

In short, the following steps are required to set up your programming environment:
  1. Install JAVA SE ( preferred 6 or 7 ) from http://www.oracle.com/technetwork/java/javase/downloads/index.html 
  2. Install an eclipse version from: http://www.eclipse.org/downloads (Version: 4.3.2 is confirmed to be working)

Setup Eclipse

An Eclipse project must be set up according to the following steps:

  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 809820 into that empty directory. A subdirectory with the name PRC_UE_CUSTOMER should appear, containing the project files. 
  3. Start your SAP GUI on the same machine, login into the system and start transaction /SAPCND/UE_DEV (enter /n/SAPCND/UE_DEV). 
  4. Select the Download option and activate the option Libraries. 
  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. Select File --> Import... and "Import an Existing Project into Workspace". Now select the PRC_UE_CUSTOMER folder as root directory. Eclipse should show the PRC_UE_CUSTOMER as project name. 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 the one currently used on your system. Check in your SAP system on which java version the VMC is running.

  7. 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. . If you receive an error please make sure that you use JDK instead of JRE. And make sure that the configured installed JRE is used in the ANT Build configuration.



  8. Refresh the eclipse Project by right mouse clicking on the project and selecting Refresh (F5) in the context menu.

Your Eclipse environment is now ready for IPC programming and debugging.

Debugging

In order to debug the code running on the VMC using your Eclipse environment, the following steps can be followed:

  1. Ensure the local java code is the same as the Java code running on the IPC. 
  2. Activate breakpoints in the Java formula you wish to debug 
  3. Set user parameter PRC_RFC = X
  4. Create a document with pricing in the webclient, we're not picking up debugging from there. Just save the document, so we can go ahead with debugging. 
  5. Now open this document in the SAP Gui transaction CRMD_ORDER Go to the item details and then to the Conditions tab.
  6. SAP should now open an ABAP debugging window. Step into the function SPC_GET_PRICING_PROCEDURE_INFO using F5.
  7. Doing this, triggers a pop-up, which shows you on which port you can connect to the debugger.
  8. Now go into Eclipse and setup a debugging configuration.
  9. In Eclipse the debugging window now shows the following:
  10. The ABAP debugger now also opens again. Now just pass through all the break points on SAP side using F8 (there is no need to debug there) 
  11. Once all break points in SAP are passed, the break points in Eclipse will be picked up.
  12. In Eclipse, you can step though the code just like in ABAP and see the value of attributes.

No comments:

Post a Comment