on 2015 Oct 06 7:22 PM
We have a requirement to fetch the Manager User from Cost Center object linked to a user account in one scenario. For this I am trying to develop a beanshell script. But in iAPI of user account, cost center group is not exposed. But in Summary view of User Account, I can see a Reference called "COST_CENTER_GROUP" which in turn has a collection "COLLN_COST_CENTERS". This collection references "COST_CENTER" and then "MANAGER_USER" object which I am interested in fetching.
But I am not able to figure out how to access COST_CENTER_GROUP from the useraccount object. Experts please help.
Request clarification before answering.
Hello Gayathri,
getFieldMetaData method can be used to access the standard fields from the class by using field id.
check the below code.
costCenterGroup = doc.getFieldMetadata("COST_CENTER_GROUP").get(doc);
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Rajshekhar.
getFieldMetaData returned an object of type com.sap.odp.common.db.ObjectReference with value same as the display name of the user.
So now I can get the display name of COST_CENTER_GROUP, but from this how can access the subordinate collection COLLN_COST_CENTERS?
Reference Guide shows this information for cost center group class:
ID: 631
Name: masterdata.CostCenterGrp
Display Name: My Cost Centers
but there is no iAPI exposed. Please suggest how to proceed.
Hi Raj,
Cost Center Bean iAPI is available (the same one in your image) but that is Class ID 626 masterdata.CostCenter. The reference included in UserAccount bean is that of Class ID 631 masterdata.CostCenterGrp. This Class 631 does not have iAPI exposed. It has a subordinate collection COLLN_COST_CENTERS which is a collection of objects of type masterdata.CostCenterSub (Class ID 633). Cost Center is a class member in this class.
So from useraccount bean I need to navigate to Classes 631 -> 633 -> 626.
When I tried to print out the class name of the object I got via doc.getFieldMetadata("COST_CENTER_GROUP").get(doc), it showed com.sap.odp.common.db.ObjectReference.
Not sure how to proceed from here to get the subordinate collection and the cost center object in the first row of that collection. Please help.
- Gayathri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.