06 October 2010

Jump between InterCompany order lines

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;

}

1 comment:

Give me the commetns and solutions

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->...