cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI Table Input not passing to R/3 Backend

Former Member
0 Kudos

Hello Experts,

I am having trouble populating a Table input in my Web Dynpro Java application. I have tried researching this issue on SDN and have attemped many of the solutions with no luck. Here is my code:

Bapi_Order_Input NewOrder = new Bapi_Order_Input();

wdContext.nodeBapi_Order_Input().bind(NewOrder);

Bapisdhd1 OrderHead = new Bapisdhd1(); - <i>(This is part of the Input Paramter, values are successfully passed)</i>

OrderHead.setDoc_Type("ZOR");

OrderHead.setSales_Org("2000");

OrderHead.setDistr_Chan("40");

NewOrder.setOrder_Header_In(OrderHead);

Bapiparnr Partner = new Bapiparnr(); - <i>(This is a table parameter, values are not being passed to the backend)</i>

Partner.setPartn_Role("SP");

Partner.setPartn_Numb("20010");

Partner.setItm_Number("000000");

NewOrder.addOrder_Partners(Partner);

wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();

I cannot use "NewOrder.setOrder_Partners(Partner)" because Order_Partners is an AbstactList. I have attempted to create this abstract list below but it will not syntactically check:

AbstractList PartnerList = new Bapiparnr.Bapiparnr_List();

If I test these same input values above in R/3, the BAPI executes fine. When I test the BAPI from WD, I get the return message " Please enter a Sold-To or ShipTo Party". I can replicate this same message in R/3 if I do not populate the Partner table.

I am also able to see the Partner values I enter when I create a Table is display them in Web Dynpro.

This is frusterating me a great deal and I would greatly appreciate, and rewards, any suggestions or recomendations.

Thank you for your help,

Matt

Former Member
0 Kudos

hi,

If you dont mind send me your node structure and datatypes once.

Such that we might conclude something.

Generally some where missing the some datatypes only.

Thanks,

kris

Message was edited by:

gopi krishna

Former Member
0 Kudos

Hi Everyone,

Well, I was finally able to resolve my issue. After debugging the Web Dynpro Application from the ECC BAPI side, I was able to see that the Partner values were failing to be passed to the back-end SAP system. After I restarted the J2EE engine, I was able to create the sales order.

I noticed a couple of interesting things as well:

-You need to fill in the leading zeros for Customer Number (KUNNR) before passing of this value

-The ECC BAPI automatically (atleast in my case) changed the input value of Partner-PartnerRole from "SP" to "AG". This change occurs before the first step in the Debugger is performed. This change, however, does not occur when the BAPI is called from Web Dynpro. Once I edited the Web Dynpro Partner Role input to "AG", I was able to create the sales order.

I have list my code below, thank you all for your help.

Regards,

Matt

Bapi_Salesorder_Createfromdat2_Input SO = new Bapi_Salesorder_Createfromdat2_Input();

Bapi_Transaction_Commit_Input Commit = new Bapi_Transaction_Commit_Input();

Bapisdhd1 OrderHeader = new Bapisdhd1();

OrderHeader.setSales_Off("0000");

OrderHeader.setDoc_Type("ZOR");

OrderHeader.setPo_Meth_S("CU01");

SO.setOrder_Header_In(OrderHeader);

Bapiparnr Partner = new Bapiparnr();

Bapiparnr.Bapiparnr_List PartnerList = new Bapiparnr.Bapiparnr_List();

Partner.setPartn_Numb(PartnerNumber);

Partner.setPartn_Role("AG");

PartnerList.addBapiparnr(Partner);

SO.setOrder_Partners(PartnerList);

int size = wdContext.nodeShoppingCart().size();

BigDecimal Qty;

Bapisditm.Bapisditm_List ItemsList = new Bapisditm.Bapisditm_List();

Bapisditm Items;

IPublicUserAccount.IShoppingCartElement CartItem = wdContext.currentShoppingCartElement();

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

Items = new Bapisditm();

Qty = new BigDecimal(BigInteger.ZERO);

