This is a basic job that describes how you can jump from one order line to another in the intercompany order structure.
In this example I have created an intercompany order that also has a linked purchase order in the production company to a vendor. This is one way you can use to jump up between the linked order lines.
I start out in the sales company “FO1” and go all the way up to the intercompany sales line in the production company “FO”, then I change company to “FO” so that I can gain access to the production company’s purchase line. From this purchase line I change the direction and move all the way back to the original sales line that is located in the sales company FO1.
As you can see I run the code while being in the sales company “FO1″. I start out with a specific sales line that I get by searching for its RecId. This code it meant to be run with a sales line as its basis. Preferably from the SalesTable form, the SalesLine table or some other object where you have sales line data that you want to explore.
static void FO_InterCompanyRefs(Args _args)
{
SalesLine salesLine =
SalesLine::findRecId(5637552101),
icSalesLine = null;
PurchLine purchLine,
icPurchLine;
;
// Sales company = FO1
// Production company = FO
// Original Sales Company SalesLine
print salesLine.SalesId;
print salesLine.ItemId;
print salesLine.dataAreaId;
print "------------------";
purchLine =
PurchLine::findInventTransId(
salesLine.InventRefTransId);
// Sales Company PurchLine
print purchLine.PurchId;
print purchLine.ItemId;
print purchLine.dataAreaId;
print "------------------";
icSalesLine =
purchLine.interCompanySalesLine();
// Production company SalesLine
print icSalesLine.SalesId;
print icSalesLine.ItemId;
print icSalesLine.dataAreaId;
print "------------------";
changecompany(icSalesLine.dataAreaId)
{
purchLine = PurchLine::findInventTransId(
icSalesLine.InventRefTransId);
// Production company PurchLine
print purchLine.PurchId;
print purchLine.ItemId;
print purchLine.dataAreaId;
print "------------------";
icSalesLine =
SalesLine::findInventTransId(
purchLine.InventRefTransId);
// Production company SalesLine
print icSalesLine.SalesId;
print icSalesLine.ItemId;
print icSalesLine.dataAreaId;
print "------------------";
purchLine =
icSalesLine.interCompanyPurchLine();
// Sales Company PurchLine
print purchLine.PurchId;
print purchLine.ItemId;
print purchLine.dataAreaId;
print "------------------";
salesLine =
purchLine.interCompanySalesLineOriginal();
// Sales Company PurchLine
print salesLine.SalesId;
print salesLine.ItemId;
print salesLine.dataAreaId;
print "------------------";
}
pause;
}
This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
Subscribe to:
Post Comments (Atom)
Ledger Voucher creation Framework and x++ code to create ledger voucher
Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...
-
{ "Message" : "Please verify that the user is valid and set up correctly." } Sol: System Administration > Se...
-
Please click here to access Custom Workflow step by step process:
-
FormRun formRun = sender.formRun(); Object inventTrans_ds = formRun.dataSource(formDataSourceStr(InventMarking,InventTransO...
i didn't find interCompanySalesLine() method in purchLine table
ReplyDeletethx