cancel
Showing results for 
Search instead for 
Did you mean: 

Working with Value Lists when creating scripts

Former Member
0 Kudos

Hi All,

I am creating a script and have run into some issues where I am working with value lists. I have been attempting to use the help provided by Saloni in the thread http://scn.sap.com/thread/3218997 however I am not able to get my script working.

Is the correct way to work with value lists in a script done as follows:

Get from a value list:

If we have a value list extension field called client_sensitive that contains a drop down of Yes or No then use

if(doc.getExtensionField(“client_sensitive”).getDisplayName().equals(“Yes”))

{

//do something

}

Set a value list field:

If we have a value list extension field called risk_tier that is linked to a value list called project_risk that contains low/medium/high then use

import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeIfc.*;

import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanIfc.*;

import com.sap.odp.api.doccommon.masterdata.ValueListTypeIBeanHomeIfc.*;

import com.sap.odp.api.doccommon.masterdata.ValueListTypeIBeanIfc.*;

vlvHome=IBeanHomeLocator.lookup(session,ValueListTypeIBeanHomeIfc.sHOME_NAME);

vlvBean=vlvHome.findByExternalId("project_risk");

valueBean=vlvBean.getCollnValueListValue().get(0);

// 0 is used here to set the field as the first entry in the value list

doc.getExtensionField("risk_tier").set(valueBean.getLocalizedObjectReference());

Currently I am getting an error of Class or variable not found: ValueListTypeIBeanHomeIfc.sHOME_NAME when I try to use this.

Any help with this would be greatly appreciated.

Many thanks

Dan

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Dan,

You could use the findUniqueByNameType method on the ValueListValueIBeanHomeIfc. Script would look something like this…

vlvHome = IBeanHomeLocator.lookup(session, ValueListValueIBeanHomeIfc.sHOME_NAME);

certTypeVlvBean = vlvHome.findUniqueByNameType("Certification", 10007);

Here 10007 is the ID of the value list type.

Hope this helps.

Regards,

Vikram

Former Member
0 Kudos

Hi Vikram,

Thank you for your help with this.

In my script I have:

import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeIfc.*;

import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanIfc.*;

import com.sap.odp.api.doccommon.masterdata.ValueListTypeIBeanHomeIfc.*;

import com.sap.odp.api.doccommon.masterdata.ValueListTypeIBeanIfc.*;

vlvHome=IBeanHomeLocator.lookup(session,ValueListValueIBeanHomeIfc.sHOME_NAME);

However I am receiving the error: Class or variable not found: ValueListTypeIBeanHomeIfc.sHOME_NAME

Is there something else I should be importing so that this is found?

Many thanks

Dan


0 Kudos

Hi Dan,

The problem seems to be in the import statement.

It should look like below, without the .* at the end.

import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeIfc;

import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanIfc;

Hope this helps.

Regards,

Vikram

Former Member
0 Kudos

Hi Vikram,

This is now working, thank you for your help with it.

Thanks

Dan

Answers (1)

Answers (1)

Former Member
0 Kudos

hi daniel

i use your code:


ValueListTypeIBeanHomeIfc vlvHome=IBeanHomeLocator.lookup(session,ValueListTypeIBeanHomeIfc.sHOME_NAME);

ValueListTypeIBeanIfc vlvBean=vlvHome.findByExternalId("WFL Section Validation");

ValueListValueIBeanIfc vlvValue = vlvBean.getCollnValueListValue().get(1);

LocalizedObjectReferenceIfc vlvObjRef = vlvValue.getLocalizedObjectReference();

logInfo("value: " + vlvValue.toString());

logInfo("value ref: " + vlvObjRef.toString());

// 1 is used here to set the field to tehe value "no"

doc.getExtensionField("ZCLM_WFL_001").set(vlvObjRef);

after executing this the field is set to "Select...".

i get no errors.

the vlvObjRef.toString() show me the correct value: -2147482215:616:No

               so i have no clue what i'm doing wrong...

can you help me with this?

thank you

Waldemar