cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to add a group of GCL approvers attached to a commodity to a list but it is giving an error.

Former Member
0 Kudos

Hi All,

I am new to Sourcing.

I have a userdefinedbizdoc1 which has a group of approvers attached with it. What I am trying is to add this group to a list but I am unable to do so. It is throwing error "Error executing script: Sourced file: inline evaluation of: ``import java.util.List; import com.sap.eso.api.rfx.RfxDocIBeanIfc; import com . . . '' : null."

Plz help how to get rid of this error.

Here is the code I am using

import java.util.List;

import com.sap.eso.api.rfx.RfxDocIBeanIfc;

import com.sap.odp.api.common.platform.IapiSessionContextIfc;

import com.sap.odp.api.common.types.ObjectReferenceIfc;

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

import com.sap.odp.api.ibean.ExtensionCollectionIfc;

import com.sap.odp.api.ibean.ExtensionCollectionMemberIfc;

import com.sap.odp.api.ibean.ExtensionFieldIfc;

import com.sap.odp.api.ibean.IBeanHomeLocator;

import com.sap.odp.api.ibean.OrderedSubordinateCollectionIfc;

import com.sap.odp.api.usermgmt.masterdata.GroupIBeanIfc;

    List listGcl= null;

   

    OrderedSubordinateCollectionIfc rfxCollaboratorCollection=(OrderedSubordinateCollectionIfc) doc.getCollaborators();

       

    ExtensionCollectionIfc commodityCollection=doc.getExtensionCollection("RR_COMMODITY_COL");//gets commodity collection

    if (commodityCollection==null||commodityCollection.size()==0)

    {

        doc.setDocumentDescription("commodityCollection null");//just to check whther working or not

    }

    for (int i=0;i<commodityCollection.size();i++)

    {

        ExtensionCollectionMemberIfc commodityCollMember=(ExtensionCollectionMemberIfc)commodityCollection.get(i);//gets every element

        ObjectReferenceIfc commodityFromRfx=(ObjectReferenceIfc)commodityCollMember.get("RR_INTERNAL_CAT");//gets object reference

        InternalCatIBeanIfc cmdy=(InternalCatIBeanIfc) IBeanHomeLocator.lookup(session,commodityFromRfx).find(commodityFromRfx);

        ExtensionFieldIfc gclExtension=cmdy.getExtensionField("RR_GCL");

        if (gclExtension.equals(null))   

            doc.setDocumentDescription("GCL null");

       

        ObjectReferenceIfc groupGcl=(ObjectReferenceIfc) gclExtension.get();//object reference of GCL

        if (!groupGcl.isSet())//if gcl is not referenced   

            doc.setDocumentDescription("groupGcl null");

       

        GroupIBeanIfc groupHomeBean=(GroupIBeanIfc) IBeanHomeLocator.lookup(session,groupGcl).find(groupGcl);//find gcl

        doc.setDocumentDescription("groupHomeBean"+groupHomeBean.getDisplayName());

      

        if(!listGcl.contains(groupHomeBean))

            listGcl.add(groupHomeBean);

       

           

    }

       

     I am getting error in last 2 lines. adding is not working. Don't know why.  

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kumud,

The null is because you have not instantiated listGcl yet.

Declared:

List listGcl= null;

Used:

if(!listGcl.contains(groupHomeBean))

No instantiation in between.

Regards,

Subhasini

Former Member
0 Kudos

Thanks Suhasini,

Is it necessary to instantiate? What if I use listGcl.add(groupHomeBean);

directly.

Why is it necessary to instantiate?

Please guide.

Regards,

Kumud

Former Member
0 Kudos

Hi Kumud,

Yes, every object in Java needs instantiation - this is when memory gets allocated for the object.

Regards,

Subhasini

Answers (0)