on ‎2011 Sep 21 5:12 PM
Hi Experts,
We are working on the SAP Sourcing 5.0. Here we have a contract workflow, which needs to go through some approval phases. The approval is working fine. Its moving from one phase to another phase once we approve the contract. But now the requirement has been changed a bit. The requirement is as following:
1. We have to first figure out the Agreement Document Type.
2. Depending upon the Document Type we have to fetch the organizational unit(External ID).
3. Depending upon the organizational unit we have to get the approval group(External ID) associated with the organization.
Can you please let help us how we will achieve above three functionality .
For the second point i tried the below code,its giving me the Organizational Unit text, but not the External ID for the Organizational Unit.
accHome = IBeanHomeLocator.lookup(session, session.getAccount().getAccountObjectReference());
accBean = accHome.find(session.getAccount().getAccountObjectReference());
org_unit = accBean.getOrganizationalUnit();
log.setLogMessage("--
");
Logger.error(log);
When i tried the below code to get the Organizational Unit External ID, it threw the following exceptions.
busUnitHome = IBeanHomeLocator.lookup(session, doc.getOrganizationalUnitRef());
busUnit = busUnitHome.find(doc.getOrganizationalUnitRef());
log.setLogMessage("--
");
Logger.error(log);
//Get the External ID for the Organizational Unit
log.setLogMessage("--
");
Logger.error(log);
Error:
Error in method invocation: No args method getOrganizationalUnitRef() not found in class'com.frictionless.api.doccommon.doc.contract.ContractDocumentIBeanImpl' : at Line: 84 : in file: inline evaluation of: ``/* * This script handles the prescript activities for the first Legal Review * . . . '' : doc .getOrganizationalUnitRef ( ).
Error:
No args method getExternalId() not found in class'com.frictionless.common.db.ObjectReference' : at Line: 70 : in file: inline evaluation of: ``/* * This script handles the prescript activities for the first Legal Review * . . . '' : org_unit .getExternalId ( )
This is an high priority issue for us, need urgent help.
Thanks,
Ritik
Request clarification before answering.
Hi Mudit,
Thanks for your timely help.
Iam working with Ritik on the same code base.Yes we have this Legal group as an extention on the Organization
Unit.
regards,
Priya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Try the following code:
OrgUnitRef = maBean.getOrganizationalUnitRef(); // to get org unit reference like mentioned before
OrgUnitHome = IBeanHomeLocator.lookup(session,OrgUnitRef );
OrgUnit = OrgUnitHome.find(OrgUnitRef);
LegalGroup = OrgUnit.getExtensionField("ExtensionFieldName").get(); // Replace ExtensionField Name with extension attribute internal name
LegalGroupHome = IBeanHomeLocator.lookup(session,LegalGroup );
LegalGroupRef =LegalGroupHome.find(LegalGroup);
LegalGroupID = LegalGroupRef.getExternalId();
Regards
Mudit Saini
Hi
1. We have to first figure out the Agreement Document Type.
I am assuming you need to get the display name of the agreement doc type here. Use the below mentioned code:
DocTypeRef = doc.getDocTypeReference();
DocTypeHome = IBeanHomeLocator.lookup(session,DocTypeRef );
DocType = DocTypeHome.find(DocTypeRef);
DocTypeName = DocType.getDisplayName();
You can make slight modifications to suit your interest
2. Depending upon the Document Type we have to fetch the organizational unit(External ID).
Following is the code to get external Id of organization Unit of current document/ master agreement.
OrgUnitRef = doc.getOrganizationalUnitRef();
OrgUnitHome = IBeanHomeLocator.lookup(session,OrgUnitRef );
OrgUnit = OrgUnitHome.find(OrgUnitRef);
OrgUnitExtID = OrgUnit.getExternalId();
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.
Hi Ankur,
There doesnt seem to be a standard getter for accessing the Org Unit in a company. Here is an approach you can try.
Assuming that you are writing the script for Company, use the findWhere() function on BusinessUnit home bean. The SQL clause should match the parent object id of the BusinessUnit with the object id of the Company.
Forum members can suggest some easier ways as well.
Thanks
Devesh
Hi Mudit,
Appreciate your help in resolving this issue . i tried the code that you sent.
For the first point, that is getting the Document Type :
DocTypeRef = doc.getDocTypeReference();
DocTypeHome = IBeanHomeLocator.lookup(session,DocTypeRef );
DocType = DocTypeHome.find(DocTypeRef);
DocTypeName = DocType.getDisplayName();The above code is giving me the Contract Document Type like Contract,Addendum,Amendment. But its not giving me the Master Agreement's Document Type .I need the Agreement document Type.
The second code is throwing error :
OrgUnitRef = doc.getOrganizationalUnitRef();
OrgUnitHome = IBeanHomeLocator.lookup(session,OrgUnitRef );
OrgUnit = OrgUnitHome.find(OrgUnitRef);
OrgUnitExtID = OrgUnit.getExternalId();Sourced file: inline evaluation of: ``/* * This script handles the prescript activities for the first Legal Review * . . . '' : Error in method invocation: No args method getOrganizationalUnitRef() not found in class'com.frictionless.api.doccommon.doc.contract.ContractDocumentIBeanImpl' : at Line: 95 : in file: inline evaluation of: ``/* * This script handles the prescript activities for the first Legal Review * . . . '' : doc .getOrganizationalUnitRef ( )
Thanks,
Ritik
Hi Ritik,
doc always refers to the document on/for which the code is executing. In case of workflows that document is always Contract Document. So there is no surprise that you are getting Addendum and Amendment as the document type.
You need to change your code a little so that you can call all the required function on the Master Agreement i.e, the parent of the current contract document. Try the snippet given below :
maBean = doc.getParentIBean();
maBeanType = maBean.getDocTypeReference().getDisplayName();
This will give you the Master Agreement Type.
The second approach looks fine, except that you need to replace doc by the maBean variable I have used above.
Let us know how it goes.
Thanks
Devesh
Hi Devesh/Mudit,
Thanks for staying on top of this issue & helping me in resolving this, appreciate your help.
The only piece left in this puzzle is getting the Legal groupu2019s External ID associated with the Organizational Unit of the agreement.
Path:
Master Agreement--> <Agreement Name> -->In the header tab of the agreement click on the Organizational Unit Link --> Here we have the Legal Group
Thanks,
Ritik
Edited by: Ritik B on Sep 23, 2011 12:48 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.