CartItem = wdContext.nodeShoppingCart().getShoppingCartElementAt(i);

Qty = Qty.add(BigDecimal.valueOf(CartItem.getQuantity()));

Items.setTarget_Qty(Qty);

Items.setTarget_Qu("EA");

Items.setMaterial(CartItem.getMaterial_number());

ItemsList.add(Items);

}

SO.setOrder_Items_In(ItemsList);

wdContext.nodeBapi_Salesorder_Createfromdat2_Input().bind(SO);

wdContext.nodeBapi_Transaction_Commit_Input().bind(Commit);

}

catch(Exception ex) {

IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

msgMgr.reportException(ex.getLocalizedMessage()+ " Create SO Failed!", true);

}

try {

wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();

wdContext.currentBapi_Transaction_Commit_InputElement().modelObject().execute();

}

catch (Exception ex){

IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

msgMgr.reportException(ex.getLocalizedMessage()+ " Retrieve Cart Failed!", true);

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

As you are using wdcontext to execute the bapi.

Use context to fill the data.

I<partner>Element element1 = wdContext.create<partner>Element();

element1.setPartn_Role("SP");

element1.setPartn_Numb("20010");

element1.setItm_Number("000000");

wdContext.node<partner>.addElement(element1);

Then continue with code which executes the bapi.

Hope this helps.

Regards,

Nagaraju Donikena.

Former Member
0 Kudos

Hi Nagaraju,

Thank you for your reply. Unfortunately, I am still not able to pass the Partner values to the backend. I had to modify your code somewhat for it to syntactically check but this is what I tried:

Bapi_Salesorder_Createfromdat2_Input NewOrder = new Bapi_Salesorder_Createfromdat2_Input();

wdContext.nodeBapi_Salesorder_Createfromdat2_Input().bind(NewOrder);

Bapiparnr PartnerStructure = new Bapiparnr();

IPrivateTestSalesOrderView.IOrder_PartnersElement Partner

= wdContext.nodeOrder_Partners().<b>createOrder_PartnersElement(PartnerStructure);</b>

The "Create" method required Bapiparnr as an input

Partner.setPartn_Role("SP");

Partner.setPartn_Numb("20010");

Partner.setItm_Number("000000");

wdContext.nodeOrder_Partners().addElement(Partner);

OrderHead.setDoc_Type("ZOR");

OrderHead.setSales_Org("2000");

OrderHead.setDistr_Chan("40");

OrderHead.setDivision("10");

OrderHead.setSales_Off("1000");

OrderHead.setPo_Meth_S("CU01");

NewOrder.setOrder_Header_In(OrderHead);

wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();

Once again, I can see the Partner table being populated with a value in the Web Dynpro table before the BAPI is executed, but the value is failing to be passed to the backend.

Thanks

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Bapi_Order_Input NewOrder = new Bapi_Order_Input();

wdContext.nodeBapi_Order_Input().bind(NewOrder);

Bapisdhd1 OrderHead = new Bapisdhd1(); - (This is part of the Input Paramter, values are successfully passed)

OrderHead.setDoc_Type("ZOR");

OrderHead.setSales_Org("2000");

OrderHead.setDistr_Chan("40");

NewOrder.setOrder_Header_In(OrderHead);

Bapiparnr Partner = new Bapiparnr(); - (This is a table parameter, values are not being passed to the backend)

Partner.setPartn_Role("SP");

Partner.setPartn_Numb("20010");

Partner.setItm_Number("000000");

NewOrder.addOrder_Partners(Partner);

wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();

Here what u are doing create the instance for <b>Bapi_Order_Input</b> and bind the this instance only

and passi the input to this instance that is OK.

But execute mehtod u wrote for the Other BAPI <b>currentBapi_Salesorder_Createfromdat2</b> .

I think this may be the problem.

Crete the one BAPI instance and pass the input to that instance and execute that BAPI ONLY.

that might helps.

Bapi_Order_Input NewOrder = new Bapi_Order_Input();

wdContext.nodeBapi_Order_Input().bind(NewOrder);

Bapiparnr Partner = new Bapiparnr(); - (This is a table parameter, values are not being passed to the backend)

Partner.setPartn_Role("SP");

Partner.setPartn_Numb("20010");

Partner.setItm_Number("000000");

NewOrder.addOrder_Partners(Partner);

wdContext.Bapi_Order_Input Element().modelObject().execute();

and write the invalidate .

I think that this might be the procedure.

Thanks,

Lohi.

Former Member
0 Kudos

Hi Lohitha,

I believe I miss-typed my actual code. At the top of my original post, I thought I would simplify the BAPI name to "Bapi_Order_Input" from "Bapi_Salesorder_Createfromdat2_Input", therefore when I wrote:

Bapi_Order_Input NewOrder = new Bapi_Order_Input();...... I really meant:

Bapi_Salesorder_Createfromdat2_Input NewOrder = new Bapi_Salesorder_Createfromdat2_Input();

But as it turns out, towards the end of my post I reverted back to using my actualy code. Sorry for the confusion...

Thanks for your help. I am still getting the same issue and have listed my code in the replies above.

Thank you all for your help so far. I appreciate your suggestions.

Regards,

Matt

monalisa_biswal
Contributor
0 Kudos

Check size of table parameter before executing the model using following method.

wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().getOrder_Partners().size().

If size > 0 your data is successfully transmitted to BAPI.

Former Member
0 Kudos

Hi Monalisa,

Thank you for responding. I was not able to test the size of the node with code you gave due to a "java.lang.NullPointException". Here is what I tried:

Bapi_Salesorder_Createfromdat2_Input NewOrder = new Bapi_Salesorder_Createfromdat2_Input();

wdContext.nodeBapi_Salesorder_Createfromdat2_Input().bind(NewOrder);

Bapiparnr PartnerStructure = new Bapiparnr();

IPrivateTestSalesOrderView.IOrder_PartnersElement Partner

= wdContext.nodeOrder_Partners().createOrder_PartnersElement(PartnerStructure);

Partner.setPartn_Role("SP");

Partner.setPartn_Numb("20010");

Partner.setItm_Number("000000");

wdContext.nodeOrder_Partners().addElement(Partner);

OrderHead.setDoc_Type("ZOR");

OrderHead.setSales_Org("2000");

OrderHead.setDistr_Chan("40");

OrderHead.setDivision("10");

OrderHead.setSales_Off("1000");

OrderHead.setPo_Meth_S("CU01");

NewOrder.setOrder_Header_In(OrderHead);

i<b>nt size = wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().getOrder_Partners().size();

wdContext.currentContextElement().setPartnerSize("Size:" + String.valueOf(size));</b>

wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();

Former Member
0 Kudos

Hello Matt,

In your view please add this code at the appropriate locations:


Bapi_Salesorder_Createfromdat2_Input NewOrder = new Bapi_Salesorder_Createfromdat2_Input();

IPrivate<ViewName>.I<OutputRow>Element ele = wdContext.node<OutputRow>.create<OutputRow>ItemElement(NewOrder);

wdContext.node<OutputRow>.addElement(ele);

Replace <OutputRow> with the name of the model node that contains the individual attributes/fields you want to modify. You will find your equivalent of <OutputRow> inside the 'Output' model node-- it may be directly under it or be nestled a few model nodes deep.

In the code above, you can use the variable 'ele' to hold the values of the attributes/fields you want to modify. Since 'ele' refers to an object that corresponds to the structure of a row that you want to modify-- you can change the values of its constituents and in effect change the values of columns in a row.

It goes without saying that if you are working with the RFM 'Bapi_Salesorder_Createfromdat2' that you will need multiple variables doing what 'ele' does in this example to transfer values to the RFM in multiple structures.

Let me know if you require further assistance with this approach.

Hope this helps,

- Vik.