
Hi,
When firm and consolidate a planned production order, I'd like to get the created production order IDs & consolidated batch order ID, and then insert these values into a custom table for reporting purposes.
On the Firm button in PmfBulkPlanConsolidate form, it triggers run method in PmfBulkPlanFirm class, with following codes:
/// <summary>
/// This method runs thru the marked consolidated orders
/// adjusting qtys and firming the planned orders
/// </summary>
public void run()
{
PmfConsOrd consOrd;
ReqTransPoMarkFirm poFirm;
ReqTrans reqTrans, reqTransPo;
ReqPO reqPO;
mapReqPoDeleted = new Map(new DictField(tablenum(ReqTrans),fieldnum(ReqTrans, RecId)).baseType(), Types::Record);
try
{
ttsbegin;
while select tmpConsOrd
where tmpConsOrd.ReqTransMark
{
// Firm all bulk orders
mapReqTrans = new Map(Types::Integer,Types::Record);
while select tmpConsBulk
where tmpConsBulk.ConsOrdId == tmpConsOrd.ConsOrdId
{
reqTrans = ReqTrans::findRecId(tmpConsBulk.ReqTransRecId);
reqPO = reqTrans.reqPo(true);
reqPO.Qty = tmpConsBulk.Qty;
reqPO.PurchQty = tmpConsBulk.Qty;
reqPO.PmfBulkOrd = true;
reqPO.update();
reqTransPo = reqPO.reqTrans();
mapReqTrans.insert(reqTransPo.RecId, reqTransPo);
}
poFirm = ReqTransPOMarkFirm::newMap(mapReqTrans);
poFirm.parmPmfConsOrdId(tmpConsOrd.ConsOrdId);
poFirm.run();
this.updateMap(poFirm.packReqPoDeleted());
// Firm all packed orders
mapReqTrans = new Map(Types::Integer,Types::Record);
while select tmpConsPack
where tmpConsPack.ConsOrdId == tmpConsOrd.ConsOrdId
{
reqTrans = ReqTrans::findRecId(tmpConsPack.ReqTransRecId);
reqPO = reqTrans.reqPo(true);
reqPO.Qty = tmpConsPack.Qty;
reqPO.PurchQty = tmpConsPack.Qty;
reqPO.PmfBulkOrd = false;
reqPO.update(null,null,'',true);
reqTransPo = reqPO.reqTrans();
mapReqTrans.insert(reqTransPo.RecId, reqTransPo);
}
poFirm = ReqTransPoMarkFirm::newMap(mapReqTrans);
poFirm.parmPmfConsOrdId(tmpConsOrd.ConsOrdId);
poFirm.run();
this.updateMap(poFirm.packReqPoDeleted());
// Create the consolidated order
consOrd.ConsOrdId = tmpConsOrd.ConsOrdId;
consOrd.ItemName = tmpConsOrd.ItemName;
consOrd.ConsQty = tmpConsOrd.ConsQty;
consOrd.bomUnitId = tmpConsOrd.bomUnitId;
consOrd.ReqDateOrder = tmpConsOrd.ReqDateOrder;
consOrd.ReqDateDlv = tmpConsOrd.ReqDateDlv;
consOrd.ReqTime = tmpConsOrd.ReqTime;
consOrd.ReqTimeOrder = tmpConsOrd.ReqTimeOrder;
consOrd.insert();
}
// Clean up the temporary order records that was firmed
delete_from tmpConsOrd
where tmpConsOrd.ReqTransMark;
ttscommit;
}
catch (Exception::Error)
{
ttsabort;
infolog.view();
}
}
There's the code creating consolidated batch order, and it ends there.
I'm looking for the code that creates Production orders but couldn't find it anywhere in any class.
I figured it should be in init* methods inside ProdTable but still no luck.
Where else can I look?
Thank you.
*This post is locked for comments
I have the same question (0)In ReqTransPoMarkFirm class there's a method called createProdTable().
After analysing the class, I added my custom codes in the end of firmSelectedPlannedOrders() method.
This solves my problem, for now.