cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with multiple record inserts when creating a PR

Former Member
0 Kudos

Hi All,

I am creating a PR through WebDybPro form.

The user is allowed to select multiple items for a Material Group.

When I submit the request there are records inserted in the table EBAN. But all the records contain similar entry i.e. Material Item, Group, Qty etc remain same.

I am posting the entire code. Plz let me know what is wrong.

Bapi_Pr_Create_Input prCreateInput = new Bapi_Pr_Create_Input();

wdContext.nodeBapi_Pr_Create_Input().bind(prCreateInput);

Bapimereqheader headerInput = new Bapimereqheader();

Bapimereqheaderx headerInputX = new Bapimereqheaderx();

AbstractList prItemList = new Bapimereqitem.Bapimereqitem_List();

Bapimereqitemimp itemInput = new Bapimereqitemimp();

AbstractList prItemXList = new Bapimereqitemx.Bapimereqitemx_List();

Bapimereqitemx itemInputX = new Bapimereqitemx();

AbstractList prItemTextInput =

new Bapimereqitemtext.Bapimereqitemtext_List();

Bapimereqitemtext itemtextInput = new Bapimereqitemtext();

AbstractList prHeaderTextInput =

new Bapimereqheadtext.Bapimereqheadtext_List();

Bapimereqheadtext headtextInput = new Bapimereqheadtext();

/**

  • Determining the number of materials which have

  • been selected by the user.

*/

tableNodeSize = wdContext.nodeTableNode().size();

wdComponentAPI.getMessageManager().reportSuccess(

"AssetMgmtView::onActionSubmit::tableNodeSize " + tableNodeSize);

/**

  • Fetching Material Details selected by the user.

  • 1. Material Number

  • 2. Material Description

  • 3. Material Quantity

  • 4. Material Group

*/

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

materialNum =

wdContext.nodeTableNode().getElementAt(

i).getAttributeAsText(

"MatlNum");

materialDesc =

wdContext.nodeTableNode().getElementAt(

i).getAttributeAsText(

"MatlDesc");

materialQty =

wdContext.nodeTableNode().getElementAt(

i).getAttributeAsText(

"MatlQty");

materialGrp =

wdContext.nodeTableNode().getElementAt(

i).getAttributeAsText(

"MatlGrp");

wdComponentAPI.getMessageManager().reportSuccess(

"AssetMgmtView::onActionSubmit::materialNum " + materialNum);

wdComponentAPI.getMessageManager().reportSuccess(

"AssetMgmtView::onActionSubmit::materialDesc " + materialDesc);

wdComponentAPI.getMessageManager().reportSuccess(

"AssetMgmtView::onActionSubmit::materialQty " + materialQty);

wdComponentAPI.getMessageManager().reportSuccess(

"AssetMgmtView::onActionSubmit::materialGrp " + materialGrp);

itemInput.setAcctasscat(acctAssCat);

itemInput.setPreq_Name(preqName);

itemInput.setMaterial(materialNum);

itemInput.setPlant(plant);

itemInput.setPur_Group(purchaseGroup);

itemInput.setMatl_Group(materialGrp);

itemInput.setPurch_Org(purchaseOrg);

itemInput.setStore_Loc(storageLocation);

itemInput.setTrackingno(trackingNo);

itemInput.setPreq_Price(new BigDecimal(valuationPrice));

itemInput.setQuantity(new BigDecimal(materialQty));

prCreateInput.addPritem(itemInput);

itemInputX.setAcctasscat(true);

itemInputX.setPreq_Name(true);

itemInputX.setMaterial(true);

itemInputX.setPlant(true);

itemInputX.setPur_Group(true);

itemInputX.setMatl_Group(true);

itemInputX.setPurch_Org(true);

itemInputX.setStore_Loc(true);

itemInputX.setTrackingno(true);

itemInputX.setPreq_Price(true);

itemInputX.setQuantity(true);

prCreateInput.addPritemx(itemInputX);

itemInput = null;

itemInputX = null;

itemInput = new Bapimereqitemimp();

itemInputX = new Bapimereqitemx();

materialNum = "";

materialQty = "";

materialGrp = "";

}

itemtextInput.setText_Line(itemTextLine);

prCreateInput.addPritemtext(itemtextInput);

headerInput.setPr_Type(purchaseType);

headerInputX.setPr_Type(true);

headtextInput.setText_Line(headerTextLine);

prCreateInput.addPrheadertext(headtextInput);

prCreateInput.setPrheader(headerInput);

prCreateInput.setPrheaderx(headerInputX);

wdThis.wdGetPRCreateCustController().executeBapiPRCreate();

wdThis.wdGetPRCreateCustController().executeBapiCommit();

Regards

Nikhil Bansal

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

HI,

use external debuggin to chk if the values are being properly passed from dynpro into the bapi

sid_sunny
Contributor
0 Kudos

Hi Nikhil,

Try this code to read the data one by one from your table and create PR one by one for each of them.

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

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

IWDNodeElement node = wdContext.nodeTablesource().getElementAt(i);

wdComponentAPI.getMessageManager().reportSuccess(node.getAttributeAsText("tabletext"));

/**

  • call your bapi execution methods here

*/

}

Regards

Sid

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi Nikhil,

seems BAPIs are haunting you(just kidding)...

your code seems ok(i will again go through it) , tell me one thing , you are printing message everytime in loop, so all those time the material details are getting updated and hope yu are geting newly accessed material's desc from table.

I will say just have a check in you backend how data is getting populated in tables parameter when it reaches r3.

also i wont say to give bpi call in loop since these calls are considered very expensive and will affect the performance..

check out r3 and let me kno

regards

Former Member
0 Kudos

Hi Abhijeet,

Infact I have been haunting the BAPIs.

My problem is resolved. I was not passing the preq_item vaue. So the BAPI was taking the default (0000) value and inserting the all the records with this value itself.

I passed the preq_item values (10,20, 30 etc) and that was it.

Thanks again.

Regards

Nikhil Bansal