Skip to Content
avatar image
Former Member

How to call a BAPI that takes a table parameter

Hi,

I have a BAPI ZHRECMFM_002_PERFRAT_WARNING that has two table parameter one is PERNR_LIST of type HROBJECT and another one is PERNR_PERFRAT of type ZHRECMGLS_002_PERNR_PERFRAT that consists of two elements pernr and perf_text.

I need to set PERNR_LIST(set of pernrs) in my WDA and call the BAPI.that BAPI will return PERNR_PERFRAT table parameter.

1.How will I pass PERNR_LIST(that consists of multiple HROBJECTS) to the BAPI.

2.After executing the BAPI How will I iterate thru PERNR_PERFRAT to get pernr and corresponding perf_text.

I tried to set PERNR_LIST using the following way suggested SivaRama Krushna

IPrivate<viewname>.I<nodeame>Node prNode = wdContext.node<node>();

IPrivate<viewname>.I<nodeame>Element prEle;

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

HROBJECT pernrList = new HROBJECT();

pernrList.setPernr(pernr); // Set the pernr from current record

prEle = prNode.create<nodeame>Element(pernrList);

prNode.addElement(prEle);

}

My code

IPrivateVEcmPlanningView.IPERFWARNNode prNode = wdContext.nodePERFWARN();

IPrivateVEcmPlanningView.IPERFWARNElement prEle ;

Hrobject pernrList = new Hrobject();

pernrList.setPlvar("01");

pernrList.setOtype("NA");

pernrList.setObjid(pernr);

prEle= prNode.createPERFWARNElement(pernrList);

prNode.addElement(prEle);

Type Mismarch:cannot convert IWDNodeElement to IPrivate<viewname>.I<nodeame>Element.

Please help me in resolving this issue

Thanks

Bala Duvvuri

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 11, 2008 at 04:02 PM

    Hi Bala,

    You did not provide the node(table) name that you created for PERNR_LIST. Try this out in your Planning VAC of MSS ECM DC:

    // you need to create reference to the PERNR_LIST node 
    // I am assuming the node name is PERNR_LIST
    IPrivateVEcmPlanningView.IPERNR_LISTNode prNode = wdContext.nodePERNR_LIST();
    // you need to create element of the type PERNR_LIST node 
    IPrivateVEcmPlanningView.IPERNR_LISTElement prEle ;
    Hrobject pernrList = new Hrobject();
    pernrList.setPlvar("01");
    pernrList.setOtype("NA");
    pernrList.setObjid(pernr);
    prEle= prNode.createPERNR_LISTElement(pernrList);
    prNode.addElement(prEle);

    Regards,

    Siva

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      hi,

      a little off topic here, but i have an SAP note that wants me to make some changes to VEcmPlanningComp but I dont know where or what tool to use to make the code changes? Can anyone help.

      note is 1288670

      thanks

      brad

  • avatar image
    Former Member
    Sep 11, 2008 at 02:39 AM

    Hi Bala,

    In your code

    prEle= prNode.createPERFWARNElement(pernrList);
    prNode.addElement(prEle);

    Can you please try like this?

    prEle= wdContext.createPERFWARNElement(pernrList);
    prNode.addElement(prEle);

    I will explain the difference

    If you want get the reference of the node element that already exist then we use this coding

    //prEle= prNode.getPERFWARNElementAt(i);

    now in prEle you have (i+1) record of PERNR_LIST.

    Hope you understand.

    Regards,

    Siva

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      HI Bala,

      I am not sure of the node structure but here is an example for you

      Parent Node :- ParentNode

      tables:- table1,table2

      table 1 and table2 are the other two node which ar eof type table

      you can try this

      Parent p=new parent().

      table1 t1= new table1(p); //if required pass p

      t1.set<>;

      ....

      table2 t2=new table2(p);

      t2.set<>.....

      p.settable1(t1);

      p.settable2(t2);

      wdContext.nodeParent.bind(p);

      regards

      Pankaj Prasoon