Dear all,
I code to create the purchase order direct delivery from sales order by reading parameter from CSV file and create purchase order X++.
But when I set the purchase price for Price line in the Purchase order line from the CSV file, but it does not work.
It's always getting purchase price from the item master(Released product master >> Purchase tab >> Price).
Please advise me how to update source code to get Price from CSV file?
PurchAutoCreate purchAutoCreate; TmpPurchLinePrice tplP; VendAccount prevVendAccount; SalesTable salesTableLocal; SalesLine salesLineLocal; InventTable inventTable; LineNum lineNumber = 0; PurchCreateFromSalesOrder purchCreateFromSalesOrder; ; try { ttsbegin; while select salesLineLocal order by inventTable.PrimaryVendorId where salesLineLocal.SalesId == ‘00018_036’ join inventTable where inventTable.ItemId == salesLineLocal.ItemId { if (prevVendAccount && prevVendAccount != inventTable.PrimaryVendorId) { purchAutoCreate = PurchAutoCreate::construct(tplP, purchCreateFromSalesOrder); purchAutoCreate.create(); delete_from tplP; lineNumber = 0; } salesTableLocal = salesLineLocal.salesTable(); purchCreateFromSalesOrder = PurchCreateFromSalesOrder::construct(); purchCreateFromSalesOrder.callerRecord(salesTableLocal); tplP.clear(); lineNumber += 1; tplP.SalesId = #fromCSV; tplP.LineNum = #fromCSV; tplP.SalesLineRefRecId = salesLineLocal.RecId; tplP.AccountNum = #fromCSV; tplP.ItemId = #fromCSV tplP.InventDimId = salesLineLocal.InventDimId; tplP.Included = NoYes::Yes; tplP.PurchQty = #fromCSV tplP.QtyOrdered = #fromCSV tplP.PurchUnit = salesLineLocal.SalesUnit; tplP.LineAmount = ???; tplP.LineDisc = salesLineLocal.LineDisc; tplP.LinePercent = salesLineLocal.LinePercent; tplP.MultiLineDisc = salesLineLocal.MultiLnDisc; tplP.MultiLinePercent = salesLineLocal.MultiLnPercent; tplP.Price = #fromCSV; tplP.PriceUnit = salesLineLocal.PriceUnit; tplP.CurrencyCode = #fromCSV; tplP.Markup = salesLineLocal.SalesMarkup; tplP.insert(); prevVendAccount = tplP.AccountNum; } if (prevVendAccount) { purchAutoCreate = PurchAutoCreate::construct(tplP, purchCreateFromSalesOrder); purchAutoCreate.create(); } ttscommit; } catch (Exception::Error) { ttsabort; } }
Thanks in advance!!!
*This post is locked for comments
Dear Ludwig,
Thank you for your response.
I received a request from end-user.
When they create direct delivery from sales order. they must be select line by line to create PO(direct delivery).
So they want to import the list of sales order and create direct delivery automatically base on CSV file contains.
Best regards,
Kaneko
Hello Sacramento,
I cannot help you with your code but wonder why you want to create purchase orders from a CSV file?
On first sight this sounds strange especially when you deal with mass data (POs, vendors, items, etc.)
Why is it that you need to do that?
Best regards,
Ludwig
Hi,
I think you should use PurchAutoCreate_Sales instead of PurchAutoCreate
if you look into PurchAutoCreate_Sales.CreateLine(), you will see pricing logic there (to get the price from tmpPurchLinePrice)
Cheers
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156