Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Issue with Create BAPI - Please help

I need to do a Create BAPI the structure is as follows:

-Orders

-Operations_create (Afvgd - BAPI table structure)

On a click of a InsertOperation button, I should be able to insert the line Items to the Operations_create node and then set them finally to the Model node. Then do the order create(Insert BAPI as a whole).

The problem is there is an already existing element (framework created). So if I do the following code in onActionInsertOperation. I am getting an extra duplicate record.

Is there a easy fix to this . I am not sure Supplyfunction will help here. If so, How?

Or Can I tweak the code here?

Thank you ... Any help is appreciated

View Controller:

onActionInsertOperation(){

IOperations_CreateElement oprEle = wdContext.createOperations_CreateElement();

oprEle .setGLAccount(wdContext.currentOperations_CreateElement().getGLAccount());

oprEle .setVendorNo(wdContext.currentOperations_CreateElement().getVendorNo());

wdContext.nodeOperations_Create().addElement(oprEle);

}

onActionCreateOrder(){

wdThis.wdGetVmrsCustController().callBapi_CreateOrder();

wdThis.wdGetVmrsCustController().callBapi_Commit();

}

Custom Controller:

callBapi_CreateOrder(){

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

Afvgd item = new Afvgd();

item.setGLAccount(wdThis.wdGetContext().nodeOperations_Create().getOperations_CreateElementAt(i).getGLAccount());

item.setVendor(wdThis.wdGetContext().nodeOperations_Create().getOperations_CreateElementAt(i).getVendorNo());

inputCreateOrder.addOperations(item) ;

}

// Executing the Model

// Invalidating ...

}

replied

Hi Vivek,

In your eventHandler check if your context node has a value for the first time?

Just do something like

  {
      IWDNode yourNode = wdContext.node<your node name>;
      if(yourNode.size != 0 && yourNode.size == 1){
         yourNode.removeElement((IWDNodeElement)yourNode.getElementAt(0));
      //Add now, but make sure you add some elements.
      }
   }

Hope this helps.

Regards,

Satyajit.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question