Announcements
Hi experts,
I have a table which has all the data i need to perform and get aggregation amt , end objective is to use this aggregate amount & create 1 JE in 1 company having line items corresponding to multiple accounts from multiple company.
Developing & using custom methods on table i can generate data like below.
After this i need a code/pseduocode which would do the following
1. Create 1 JE in 1 company
For example je D01 in company D which will never be present in above list of companies
2.Traverse the above structure & create line items in this JE for respective companies & acc# while ignoring 0 amt transactions.
I think key here will be to map the T1 T2 to Ledger dim value of ledger account in that company , is it something which can be managed in Ax directly or i need to create another column in my table & enter full ledgeraccountdim value so as to map T1 to a ledgerdimvalue as they are not stored as values but only as rec id in dimattribute & displayed as complete value only for display purpose.
Thanks
Mav
Gunjan,
Thanks a lot for your help. My apologies for missing that link on previous post & continuing with system method which indeed becomes an issue when financial dimension is blank , which is weird especially considering that i m checking allow blank values on in the form.
Neverthless the custom method did fix the issue. Once again thanks expert.
Thanks
Mav.
Hi Mav,
I think passing blank values is causing the issue. Can you try this method instead? I am using the earlier post I referred to -
RecId getLedgerDimension(str _ledgerAccount, str _fDim1, str _fDim2, str _fDim3, str _fdim4, str _fDim5, str _fDim6, str _fDim7, str _fDim8) { DimensionServiceProvider DimensionServiceProvider = new DimensionServiceProvider(); LedgerAccountContract LedgerAccountContract = new LedgerAccountContract(); DimensionAttributeValueContract ValueContract; List ListValueContract = new List(Types::Class); dimensionAttributeValueCombination dimensionAttributeValueCombination; DimensionStorage dimStorage; if (_fDim1) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName('Businessunit') ; ValueContract.parmValue(_fDim1); ListValueContract.addEnd(ValueContract); } if (_fDim2) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName('Legalentity') ; ValueContract.parmValue(_fDim2); ListValueContract.addEnd(ValueContract); } if (_fDim3) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName('Department') ; ValueContract.parmValue(_fDim3); ListValueContract.addEnd(ValueContract); } if (_fDim4) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName('Project') ; ValueContract.parmValue(_fDim4); ListValueContract.addEnd(ValueContract); } if (_fDim5) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName('Shipment') ; ValueContract.parmValue(_fDim5); ListValueContract.addEnd(ValueContract); } if (_fDim6) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName('Customer') ; ValueContract.parmValue(_fDim6); ListValueContract.addEnd(ValueContract); } if (_fDim7) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName('COntract') ; ValueContract.parmValue(_fDim7); ListValueContract.addEnd(ValueContract); } if (_fDim8) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName('Location') ; ValueContract.parmValue(_fDim8); ListValueContract.addEnd(ValueContract); } LedgerAccountContract.parmMainAccount(_ledgerAccount); LedgerAccountContract.parmValues(ListValueContract); dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract); dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save()); return dimensionAttributeValueCombination.RecId; }
HI Gunjan
Here is the snippet with my comments on FAIL case & Pass/working case also showing at which line it is failing in both my custom class & system class.
_dimvalue = "MAcct-Fdim2-Fdim3-Fdim4----Fdim7-Fdim8"; // FAILS as Fdim 5,6, & 7 are blank FAILS at line 16 in createJE() which it recives as ERROR at line 78 for getLedgerAccountId(container _dimensionValue) because "" does not exist in dimattributevalue table , however that should not be the case as Dimension was set to allow blanks yes in COA as shown in pic in previous post. -dimvalue = "Macct-Fdim2-Fdim3-Fdim4-Fdim5-Fdim6-Fdim7-Fdim8"; //Works as i m providing value for all FDIMS public static createJELineitems(str _dimvalue) { dimcon = str2con(_dimvalue, ledgerAccountDelimiter, false); _acctPattern = [_ledgerJournalTrans.LedgerCode(),_ledgerJournalTrans.LedgerCode(),9,'MainAccount',conPeek(dimcon,1),'Fdim1',conPeek(dimcon,2), 'Fdim2',conPeek(dimcon,3),'Fdim3',conPeek(dimcon,4),'Fdim4',conPeek(dimcon,5),'Fdim5',conPeek(dimcon,6),'Fdim6',conPeek(dimcon,7),'Fdim7',conPeek(dimcon,8),'Fdim8',conPeek(dimcon,9)]; _offSetAcctPattern = [_ledgerJournalTrans.OffsetLedgerCode(),_ledgerJournalTrans.OffsetLedgerCode(),0]; ledgerJournalTrans.AccountType = LedgerJournalACType::Ledger; ledgerJournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(_acctPattern); ledgerJournalTrans.TransDate = _ledgerJournalTrans.TransactionDate(); } System class AxdDimensionUtil public static recId getLedgerAccountId(container _dimensionValue) { LedgerAccountContract ledgerAccountContract; DimensionServiceProvider dimensionServiceProvider; DimensionStorage dimensionStorage; MainAccountNum mainAccountId; int collectionCount, collectionIndex, containerElementIndex; str displayValue, attributeName, attributeValue; DimensionAttribute dimensionAttribute; DimensionAttributeValue dimensionAttributeValue; // Initialize variables needed for this method. dimensionStorage = DimensionStorage::construct(0, LedgerDimensionType::Account); dimensionServiceProvider = new DimensionServiceProvider(); ledgerAccountContract = new LedgerAccountContract(); ledgerAccountContract.parmValues(new List(Types::Class)); containerElementIndex = 1; // At this point we need to read the values from the passed in container and use them to build the // list of values needed by the DimensionServiceProvided. // Get displayValue. displayValue = conPeek(_dimensionValue, containerElementIndex); containerElementIndex ; // Get MainAccountId value. mainAccountId = conPeek(_dimensionValue, containerElementIndex); ledgerAccountContract.parmMainAccount(mainAccountId); containerElementIndex ; // Validate that the MainAccount exists. AxdDimensionUtil::validateMainAccount(mainAccountId); // Get Attribute Name/ Attribute Value pair count. collectionCount = conPeek(_dimensionValue, containerElementIndex); containerElementIndex ; // We need to load the list ledgerAccountContract.parmValues() so we can get a dimension storage instance built. for (collectionIndex = 1; collectionIndex <= collectionCount; collectionIndex ) { // Get attribute name attributeName = conPeek(_dimensionValue, containerElementIndex); containerElementIndex ; // Validate the Financial Dimenion that was passed in. dimensionAttribute = AxdDimensionUtil::validateFinancialDimension(attributeName); // Get attribute value attributeValue = conPeek(_dimensionValue, containerElementIndex); containerElementIndex ; // Validate the Financial Dimenion Value that was passed in. dimensionAttributeValue = AxdDimensionUtil::validateFinancialDimensionValue(dimensionAttribute, attributeValue); // Add the Dimension Name and Value to the Values list in the contract. ledgerAccountContract.parmValues().addEnd(AxdDimensionUtil::fillDimensionAttributeValueContract(attributeName,attributeValue)); } dimensionStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(ledgerAccountContract); return dimensionStorage.save(); }
Thanks
Mav
Hi Mav,
Please share your code where you are passing values to this method.
Finally was able to understand and make below FOR loop working to get finacial dim attribute name & attribute value.
However the code still errors out for dimension having blank values at red line shown in pic below which is weird because in COA the dimension is set to Allow blanks
Any ideas to fix this?
Pic showing allow blanks for financcial dim in COA structure form.
Hi Mav,
Since the account is being provided in a particular format, Can you segregate each of the dimensions and store the values in a variable? You can then create the ledger dimension and assign it to LedgerJournalTrans.LedgerDimension / LedgerJournalTrans.OffsetLedgerDimension fields.
Please check the code here.
Hi Dr,
Can you share an example of how to take full ledger dim value and then use that in account field of ledger journal line items?
The requirement is very clear that user will provide full ledger dimension value and Ax should create journal line items with account field showing full ledger dim instead of just main account.
With above code I am able to create JE line items however it shows only main account number under accounts of JE line items, hence it fails my cause as the requirement is to create JE line item with full ledger dim value showing under accounts field of JE line items.
Thanks
Mav
Hi Mav,
I am not sure whether you have to code all of that stuff.
There are some 'hidden' features available in the COA and other setup forms in AX2012 that might be able to create the extra line automatically without coding.
Yet, we would need a better understand of what these extra lines shall be used for and what the purpose of that extra lines is.
Best regards,
Ludwig
ledgerJournalTrans.AccountType = LedgerJournalACType::Ledger; statick job1() { Ledgerjournaltrans ledgerjournaltrans; str 50 dim value,ledgerAccountDelimiter; MyJECreateutil syncUtil = new MyJECreateutil(); MyJEDatacontract myDc = new MyJEDatacontract(); List transacitonList = new List(Types::Class); dimvalue = "920000-005-Cma-02----Contract_1-"; ledgerAccountDelimiter = SystemParameters::getChartOfAccountsDelimiter(); dimvaluecon = str2con(dimvalue, ledgerAccountDelimiter, false); ledgerJournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(dimvaluecon); ERRORS out here because of reasons stated below /* Working code , working i.e. creating journal ledger & journal line tems //WOrking code begin myDc.LedgerCode("111001"); myDc.OffsetLedgerCode("999999"); myDc.TransactionCurrencyAmount(1); myDc.TransactionDate(01\09\2020); transacitonList.addEnd(myDc); myDc = new EVA_UltiproCreateJEDC(); myDc.LedgerCode("111001"); myDc.OffsetLedgerCode("999999"); myDc.TransactionCurrencyAmount(2); myDc.TransactionDate(01\09\2020); transacitonList.addEnd(myDc); syncUtil.CreateGeneralJournal("Myjournalname", "OB Transfer", transacitonList); info("Created General Journal !"); //Working code end */ }
Hi,
Unable to share full project , however sharing the code for test job for core issue & reference used to create utilities can be found here
Above is sample test job showing where it fails at line 13 because it is unable to populate attribute names in below class I understand that below system class is trying to look everything in 1 container which is not easily doable.
Main objective still remains the same - User provides a full ledger dimension , details of which shared above , need to create a ledgher journal line item with that full dimension showing in account number.
Thanks
Mav
Hi Mav,
Could you please share the code you have till now?
André Arnaud de Cal...
294,125
Super User 2025 Season 1
Martin Dráb
232,871
Most Valuable Professional
nmaenpaa
101,158
Moderator