cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to obtain the Agreement Document Type,OrgUnit External ID,ApprovalGrp

ritikbaral
Explorer
0 Likes
445

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("--


WF:Organizational Unit: " + org_unit + "--


");

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("--


WF:Organizational Unit: " + busUnit + "--


");

Logger.error(log);

//Get the External ID for the Organizational Unit

log.setLogMessage("--


WF:Organizational Unit: " + busUnit.getExternalId() + "--


");

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

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

Former Member
0 Likes

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

ritikbaral
Explorer
0 Likes

Thanks a lot Mudit/Devesh. All our issues are now resolved.I have rewarded the points. Appreciate your help.

Answers (1)

Answers (1)

Former Member
0 Likes

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

Former Member
0 Likes

Hi Mudit,

In my requirement i want to have the Organisational Unit of the Company.Can you Please suggest some workaound for this.

Thanks,

Ankur

Former Member
0 Likes

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

ritikbaral
Explorer
0 Likes

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

Former Member
0 Likes

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

ritikbaral
Explorer
0 Likes

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

Former Member
0 Likes

Hi

Is this Legal Group an extension definition that you have added to Organizational Unit?

Regards

Mudit Saini