Skip to Content
avatar image
Former Member

Executing BAPI Multiple Times

Hello Everyone,

I am trying to execute BAPI_ACC_DOCUMENT_POST multiple times in an application. My requirement is to post multiple documents in one click. The Context is as follows.

--Context

-


BAPI_ACC_DOCUMENT_POST(model node)---cardinality(0..1)

-


Accountgl(model node)---cardinality(0..n)

-


AccountPayable(model node)---cardinality(0..n)

-


Currencyamount(model node)---cardinality(0..n)

-


DocumentHeader(model node)---cardinality(0..1)

-


Output(model node)---cardinality(0..1)

-


-Document(Value Node) -cardinality(0..n)

I have create the Value node Document and I am trying to get few values from the user and assigning it to the model nodes during runtime. The BAPI should execute depending on the number of rows in the Document Table that the user decides at the runtime.

Could anyone give me some basic idea about how to acheive this requirement. I hope you can understand my requirement and please do let me know if you need any further explanation. I would greatly appreciate your help.

Regards,

Gopal.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Aug 27, 2009 at 02:35 PM

    Hi Gopal,

    As per my understanding -Document(Value Node) size will decide the BAPI calls.

    Then try this out:

    for (int i=0; i<wdContext.nodeDocument().size();i++)
    {
    //access value node attribute here and set them to model e.g.
    // declare model node element use setter methods
    wdContext.nodeDocument().getDocumentElementAt(i).get<attributename>();
    // like get all attribute and set 
    
    // execute BAPI here
    }

    Let me know if you are not clear yet.

    Regards,

    Siva

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Siva,

      My issue is resolved by using the following code.

      public void onActionPostDocument(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

      {

      //@@begin onActionPostDocument(ServerEvent)

      //$$begin ActionButton(-761385096)

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

      wdContext.currentDocumentheaderElement().setHeader_Txt(wdContext.nodeDocument().getDocumentElementAt(i).getHeader_Txt());

      wdContext.currentDocumentheaderElement().setRef_Doc_No(wdContext.nodeDocument().getDocumentElementAt(i).getRef_Doc_No()); wdContext.currentAccountglElement().setGl_Account(wdContext.nodeDocument().getDocumentElementAt(i).getGl_Account());

      wdContext.currentAccountglElement().setCostcenter(wdContext.nodeDocument().getDocumentElementAt(i).getCostcenter());

      wdContext.currentAccountpayableElement().setVendor_No(wdContext.nodeDocument().getDocumentElementAt(i).getVendor_No());

      wdContext.nodeCurrencyamount().setLeadSelection(0);

      wdContext.currentCurrencyamountElement().setAmt_Doccur(wdContext.nodeDocument().getDocumentElementAt(i).getAmt_Doccur().negate());

      wdContext.currentCurrencyamountElement().setItemno_Acc("0000000001");

      wdContext.nodeCurrencyamount().setLeadSelection(1);

      wdContext.currentCurrencyamountElement().setAmt_Doccur(wdContext.nodeDocument().getDocumentElementAt(i).getAmt_Doccur());

      wdContext.currentCurrencyamountElement().setItemno_Acc("0000000002");

      wdThis.wdGetMultipleDocCompController().executeBapi_Acc_Document_Post_Input();

      }

      Thanks a lot for your help.

      Regards,

      Gopal.