cancel
Showing results for 
Search instead for 
Did you mean: 

Executing BAPI Multiple Times

Former Member
0 Kudos
163

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Siva,

Thanks a lot for you reply. My code is as follows.

I have no problem assigining the values from Document node to the other model nodes apart from the "Currencyamount" table.

I have to take a value from the "Amount" field of the Document table and assign it to two different rows in the "Currencyamount" table. For Eg:-

Document Table

row 1----


Amount = 100 (this is bigdeciaml value)

Now I have to take this amount value and add it in two rows of the currencyamount table like:-

Currencyamount table

row1----


Amount =-100

row2----


Amount = 100

Can you help me with some code to do this. I hope you can understand my requirement . Please do, let me know if you dont undestand my requirement, I will try to explain in more detail.

Thanks a lot for your help.

Regards,

Gopal.

Former Member
0 Kudos

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.

Answers (0)