on 08-29-2012 5:09 PM
I need some help with the script required to set a contract extension field currency code to equal the Master Agreement currency.
//Fetch the currency
MACcy=MAbean.getCurrency();
logMsg.setLogMessage(CLM + "Document Currency is : " + MAbean.getCurrency().getDisplayName());
Logger.info(logMsg);
PriceIfc priceValue = doc.getExtensionField("PRC001").get();
contractValue = priceValue.getPrice();
curr = priceValue.getCurrency();
doc.getExtensionField("PRC001").setCurrency(MAbean.getCurrency()); //script fails at this point
Hi Michael,
I am assuming that your extension field PRC001 is of PriceIfc type.
The PriceIfc doesn't have a method called setCurrency(). Thats where you code is failing.
The only way you can set your extension field is by using a PriceIfc object. My suggestion is to create a new use PriceIfc object by using TypeFactory API. While creating this object you should pass the currency object reference as a parameter to the constructor. This should be the same one that you have got from the MAbean.getCurrency() method.
In short, have a look at the TypeFactory APIs and your problem will be solved
Thanks
Devesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is some coding I recently used to set the price value in an extension collection, just to show an example of what Devesh explained:
collIt = extCollection.iterator();
while(collIt.hasNext()) {
ExtensionCollectionMemberIfc member = collIt.next();
// first get value stored in a decimal field
reduction = member.get("benefits_reduction");
if(reduction != null) {
// take the decimal and the document currency to create a PriceIfc object
// and set it to the new field of type price
price = TypeFactory.createPrice(doc.getCurrency(), reduction);
member.set("benefits_red_curr", price);
}
}
So basically don't try to set the currency on the existing price vale but create a new price value and set this.
Hi All ,
I have a requirement for changing the custom field currency on changing the project header currency . Only the currency of extension field needs to be changed but not the price. I'm trying the below method but looks like not working
doc.getExtensionField("Z_TOOLING_VALUE").setCurrency (doc.getCurrency());
Can you please suggest ?
Thanks
Sudipta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please try :
doc.getExtensionField("PRC001").set(MAbean.getCurrency());
or
doc.getFieldMetadata("PRC001").set(doc, MAbean.getCurrency());
Please check and reply if its working.
Regards,
Kumud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried both examples and both cause the script to fail on the
"PriceIfc priceValue = doc.getExtensionField("PRC001").get();" statement. I suspect the price portion of the field is being removed.
Script extract as follows.....>
doc.getFieldMetadata("PRC001").set(doc, MAbean.getCurrency());
//Fetch the currency
MACcy=MAbean.getCurrency();
logMsg.setLogMessage(CLM + "Document Currency is : " + MAbean.getCurrency().getDisplayName());
Logger.info(logMsg);
PriceIfc priceValue = doc.getExtensionField("PRC001").get();
contractValue = priceValue.getPrice();
curr = priceValue.getCurrency();
logMsg.setLogMessage(CLM + "Currency is : " + curr );
Logger.info(logMsg);
//If currency is other then USD then conversion is required
if (!curr.equalsIgnoreCase("USD")) {
Error in log is....>
Sourced file: inline evaluation of: ``// Author: Mike Wellard // Date: 17 July 2012 // Class: Contract Document // . . . '' : Typed variable declaration : Can't assign com.sap.odp.common.db.LocalizedObjectReference to com.sap.odp.api.common.types.PriceIfc : at Line: 324 : in file:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.