Skip to Content
avatar image
Former Member

Working with Value Lists when creating scripts

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 01, 2012 at 04:13 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 07, 2015 at 12:44 PM

    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

    Add comment
    10|10000 characters needed characters exceeded