Thursday, August 11, 2016

Update GL posted Voucher number ax 2012

//Update GL posted Voucher ax 2012

//Change Field name as per requirement

//CustTrans/VendTrans/AssetTrans / ledgerTrans Sample

LedgerJournalTrans          jourTrans;
    CustTrans           custTrans; //00000003ST-
    GeneralJournalEntry jouranlEntry;
    SubledgerVoucherGeneralJournalEntry linkVOucher;
    ;
    update_recordSet jourTrans setting Voucher = "ST-00000003"
        where jourTrans.Voucher == "00000003ST-";
    update_recordSet custTrans setting Voucher = "ST-00000003"
        where custTrans.Voucher == "00000003ST-";
    update_recordSet jouranlEntry setting SubledgerVoucher = "ST-00000003"
        where jouranlEntry.SubledgerVoucher == "00000003ST-";
   
    update_recordSet linkVOucher setting Voucher = "ST-00000003"
        where linkVOucher.Voucher == "00000003ST-";


//Project Trans

    LedgerJournalTrans          jourTrans;
    GeneralJournalEntry jouranlEntry;
    SubledgerVoucherGeneralJournalEntry linkVOucher;
    LedgerJournalTrans_Project  transProject;
    ProjTransPosting        projTrans;
    ProjCostTrans   projCostTrans;
    TransDate       _date= mkDate(01,02,2016);
    ;
     jourTrans.clear();
    update_recordSet jourTrans setting TransDate = _date
        where jourTrans.Voucher == "00028/2016";
    jourTrans.clear();
    transProject.clear();
    update_recordSet transProject setting ProjTransDate = _date
        where transProject.RefRecId == jourTrans.RecId
            join jourTrans
                where jourTrans.Voucher == "00028/2016"
                    && jourTrans.AccountType == LedgerJournalACType::Project;
    projTrans.clear();
    update_recordSet projTrans setting ProjTransDate = _date,LedgerTransDate = _date,PaymentDate =_date
        where projTrans.Voucher == "00028/2016";
   
    projCostTrans.clear();
    jourTrans.clear();
    transProject.clear();
    while select jourTrans
        where jourTrans.Voucher == "00028/2016"
           && jourTrans.AccountType == LedgerJournalACType::Project
           join transProject
                where  transProject.RefRecId == jourTrans.RecId
    {
        ttsBegin;
        while select forupdate projCostTrans
                where projCostTrans.TransId == transProject.TransId
        {
            projCostTrans.TransDate = _date;
            projCostTrans.update();
            info(strFmt("%1,%2,%3",projCostTrans.TransDate,projCostTrans.TransId,projCostTrans.RecId));
        }       
        ttsCommit;
    }

    jouranlEntry.clear();
    update_recordSet jouranlEntry setting AccountingDate = _date
        where jouranlEntry.SubledgerVoucher == "00028/2016";
    linkVOucher.clear();
    update_recordSet linkVOucher setting AccountingDate = _date
        where linkVOucher.Voucher == "00028/2016";

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...