Using non-stock items in the daily business can be handled in Dynamics AX 2012 by using Direct delivery.
You can use the Button "Direct delivery" from a sales order you have created, to create a matching purchase order.
However if you use the Name field on the salesline to describe the specifications of the item you want to the vendor, the standard functionality does create the matching purchase order lines so that the name of the originating sales line is also used on the sales lines.
Direct deliveries are handled so that the inventory transactions of the salesline are marked against the purchline, so I wrote this small script to be able to get the hang of how to find the direct delivery purchaselines from the saleslines records of a sales order.
static void Job235(Args _args)
{
SalesLine salesLine;
PurchLine purchLine;
InventTransOriginSalesLine itosl;
InventTransOriginPurchLine itopl;
InventTrans it,it1;
InventTable iTbl;
InventHandlingGroup ihg;
ttsBegin;
while select salesLine
where salesLine.SalesId == "1001135"
join itosl
where itosl.SalesLineDataAreaId == salesLine.dataAreaId
&& itosl.SalesLineInventTransId == salesLine.InventTransId
join it
where it.InventTransOrigin == itosl.InventTransOrigin
join it1
where it1.InventTransOrigin == it.MarkingRefInventTransOrigin
join itopl
where itopl.PurchLineDataAreaId == it1.dataAreaId
&& itopl.InventTransOrigin == it1.InventTransOrigin
join forupdate purchLine
where purchLine.dataAreaId == itopl.PurchLineDataAreaId
&& purchLine.InventTransId == itopl.PurchLineInventTransId
&& purchLine.Name != salesLine.name
join itbl
where itbl.itemid == salesLine.ItemId
{
info("***** FØR ********");
info(strFmt("Salg: %1 %2 %3 %4",salesLine.SalesId,salesLine.ItemId,salesLine.LineNumber,salesLine.name));
info(strFmt("Indkøb: %1 %2 %3 %4",purchLine.purchid,purchLine.ItemId,purchLine.LineNumber,purchLine.name));
purchLine.Name = salesLine.Name;
purchLine.doUpdate();
info("***** EFTER ********");
info(strFmt("Salg: %1 %2 %3 %4",salesLine.SalesId,salesLine.ItemId,salesLine.LineNumber,salesLine.name));
info(strFmt("Indkøb: %1 %2 %3 %4",purchLine.purchid,purchLine.ItemId,purchLine.LineNumber,purchLine.name));
}
ttsCommit;
}
With this code at hand I could continue to customize the PurchAutoCreate_Sales class to sync the names of the salesLines to the purchLines.
You can use the Button "Direct delivery" from a sales order you have created, to create a matching purchase order.
However if you use the Name field on the salesline to describe the specifications of the item you want to the vendor, the standard functionality does create the matching purchase order lines so that the name of the originating sales line is also used on the sales lines.
Direct deliveries are handled so that the inventory transactions of the salesline are marked against the purchline, so I wrote this small script to be able to get the hang of how to find the direct delivery purchaselines from the saleslines records of a sales order.
static void Job235(Args _args)
{
SalesLine salesLine;
PurchLine purchLine;
InventTransOriginSalesLine itosl;
InventTransOriginPurchLine itopl;
InventTrans it,it1;
InventTable iTbl;
InventHandlingGroup ihg;
ttsBegin;
while select salesLine
where salesLine.SalesId == "1001135"
join itosl
where itosl.SalesLineDataAreaId == salesLine.dataAreaId
&& itosl.SalesLineInventTransId == salesLine.InventTransId
join it
where it.InventTransOrigin == itosl.InventTransOrigin
join it1
where it1.InventTransOrigin == it.MarkingRefInventTransOrigin
join itopl
where itopl.PurchLineDataAreaId == it1.dataAreaId
&& itopl.InventTransOrigin == it1.InventTransOrigin
join forupdate purchLine
where purchLine.dataAreaId == itopl.PurchLineDataAreaId
&& purchLine.InventTransId == itopl.PurchLineInventTransId
&& purchLine.Name != salesLine.name
join itbl
where itbl.itemid == salesLine.ItemId
{
info("***** FØR ********");
info(strFmt("Salg: %1 %2 %3 %4",salesLine.SalesId,salesLine.ItemId,salesLine.LineNumber,salesLine.name));
info(strFmt("Indkøb: %1 %2 %3 %4",purchLine.purchid,purchLine.ItemId,purchLine.LineNumber,purchLine.name));
purchLine.Name = salesLine.Name;
purchLine.doUpdate();
info("***** EFTER ********");
info(strFmt("Salg: %1 %2 %3 %4",salesLine.SalesId,salesLine.ItemId,salesLine.LineNumber,salesLine.name));
info(strFmt("Indkøb: %1 %2 %3 %4",purchLine.purchid,purchLine.ItemId,purchLine.LineNumber,purchLine.name));
}
ttsCommit;
}
With this code at hand I could continue to customize the PurchAutoCreate_Sales class to sync the names of the salesLines to the purchLines.
Comments
Post a Comment