cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_MATERIAL_SAVEDATA Unable to create Material

Former Member
0 Kudos

Hi,

I am having problem creating the material using Web Dynpro Application.. I am using the BAPI_MATERIAL_SAVEDATA bapi to create the material. I was able to use the same BAPI and creat the material directly on the R/3 system.

With the same Input parameters (as used in the below code)I was able to create the material on the R/3 system.But when I tried the same using Web Dynpro application it gives me the following error.

Unit of measure ****** is not defined; check your entry

My Guess is that, While creating the material on R/3 system, for 'ClientDataX' we passed 'X' as the values for BASE_UOM and BASE_UOM_ISO. But from the Web Dynpro application, these two fields are listed as Boolean attributes.

Any Ideas Guys.

Below is the code that I have written to create the material.

//@@begin wdDoInit()

Bapi_Material_Savedata_Input input = new Bapi_Material_Savedata_Input();

wdContext.nodeBapi_Material_Savedata_Input().bind(input);

// Head Data

Bapimathead headData = new Bapimathead();

headData.setMaterial("TEST304");

headData.setInd_Sector("M");

headData.setMatl_Type("FERT");

input.setHeaddata(headData);

IPublicCreateMaterialComp.IHeaddataElement headDataElement = wdContext.createHeaddataElement(headData);

wdContext.nodeHeaddata().addElement(headDataElement);

// Client Data

Bapi_Mara clientData = new Bapi_Mara();

clientData.setBase_Uom("PGL");

clientData.setBase_Uom_Iso("PGL");

clientData.setMatl_Group("001");

clientData.setStd_Descr("Material Desc");

clientData.setTrans_Grp("0001");

input.setClientdata(clientData);

IPublicCreateMaterialComp.IClientdataElement clientDataElement = wdContext.createClientdataElement(clientData);

wdContext.nodeClientdata().addElement(clientDataElement);

// Client DataX

Bapi_Marax clientDatax = new Bapi_Marax();

clientDatax.setBase_Uom(true);

clientDatax.setBase_Uom_Iso(true);

clientDatax.setMatl_Group(true);

clientDatax.setStd_Descr(true);

clientDatax.setTrans_Grp(true);

input.setClientdatax(clientDatax);

IPublicCreateMaterialComp.IClientdataxElement clientDataxElement = wdContext.createClientdataxElement(clientDatax);

wdContext.nodeClientdatax().addElement(clientDataxElement);

// Plant Data

Bapi_Marc plantData = new Bapi_Marc();

plantData.setLoadinggrp("0001");

plantData.setLotsizekey("EX");

plantData.setMrp_Type("PD");

plantData.setMrp_Ctrler("001");

plantData.setPlant("1000");

plantData.setSm_Key("000");

plantData.setPur_Group("");

input.setPlantdata(plantData);

// Plant Data

Bapi_Marcx plantDatax = new Bapi_Marcx();

plantDatax.setPlant("1000");

input.setPlantdatax(plantDatax);

//Material Description - Table

Bapi_Makt materialDescription = new Bapi_Makt();

materialDescription.setLangu("EN");

materialDescription.setMatl_Desc("Material Desc");

input.addMaterialdescription(materialDescription);

// Material UOM - Table

Bapi_Marm unitOfMeasure = new Bapi_Marm();

unitOfMeasure.setAlt_Unit("PGL");

unitOfMeasure.setAlt_Unit_Iso("PGL");

input.addUnitsofmeasure(unitOfMeasure);

IPublicCreateMaterialComp.IUnitsofmeasureElement input1 = wdContext.createUnitsofmeasureElement(unitOfMeasure);

wdContext.nodeUnitsofmeasure().addElement(input1);

// Material UOMX - Table

Bapi_Marmx unitOfMeasurx = new Bapi_Marmx();

unitOfMeasurx.setAlt_Unit("PGL");

unitOfMeasurx.setAlt_Unit_Iso("PGL");

input.addUnitsofmeasurex(unitOfMeasurx);

IPublicCreateMaterialComp.IUnitsofmeasurexElement input2 = wdContext.createUnitsofmeasurexElement(unitOfMeasurx);

wdContext.nodeUnitsofmeasurex().addElement(input2);

try{

wdContext.currentBapi_Material_Savedata_InputElement().modelObject().execute ();

wdContext.nodeOutput ().invalidate();

}

catch(WDDynamicRFCExecuteException e){

msgMgr.reportSuccess(e.getMessage());

msgMgr.reportSuccess(e.toString());

}

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Guys,

Thanks for your suggestions and help. we got it resolved by changing the UOM parameters. The problem was with the langugae settings. The language that was used was German and we were passing the UOM values for English language. By changing UOM values corresponding to German values we got this working.

Thanks for all your help.

Former Member
0 Kudos

Guys,

Thanks for the Suggestions

The problems seems to be is in this peice code. While creating the material on R/3 system, for 'ClientDataX' we passed 'X' as the values for BASE_UOM and BASE_UOM_ISO. But from the Web Dynpro application, these two fields are listed as Boolean attributes.

// Client Data

Bapi_Mara clientData = new Bapi_Mara();

clientData.setBase_Uom("PGL");

clientData.setBase_Uom_Iso("PGL");

clientData.setMatl_Group("001");

clientData.setStd_Descr("Material Desc");

clientData.setTrans_Grp("0001");

input.setClientdata(clientData);

// Client DataX

Bapi_Marax clientDatax = new Bapi_Marax();

clientDatax.setBase_Uom(true);

clientDatax.setBase_Uom_Iso(true);

clientDatax.setMatl_Group(true);

clientDatax.setStd_Descr(true);

clientDatax.setTrans_Grp(true);

input.setClientdatax(clientDatax);

The Bapi is not able to identify the Unit of measure since we are passing the boolean values as input for ClientDataX.

Former Member
0 Kudos

Actually, WD Adaptive RFC Model correctly converts between boolean and CHAR(1) "X"/SPACE.

So it hardly to be the reason.

Try to debug your RFC calls.

See the following blog posts by <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=ep4f7oug4ay%3d">tarun Telang</a>:

/people/tarun.telang2/blog/2005/10/03/debugging-a-rfc-call-using-jco-api-part-2

/people/tarun.telang2/blog/2005/10/01/debugging-a-rfc-call-using-jco-api

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Hi,

Can you post your import params of BAPI.

What are the inputs your giving to the back end side also I mean your giving the data in R/3 execution.

input data types also.

Thanks

Lohi.

Former Member
0 Kudos

HI,

When you create BAPI you shuld declare only import and export params.

Only through that paramaters only get the value from R/3 and save the data to R/3.

Suppose your BAPI is

bapi :Z_Matnr.

After importing this u will get the Z_Matnr_Input

u can implement this code in your view.

In your View init method.u can write the code like this.

Z_Matnr_Input input = Z_Matnr_Input();

wdContext.node<Z_Matnr_Input>.bind(input);

Do u have any input params send here.

input.set<param>(1);

input.set<param1>(2);

Otherwise u do not have params.

wdContext.current< Z_Matnr_Input()>.modelObject().execute();

wdContext.node<OutPutNode>.invalidate();

This will help you.

U need to change your BAPI as per this.

For displaying data to view then your code is suitable.

IprivateView.INode().

Thanks

MNRAO.

roberto_tagliento
Active Contributor
0 Kudos

By the way pay the attention between, input and output nodes.

And between table and structure.

For structure don't do this instruction

IPublicCreateMaterialComp.IHeaddataElement headDataElement = wdContext.createHeaddataElement(headData);

wdContext.nodeHeaddata().addElement(headDataElement);

roberto_tagliento
Active Contributor
0 Kudos

Remove this instruction:

IPublicCreateMaterialComp.IHeaddataElement headDataElement = wdContext.createHeaddataElement(headData);

wdContext.nodeHeaddata().addElement(headDataElement);

IPublicCreateMaterialComp.IClientdataElement clientDataElement = wdContext.createClientdataElement(clientData);

wdContext.nodeClientdata().addElement(clientDataElement);

IPublicCreateMaterialComp.IClientdataxElement clientDataxElement = wdContext.createClientdataxElement(clientDatax);

wdContext.nodeClientdatax().addElement(clientDataxElement);

IPublicCreateMaterialComp.IUnitsofmeasureElement input1 = wdContext.createUnitsofmeasureElement(unitOfMeasure);

wdContext.nodeUnitsofmeasure().addElement(input1);

IPublicCreateMaterialComp.IUnitsofmeasurexElement input2 = wdContext.createUnitsofmeasurexElement(unitOfMeasurx);

wdContext.nodeUnitsofmeasurex().addElement(input2);

also other i missed, like this of above.

Must be not necessary.

Message was edited by: Roberto Tagliento

roberto_tagliento
Active Contributor
0 Kudos

I am trieng myself also.

EDIT

Cannot try , my SLD is bad configurated.

And cannot test,

Message was edited by: Roberto Tagliento