Quantcast
Channel: SCN : Blog List - Customer Relationship Management (SAP CRM)
Viewing all articles
Browse latest Browse all 229

Copy pricing conditions between documents

$
0
0
ComponentSuuport Pachage
BBPCRMSAPKU70204
SAP_ABASAPKA73105
SAP_BASISSAPKB73105
WEBCUIF

SAPK-73105INWEBCUIF

 

The Scenario

 

We want to copy only one specific manual condition if some info of target document meets a custom criteria.

 

The design

 

We will include a new field in the pricing field catalog, which will be informed in the communication BADI, where we will have our criteria.

Why this approach? the "correct" thing would be to include all the criteria in the field catalog and use all the data to determine what to do inside the java routine. Why I'm not doing this approach? because the transfer structures for pricing have the same limitation as a normal structure, if you start to add fields like crazy you will run out of fields, some field may be necessary for the routines or to define pricing tables, so is very important to be selective. Plus I prefer to do as much as I can the custom logic on the ABAP side and looks like I'm not the only one who follows that path you can check the cool blog from Manuel SeegerEntering Java Userexits 01: Generic Requirements

 

Step 1 Add a transfer field into the pricing field catalog:

 

 

cust1.JPG

 

I already have created the data element which has a FLAG domain.

cust2.JPG

 

We save the changes.

Step 2 Create the Java User exit


I will skip the detail on this part as you already have all the information on the note Note 809820, the only thing to point is we will extend the standard class PricingCopyFormulaAdapter in order to use the pricing copy exit (pricingCopy), as I said further details in note  809820.

 

Step 3 Maintenance of User Exit Assignments

 

We will launch the transaction /SAPCND/UEASS with usage PR (our scenario) and select the CPY User Exit Type

 

cust3.JPG

 

On implementations, we define our new implementation and point it to the IPC directory

 

cust4.JPG

 

cust5.JPG

 

And we also define the custom attribute which will tell us what do do inside the Java routine

cust6.JPG

 

 

 

In the formula area (Application CRM, Usage PR in our scenario) we will assign Our user exit to a formula ID

 

cust7.JPG

 

We are using 601 as is our customer number range, for more info check the transaction /SAPCND/UERNG  and the note  809820.

Also, we need to map the Attribute of the implementation with the pricing transfer structure field

cust8.JPG


Caution!!! Here comes the weird part, the attribute won't be visible inside the copy routine unless you define a REQ or VAL void routine which has the parameter definition which you need it in the copy routine, so we need to create that and assign the routine in some condition in each pricing procedure which the copy control should apply, as it will be a dummy routine you can assign it anywhere, don't ask me why works like this, only SAP IPC engineers knows that


cust14.JPG

cust15.JPG

cust16.JPG


Don't forget to delete the VM cache (SM53) after the copy control changes.

Sm53.JPG

Step 4 Set up de copy control for the document items


cust9.JPG

 

cust10.JPG

We will copy the standard one (01000) and replace the copy routine number for our own one (601)

 

cust11.JPG

 

 

cust12.JPG

 

cust13.JPG

Step 5 The ABAP Code


I will skip the ABAP side, as is the easiest one, we will implement or modify the implementation of the BADI CRM_COND_COM_BADI to put our custom logic and inform the field on the method ITEM_COMMUNICATION_STRUCTURE (changing parameter CS_ACS_I_COM) depending on our criteria.


Step 6 Java Code

 

I'm not an expert on Java so I'm sure this algorithm can be easily improved

 

package z***.pricing.userexits;
import com.sap.spe.conversion.IQuantityValue;
import com.sap.spe.pricing.customizing.ICopyType;
import com.sap.spe.pricing.customizing.IPricingType;
import com.sap.spe.pricing.customizing.PricingCustomizingConstants;
import com.sap.spe.pricing.transactiondata.PricingTransactiondataConstants;
import com.sap.spe.pricing.transactiondata.userexit.IPricingConditionUserExit;
import com.sap.spe.pricing.transactiondata.userexit.IPricingDocumentUserExit;
import com.sap.spe.pricing.transactiondata.userexit.IPricingItemUserExit;
import com.sap.spe.pricing.transactiondata.userexit.PricingCopyFormulaAdapter;
public class ZCopyOnlyZ**** extends PricingCopyFormulaAdapter {
public void pricingCopy(IPricingDocumentUserExit pricingDocument,  IPricingItemUserExit pricingItem,  IPricingConditionUserExit pricingCondition,  IPricingType pricingType, ICopyType copyType,  IQuantityValue sourceSalesQuantity) {  String CopyZ = pricingItem.getAttributeValue("ZZ***_COPY_Z*****");  if (pricingCondition.getConditionTypeName().equals("Z****")){       if (!CopyZ.equals("X"))       {
//        Don't Copy condition Z***         pricingCondition.setInactive(PricingCustomizingConstants.InactiveFlag.INVISIBLE);       }  }  else  {
//      We only copy manual conditions of type Z****   pricingCondition.setInactive(PricingCustomizingConstants.InactiveFlag.INVISIBLE);  }  }
}

Before finish the blog I would like to thank Baris Yalcin for his support and I hope you find this blog useful, looking forward for your feedback

 

Cheers!

 

Luis


Viewing all articles
Browse latest Browse all 229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>