on 05-18-2011 8:41 AM
Hi
We are working on SAP e sourcing 5.1
I am trying to access all the master agreement with Display_Name beginning with "A" and trying to change expiration date based on an integer value extension field "RENEWAL_DUR_YEAR". I have written the following script for the same
-
import com.frictionless.api.contracts.ContractIBeanIfc;
import java.text.*;
import java.util.*;
import java.lang.*;
import com.frictionless.api.ibean.IBeanHomeLocatorIfc;
import com.frictionless.api.ibean.IBeanHomeIfc;
import com.frictionless.api.contracts.*;
import java.text.SimpleDateFormat;
import com.frictionless.api.ibean.OrderedSubordinateCollectionIfc;
logMsg = Logger.createLogMessage(session);
contractHome = IBeanHomeLocator.lookup(session,com.frictionless.api.contracts.ContractIBeanHomeIfc.sHOME_NAME);
contractList = contractHome.findWhere("DISPLAY_NAME LIKE 'A%' '');
for(Iterator iterator1 = contractList.iterator(); iterator1.hasNext();)
{
ContractIBeanIfc masterAgreement = (ContractIBeanIfc)iterator1.next();
ExpirationDate = masterAgreement.getExpirationDate().getDate();
Calendar cal2=Calendar.getInstance();
cal2.setTime(ExpirationDate);
durationYear = masterAgreement.getExtensionField("RENEWAL_DUR_YEAR").get();
cal2.add(Calendar.YEAR,durationYear);
masterAgreement.setExpirationDate(TypeFactory.createSysDate(cal2.getTime()));
}
-
I am getting the following error:
Error executing script: Sourced file: inline evaluation of: ``import com.frictionless.api.contracts.ContractIBeanIfc; import java.text.*; imp . . . '' : Method Invocation masterAgreement.setExpirationDate.
setExpirationDate is working fine otherwise. Is there something I am missing? please suggest
Regards
Mudit Saini
Edited by: Mudit_UCB on May 18, 2011 10:33 AM
Edited by: Mudit_UCB on May 18, 2011 10:49 AM
Mudit,
At first glance, your code looks OK but I think there is a syntax error in the line
contractList = contractHome.findWhere("DISPLAY_NAME LIKE 'A%' '');
That last double quote is actually 2 single quotes. Please check this in your code and make sure it's a double quote.
Second, I would write a comment to the log file to find out the size of contractList to make sure it has members.
Lastly, Immanuel made a good point to make sure the record is in edit mode.
Regards,
Alan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you are getting the error becaue you are trying to set value in a master agreement that is not in the edit mode.
follow these steps:
1)check if the master agreement is in edit mode.
2)if not, upgrade it to edit mode
3)set the expiration date
4)save the master agreement.
5)down grade the master agreement to view mode.
the code should be something like this....
if(masterAgreement.isObjectAccessModeEdit())
masterAgreement.setExpirationDate(TypeFactory.createSysDate(cal2.getTime()));
else
{
masterAgreement.getIBeanHomeIfc().upgradeToEdit(masterAgreement);
masterAgreement.setExpirationDate(TypeFactory.createSysDate(cal2.getTime()));
masterAgreement.getIBeanHomeIfc().save(masterAgreement);
masterAgreement.getIBeanHomeIfc().downgradeToView(masterAgreement);
}
Hope this helps.,
Regards,
Immanuel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Immanuel & Alan
Thanks a lot for your inputs! It certainly helped me solve the problem
I have one more doubts that I would like to clarify before closing the question. I want to deploy a loop to access all the master agreements with STATUS ACTIVE . I tried using the following code line for the same:
contractList = contractHome.findWhere("STATUS LIKE 'ACTIVE' ");
Now since STATUS is not a text field, this query "STATUS LIKE 'ACTIVE' " didn't work. Can you plz help me define a query to access agreement status
Regards
Mudit Saini
Hi Devesh
I used the following script to check "contractHome.findWhere("INACTIVE=0");" method:
-
import com.frictionless.api.contracts.ContractIBeanIfc;
import java.text.*;
import java.util.*;
import java.lang.*;
import com.frictionless.api.ibean.IBeanHomeLocatorIfc;
import com.frictionless.api.ibean.IBeanHomeIfc;
import com.frictionless.api.contracts.*;
import java.text.SimpleDateFormat;
import com.frictionless.api.ibean.OrderedSubordinateCollectionIfc;
logMsg = Logger.createLogMessage(session);
contractHome = IBeanHomeLocator.lookup(session,com.frictionless.api.contracts.ContractIBeanHomeIfc.sHOME_NAME);
contractList = contractHome.findWhere("INACTIVE=0");
for(Iterator iterator1 = contractList.iterator(); iterator1.hasNext();)
{
ContractIBeanIfc masterAgreement = (ContractIBeanIfc)iterator1.next();
Title = masterAgreement.getDisplayName();
logMsg.setLogMessage("*****Title"+Title);
Logger.info(logMsg);
}
-
I got the following error:
Error executing script: Sourced file: inline evaluation of: ``import com.frictionless.api.contracts.ContractIBeanIfc; import java.text.*; imp . . . '' : Method Invocation contractHome.findWhere.
Regards
Mudit Saini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.