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());
}