Friday, 2 February 2018

CrossCompany insert Code in AX2012

CrossCompany insert Code


The following code are my Test.i cant assure that this code will work as you expect.



static void crosscompantinsert(Args _args)
{

    TMSSalesTable tableFrom,tableTo;

    str destinationCompany="USRT";

    str curCompany;

    #avifiles
    SysOperationProgress  oProgress;
    int                   nTotal;

    #define.TITLE("Copying data...");

        curCompany=curext();
    if(curCompany=="USMF")
    {

    select count(RecId) from tableFrom;

   // nTotal=tableFrom.RecId;

    oProgress=SysOperationProgress::newGeneral(#aviUpdate,#TITLE,nTotal);

    tableFrom.clear();

    while select tableFrom
    {
        changeCompany(destinationCompany)
        {
            tableTo=null;

            ttsBegin;

            buf2Buf(tableFrom,tableTo);
            tableTo.insert();

            ttsCommit;
        }

        oProgress.incCount();

    }

    oProgress.hide();
    }

    else
    {
        info("Cannot be processed");

}
}

No comments:

Post a Comment

job to Update Internal Customers - custTable - AX2012 in all companies (crosscompany)

UpdateInternalCustomers using cross Company in AX2012 we can update the custTable Table in all the companies in AX     static void KTI_...