Dieser Beitrag bezieht sich auf die Version:
Dynamics AX 2012
Dynamics AX 2012
Excellent advice. Thank you! I'm creating BOM's from xml file, so this was helpful. |
|
|
|
|
|
|
Dieser Beitrag bezieht sich auf die Version:
Dynamics AX 2012
|
Mit dem folgenden Code kann man eine Stückliste inkl. Stücklistenversion per Code erstellen.
{
AxBOMTable axBOMTable;
AxBOMVersion axBOMVersion;
AxBOM axBOM;
InventTable inventTable = InventTable::find("100160");
InventDim inventDim;
try
{
ttsbegin;
// BOM Table
axBOMTable = AxBOMTable::construct();
axBOMTable.validateInput(true);
axBOMTable.continueOnError(false);
axBomTable.parmBOMId(BOMTable::numberSeq().num());
axBOMTable.parmItemGroupId(inventTable.itemGroupId());
axBOMTable.parmApprover(HcmWorker::userId2Worker(curUserId()));
axBOMTable.parmApproved(NoYes::Yes);
axBOMTable.parmName("Name of BOM");
axBOMTable.parmSiteId("GF");
axBOMTable.save();
// BOM Version
inventDim.clear();
inventDim.InventSiteId = axBOMTable.parmSiteId();
inventDim = InventDim::findOrCreate(inventDim);
axBOMVersion = AxBOMVersion::construct();
axBOMVersion.validateInput(true);
axBOMVersion.continueOnError(false);
axBOMVersion.parmBOMId(axBOMTable.parmBOMId());
axBOMVersion.parmItemId(inventTable.ItemId);
axBOMVersion.parmApprover(HcmWorker::userId2Worker(curUserId()));
axBOMVersion.parmApproved(NoYes::Yes);
axBOMVersion.parmActive(NoYes::Yes);
axBOMVersion.parmInventDimId(inventDim.InventDimId);
axBOMVersion.save();
// BOM
inventDim.clear();
inventDim.InventSiteId = axBOMTable.parmSiteId();
inventDim.ConfigId = "RoundNeck";
inventDim.InventSizeId = "XS";
inventDim.InventStyleId = "SlimFit";
inventDim.InventColorId = "Blue";
inventDim.InventLocationId = "902";
inventDim = InventDim::findOrCreate(inventDim);
axBOM = AxBOM::construct();
axBOM.validateInput(true);
axBOM.continueOnError(false);
axBOM.parmBOMId(axBOMTable.parmBOMId());
axBOM.parmItemId("100158");
axBOM.parmInventDimId(inventDim.InventDimId);
axBOM.parmBOMQty(17);
axBOM.save();
ttscommit;
}
catch
{
throw error("BOM creation failed");
}
}