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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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;
 
}

Printout:

00714_036
B-pack2
fo1
——————
00517_049
B-pack2
fo1
——————
fo100714_036
B-pack2
fo
——————
00258_049
B-pack2
fo
——————
fo100714_036
B-pack2
fo
——————
00517_049
B-pack2
fo1
——————
00714_036
B-pack2
fo1
——————

Last 5 posts in Development

Leave a Reply

Your email address will not be published. Required fields are marked *