Wednesday 21 December 2011

Reference the field added in LedgerJournalTrans to LedgerTrans in Ax 2009

Hi Friends,

        Today we will implement the field which is added in LedgerJournalTrans will be displayed on LedgerTrans . For example we are going to add an EmplId field in LedgerJournalTrans , the value which is given in the LedgerJournalTrans will have to be shown in LedgerTrans. Add the fields in the LedgerJournalTrans and show it in the form.
Note:: The code given below is not in a order..............
1. In classes LedgerVoucher ,in method initledgerTransList add the following code

protected void initLedgerTransList()
{
    ledgerTransList = new RecordSortedList(tablenum(LedgerTrans));
    ledgerTransList.sortOrder(
        fieldnum(LedgerTrans, Voucher),
        fieldnum(LedgerTrans, EmplId), // This is the field which we have added
        fieldnum(LedgerTrans, TransDate),
        fieldnum(LedgerTrans, AccountNum),
        fieldnum(LedgerTrans, PeriodCode),
        fieldnum(LedgerTrans, OperationsTax),
2.In classes LedgerVoucherObject  initialize the EmplId by declaring it,
 and in the same class create a new method of ParmEmplId , use the code as follows

public S3_EmplId parmEmplId_S3(S3_EmplId _emplId = emplId)
{
    ;
    emplId = _emplId;
    return emplId;
}
3.In same class in allocate method use the follwing code
 
    allocationTransObject =
            LedgerVoucherTransObject::newVoucherTrans(
                this,
                LedgerPostingType::Allocation,
                baseLedgerTrans.AccountNum,
                baseLedgerTrans.Dimension,
                baseLedgerTrans.CurrencyCode,
                baseLedgerTrans.Txt,
                baseLedgerTrans.TransDate,
                baseLedgerTrans.EmplId, // Added the code here
                baseLedgerTrans.
                -totalTrans.Qty,
                -totalTrans.AmountCur,
                -totalTrans.AmountMST,
4.And in same class of method postRoundingDifferencesPerDate modify it

              this.addTrans(
                LedgerVoucherTransObject::newVoucherTrans(
                    this,
                    LedgerPostingType::MSTDiffSecond,
                    accountNum,
                    dimension,
                    companyCurrencyCode,
                    transactionTxt.txt(),
                    ledgerTrans.TransDate,
                    ledgerTrans.EmplId,
                    0,
                    0,
                    0,
                    -ledgerTrans.AmountMSTSecond,
                    NoYes::No,
                    true,
                    tmpVoucherMap),
                false);
5.And in the   LedgerVoucherTransObject Class   of method newTransLedgerJournal add the code


    ledgerTransObject.parmLedgerTransType(LedgerTransType::None);
    ledgerTransObject.parmPeriodCode(PeriodCode::Regular);
    ledgerTransObject.parmSourceTableId(_ledgerJournalTrans.TableId);
    ledgerTransObject.parmSourceRecId(_ledgerJournalTrans.RecId);
    ledgerTransObject.parmCompany(_ledgerJournalTrans.Company);
    ledgerTransObject.parmLedgerAccount(_ledgerJournalTrans.AccountNum);
    ledgerTransObject.parmVoucher(_ledgerJournalTrans.Voucher);
    ledgerTransObject.parmTransDate(_ledgerJournalTrans.TransDate);
    ledgerTransObject.parmTransTxt(_ledgerJournalTrans.Txt);
    ledgerTransObject.parmEmplId(_ledgerJournalTrans.EmplId);// we have used our EmplId here
6. And in the same class of method newVoucherTrans add the code

static LedgerVoucherTransObject newVoucherTrans(LedgerVoucherObject    _ledgerVoucherObject,
                                                 LedgerPostingType     _ledgerPostingType,
                                                 LedgerAccount         _ledgerAccount,
                                                 Dimension             _dimension,
                                                 CurrencyCode          _currencyCode,
                                                 TransTxt              _transTxt,
                                                 EmplId              _emplId,// we have used it here
                                                 TransDate             _transDate



    ledgerTransObject.parmEUROTriangulation(_euroTriangulation);
    ledgerTransObject.parmThisIsARoundingTrans(_thisIsARoundingTrans);
    ledgerTransObject.parmTmpVoucherMap(_tmpVoucherMap);
    ledgerTransObject.parmEmplId();// we have used it here
7.In the same class of initfromledgervoucher object

     void initFromLedgerVoucherObject(LedgerVoucherObject _ledgerVoucherObject)
{
    ;
    ledgerTrans.Voucher                                 = _ledgerVoucherObject.parmVoucher();
    ledgerTrans.EmplId                               = _ledgerVoucherObject.parmEmplId();//Added here




8. Add Parmmethod of EmplId in the same class 
By doing all this mopdifications in the classes u will get the desired result
                                                                Vivek Chirumamilla.

1 comment:

  1. In AX 2012 try using the Financial Dimension Framework to avoid having to make these sort of changes, if possible.
    Useful post :)

    ReplyDelete