web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

X++ Get Created Production Order ID & Consolidated Batch Order ID While Firm & Consolidate a Planned Production Order

(0) ShareShare
ReportReport
Posted on by 1,214

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.

pastedimage1563850047706v1.png

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)
  • Suggested answer
    HAIRUL HAZRI Profile Picture
    1,214 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans