Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

bulk PO creation

Posted on by 425

Hi All,

I am creating a PO with 90 k lines and it is taking huge time in hours  any thing we can do to reduce the time .

purchTablePartner = InvoiceBatchXML::createPurchaseOrder(poHeaderSummaryInvIB);
InvoiceBatchXML::createPurchaseOrderLines(purchTablePartner,invoiceNumberSummary,InventDim.inventDimId);

public static server PurchTable createPurchaseOrder(SummaryInvoice poHeaderSummaryInvIB)
{
PurchTable purchTablePartner;
AxPurchTable axPurchTable;

purchTablePartner.clear();
purchTablePartner.initFromVendTable(VendTable::find(InvoiceBatchXML::getVendorAccountNum(poHeaderSummaryInvIB.OVTIDSupplier)));

axPurchTable = axPurchTable::newPurchTable(purchTablePartner);
axPurchTable.parmPurchId(NumberSeq::newGetNum(PurchParameters::numRefPurchId()).num());
axPurchTable.parmPurchaseType(PurchaseType::Purch);
axPurchTable.parmRAXShipmentType(ShipmentType::None);
axPurchTable.parmDocumentStatus(DocumentStatus::PurchaseOrder);
axPurchTable.parmAccountingDate(today());
axPurchTable.parmDeliveryDate(InvoiceBatchXML::getMinimumDeliveryDate(poHeaderSummaryInvIB));
axPurchTable.parmPurchStatus(PurchStatus::Backorder);
axPurchTable.save();

return purchTablePartner;
}

public static server void createPurchaseOrderLines(PurchTable _purchTable,string20 _invoiceNumber, inventDimId _inventDimId)
{
PurchLine purchLinePartner;
AxPurchLine axPurchLine;
SON_AttachmentELMOInvoice SON_AttachmentELMOInvoiceloc;
InventTable inventTable;


while select DeliveryNote,EANCode,ItemId,DeliveryDate,ItemId,InvoicedQty,VendorInvoiceAmt from Invoiceloc
where Invoiceloc.SummaryInvoiceNumber == _invoiceNumber

{
purchLinePartner.clear();
purchLinePartner.initFromPurchTable(_purchTable);
purchLinePartner.initFromInventTable(InventTable::find(Invoiceloc.ItemId));
axPurchLine = AxPurchLine::newPurchLine(purchLinePartner);
axpurchLine.parmDeliveryDate(SON_AttachmentELMOInvoiceloc.DeliveryDate);
axPurchLine.parmPurchQty(SON_AttachmentELMOInvoiceloc.InvoicedQty);
axPurchLine.parmLineAmount(round(SON_AttachmentELMOInvoiceloc.VendorInvoiceAmt,0.01));
axPurchLine.parmInventDimId(_inventDimId);

select firstonly DefaultDimension from inventTable
index hint ItemIdx
where inventTable.ItemId == SON_AttachmentELMOInvoiceloc.ItemId;

axPurchLine.parmDefaultDimension(SON_ELMOInvoiceBatchXML::PurchLineDefaultDimension(_purchTable.DefaultDimension, inventTable.DefaultDimension));
axPurchLine.save();
}
}

any idea what thing i can do extra to make it fast???

*This post is locked for comments

  • Suggested answer
    Mohammed Khatib Profile Picture
    Mohammed Khatib 430 on at
    RE: bulk PO creation

    If the source of your data is XML file only, I would suggest that you upload the data into a staging table, then process the records to the target tables (Purchase order & Purchase lines) - You can use DIEF for this purpose or custom your own staging tables.

    I agree with André , dividing the 90K lines into smaller batches of data (5K lines) at a time and running the import process in batch job would be better.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: bulk PO creation

    Hi Rohit1900,

    Check if there is a correct index on the field SummaryInvoiceNumber on the table "Invoiceloc". What caching method did you select on this table?

    Are you running the process on the client or in the background using the batch framework? I would suggest to used the batch framework and the Business Operations Framework. community.dynamics.com/.../business-operation-framework-bof-ax-2012

    You can also try to split the lines into smaller batch tasks to do parallel processing on inserts. The worlkflow message processing job is having an example how to split the tasks.

    In addition, you can try to optimize inserts using the next page: docs.microsoft.com/.../optimizing-record-inserts

  • rohit1900 Profile Picture
    rohit1900 425 on at
    RE: bulk PO creation

    Actually my client wants a single PO with all the  lines  and we cannot spilt PO we are reading 90 k lines from the  XML and creating a single PO for XML with 90 K lines.

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,647 Moderator on at
    RE: bulk PO creation

    Why you are creating such a huge PO ? Cant you spilt it up in multiple PO's ? From where are you reading these lines ?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans