Intercompany : Technical Guide Line

This post will explain you how to make the transfert of information from the ORDER 1 (Sales order create in the company A who have create the Purch order (ORDER 2) in the company A and the other Sales order (ORDER 3) in the company B).

So, if it’s a new field, you need to put your field in tables :

  • SalesTable
  • PurchTable

Of, if it’s in the level of the line :

  • SalesLine
  • PurchLine

I will continue my explanation with the header.

In your both tables, you need to modify the following method, it’s simply to say : “I want transfert information throught my interco when I modify this field”

boolean  interCompanyUpdateNow()
{
    boolean  ok = false;
    ;

    if (!this.RecId)
        ok = true;

    if (this.orig().SalesType                       != this.SalesType
    ||  this.orig().CurrencyCode                    != this.CurrencyCode
    [...]
    ||  this.orig().ReturnReplacementCreated        != this.ReturnReplacementCreated
// INTERCO - BEGIN
    ||  this.orig().MyNewField                      != this.MyNewField
// INTERCO - END
        )
    {
        ok = true;
    }

    return ok;
}

Now, go to the classes

You need sur create the method in the AxABC method. So you need to modify theses method :

  • AxSalesTable
  • AxSalesLine
  • AxPurchTable
  • AxPurchLine

Example in AxSalesTable :

public Description parmMyNewField(Description _myNewField = "")
{
    if (!prmisdefault(_myNewField ))
    {
        this.setField(fieldnum(SalesTable, MyNewField), _myNewField );
    }

    return salesTable.MyNewField;
}

Ensuite, il faut modifier les classes Type suivantes:

  • SalesTableType
  • SalesLineType
  • PurchTableType
  • PurchLineType

You must modify the following method :

void  interCompanyMirror()
{
    [...]
// INTERCO - BEGIN
        if (create || salesTable.fieldChanged(fieldNum(SalesTable, MyNewField)))
        {
            axPurchTable.parmMyNewField(salesTable.MyNewField);
        }
// INTERCO - END

        if (create)
            axPurchTable.parmInterCompanyOrigin(InterCompanyOrigin::Derived);

        axPurchTable.defaulting(create);
        axPurchTable.save();

        if (create)
        {
            info(strfmt("@SYS121436",axPurchTable.purchTable().PurchId),'', SysInfoAction_TableField::newBuffer(axPurchTable.purchTable()));
        }

        salesTable.InterCompanyPurchId = axPurchTable.parmPurchId();
    }

    [...]
}

And the method (for SalesTable) :

AxPurchTable syncPurchTable(SalesTable _salesTable, PurchTable _purchTable, boolean _forceAddressSync = false)
{
    [...]
// INTERCO - BEGIN
    if (create || salesTable.fieldChanged(fieldNum(SalesTable, MyNewField)))
    {
        axPurchTable.parmMyNewField(salesTable.MyNewField);
    }
// INTERCO - END

    return axPurchTable;
}

And the method for PurchTable :

AxSalesTable syncSalesTable(PurchTable _purchTable, SalesTable _salesTable = null, boolean _forceAddressSync = false)
{
    [...]
// INTERCO - BEGIN
    if (create || purchTable.fieldChanged(fieldNum(PurchTable, MyNewField)))
    {
        axSalesTable.parmMyNewField(purchTable.MyNewField);
    }
// INTERCO - END

    return axSalesTable;
}

And it’s finished !

Getting Class extend list

There the code for display all classes who extend the class that you specify at the beginning:

static void MyGetClassList(Args _args)
{
    DictClass               dictClass;
    List                    listClass;
    ListEnumerator          listEnumerator;

    ClassId                 baseClass = classNum(TradeTotals);
    ;

    listClass = new DictClass(baseClass).extendedBy();

    listEnumerator = listClass.getEnumerator();

    while (listEnumerator.moveNext())
    {
        dictClass = new DictClass(listEnumerator.current());

        if (dictClass && !dictClass.isAbstract())
        {
            info(dictClass.name());
        }
    }
}