Vasanth Arivali's Blog

Hi Guys,

Here I have posted a sample job to fetch the Dimension values based on the LedgerDimension in Ax 2012. This will give the clear picture how the LedgerDimenion(Combination of MainAccount-Dim1-Dim2-Dim3) is mapped with each Dimension Values

/// This will get the Dimension based on your AccountStructure of the Current Company and Posting Profile Setup.

static void getDimensionValueFromLedgerDimension(Args _args)

{

DimensionAttribute                          dimensionAttributeTable;

DimensionAttributeValueGroupStatus          dimAttrValueGroupStatusTable;

DimensionAttributeValueGroupCombination     dimAttrValueGroupComboTable;

DimensionAttributeValueGroup                dimAttrValueGroupTable;

DimensionAttributeLevelValue                dimAttrLevelValueTable;

DimensionAttributeValue                     dimAttrValueTable;

DimensionAttrValueCOAOverride               dimAttrValueCOAOverrideTable;

DimensionAttrValueLedgerOverride            dimAttrValueLedgerOverrideTable;

DimensionFinancialTag                       dimensionFinancialTagTable;

InventPosting                               inventPostingTable;

DimensionValue                              Dimension1, Dimension2, Dimension3;

MainAccountNum                              LedgerAccount;

RecId                                       LedgerRecId, dimCombinationId;

dimCombinationId    = 5637144728; // for example here i gave a valid ledgerdimension

// find MainAccountId from LedgerDimension

LedgerAccount       = MainAccount::findByLedgerDimension(dimCombinationId).MainAccountId;

LedgerRecId         = Ledger::findLedgerRecIdByLegalEntity(CompanyInfo::findDataArea(curext()).RecId);

Dimension1 = “”;

Dimension2 = “”;

Dimension3 = “”;

while select Ordinal from dimAttrValueGroupComboTable order by Ordinal

where dimAttrValueGroupComboTable.DimensionAttributeValueCombination == dimCombinationId

join dimAttrValueGroupTable

where dimAttrValueGroupTable.RecId == dimAttrValueGroupComboTable.DimensionAttributeValueGroup

outer join dimAttrValueGroupStatusTable

where dimAttrValueGroupStatusTable.DimensionAttributeValueGroup == dimAttrValueGroupTable.RecId

join dimAttrLevelValueTable

where dimAttrLevelValueTable.DimensionAttributeValueGroup == dimAttrValueGroupTable.RecId

join pessimisticLock IsSuspended, IsTotal, ActiveFrom, ActiveTo, DimensionAttribute, RecId, EntityInstance from dimAttrValueTable

where dimAttrValueTable.RecId == dimAttrLevelValueTable.DimensionAttributeValue

outer join pessimisticLock IsSuspended, ActiveFrom, ActiveTo, RecId from dimAttrValueCOAOverrideTable

where dimAttrValueCOAOverrideTable.DimensionAttributeValue == dimAttrValueTable.RecId && dimAttrValueCOAOverrideTable.ChartOfAccounts == LedgerChartOfAccounts::current()

outer join pessimisticLock IsSuspended, ActiveFrom, ActiveTo, RecId from dimAttrValueLedgerOverrideTable

where dimAttrValueLedgerOverrideTable.DimensionAttributeValue == dimAttrValueTable.RecId && dimAttrValueLedgerOverrideTable.Ledger == LedgerRecId

{

dimensionFinancialTagTable = null;

select * from dimensionFinancialTagTable

where dimensionFinancialTagTable.RecId == dimAttrValueTable.EntityInstance

join dimensionAttributeTable

where dimensionAttributeTable.RecId == dimAttrValueTable.DimensionAttribute;

if (dimensionAttributeTable.Name == ‘Department’)

{

Dimension1 = dimensionFinancialTagTable.Value;

}

if (dimensionAttributeTable.Name == ‘CostCenter’)

{

Dimension2 = dimensionFinancialTagTable.Value;

}

if (dimensionAttributeTable.Name == ‘Purpose’)

{

Dimension3 = dimensionFinancialTagTable.Value;

}

}

info(strFmt(“%1     %2      %3”,Dimension1,Dimension2,Dimension3));

}

Advertisements

Hi,

Here I have written a sample code to execute a simple secenario with “Common” Table in Ax 2012

static void Job_UsingCommonTable(Args _args)

{

#define.ledgerDimension(‘LedgerDimension’)

#define.inventPosting(‘InventPosting’)

#define.inventItemGroupForm(‘InventItemGroupForm’)

InventPosting                    inventPosting;

container                           conCompanies = [‘CEE’, ‘CUE’, ‘DMO’];

InventItemGroupForm    inventItemGroupForm;

container                           tableList = [tableStr(Inventposting), tableStr(InventItemGroupForm)];

TableName                        name;

int                                       loop;

void updateDimension(Common common)

{

DimensionAttributeValueCombination  dimensionAttributeValueCombination;

ttsbegin;

while select crossCompany:conCompanies common

{

select forUpdate LedgerDimensionType, RecId from dimensionAttributeValueCombination

where

dimensionAttributeValueCombination.RecId == common.(fieldName2id(common.TableId,  #ledgerDimension));

if(dimensionAttributeValueCombination.RecId)

{

dimensionAttributeValueCombination.LedgerDimensionType =  LedgerDimensionType::Account;

dimensionAttributeValueCombination.doUpdate();

}

}

ttsCommit;

info(strFmt(‘DimensionAttributeValueCombination is update for Table: %1’, tableId2name(common.TableId)));

}

for (loop = 1; loop <= conLen(tableList); loop++)

{

name = conPeek(tableList, loop);

switch(name)

{

case #inventPosting :

updateDimension(inventPosting);

break;

case #inventItemGroupForm :

updateDimension(inventItemGroupForm);

break;

}

}

info(‘Completed’);

}

Thanks & Regards,

Vasanth Arivali

Hi All,

We all know about “Go To Main Table” Option in our Axapta Forms and Tables. Here I wrote one sample for how to get that functionality in our forms or table. This is done by three ways:

1) By EDT Relations

2) By using JumpRef method

3) By using FormRef property in Table

EDT Relations:

If you use an EDT in tables which have relation with some other table fileds, that time you can able to navigate the main table or main form.

FormRef Property:

Select the Table and go to properties and select the required form in the FormRef property.

JumpRef method:

If you are not having that option, simply write a override the JumpRef method in a field of DataSource or in a Form Control. Here i show you a sample jumpRef method code:

public void jumpRef()
{
Args            args;
MenuFunction    menuFunction;
;

args = new Args();
menuFunction = new MenuFunction(menuitemDisplayStr(“FormName”), MenuItemType::Display);
args = new Args(menuFunction.object());
args.caller(element);
args.record(“RecordName”); // to be a datasource which added in the current form
menuFunction.run(args);
}

In the form init() which we called here, we have to check the condition whether the form is called by any dataset or not.

Thanks & Regards

Vasanth Arivali

Hi Guys,

Here i posted a small job , to explain how we use regular expressin in Axapta. Try it.

static void RegularExpression_Test()

{

int nameLength,myStringLength;

str myname = “Vasanth”;

str myString = “1234”;

str formatString , formatString1;

System.Text.RegularExpressions.Regex regEx;

System.Text.RegularExpressions.Regex regEx1;

System.Text.RegularExpressions.Match regMatch;

InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);

boolean retVal, retVal1;

;

nameLength = strLen(myname);

myStringLength = strLen(myString);

formatString   = strfmt(@”^[0-9]{%1}”, myStringLength);

formatString1   = strfmt(@”^[a-zA-Z ]{%1}”, nameLength);

permission.assert();

//BP Deviation documented

regEx = new System.Text.RegularExpression.Regex(formatString);

regEx1 = new System.Text.RegularExpression.Regex(formatString1);

regMatch = regEx.Match(myString);

retVal = regMatch.get_Success();

print retVal; // Returns True;

regMatch = regEx1.Match(myname);

retVal1 = regMatch.get_Success();

print retVal1 // Returns True;


}

Thanks & Regards,

Vasanth Arivali

Hi All,

 

Here i written the code to use the Aggregate functions and Joins in Dynamic Query in spite of using normal Select statement in Ax 2009

 

Normal Select Statement:

 

while select sum(qty) from inventTrans where inventTrans.ItemId ==

“OL-2500” join inventDimgroup by inventBatchId where

inventDim.InventDimId == inventTrans.InventDimId

{

// Our Code Here

}

 

Dynamic Query:

 

static void Vasanth_Query_Eg1(Args _args)

{

Query                   query;

QueryBuildDataSource    queryBuildDataSource;

QueryBuildRange         queryBuildRange;

QueryRun                queryRun;

Qty                     total;

InventTrans             inventTrans;

;

query = new Query();    queryBuildDataSource    = query.addDataSource(tableNum(InventTrans));

queryBuildDataSource.addSelectionField(fieldNum(InventTrans,Qty),

SelectionField::Sum);

queryBuildDataSource.orderMode(OrderMode::GroupBy);

queryBuildRange         = queryBuildDataSource.addRange(fieldNum(InventTrans,ItemId));

queryBuildDataSource    = queryBuildDataSource.addDataSource(tableNum(InventDim));

queryBuildDataSource.orderMode(OrderMode::GroupBy);

queryBuildDataSource.addSortField(fieldNum(InventDim,InventBatchId));

queryBuildDataSource.relations(true);

queryRun = new QueryRun(query);

if (queryRun.prompt())

{

while (queryRun.next())

{

inventTrans = queryRun.get(tableNum(InventTrans));

total = inventTrans.Qty;

}

}

info(strFmt(“Quantity: %1”, total));
}

Hi,

Here i posted the code to use the AOT Query Object in our X++ code.

Steps:

1) Create a AOT Query Object as your requirement.

2) Create a Job and paste the below code to check the Query Object.

static void ExecuteAOTQuery(Args _args)

{

QueryRun queryRun;

Counter totalRecords;

;

queryRun = new QueryRun(queryStr(CreatedAOTQueryName));

if (queryRun.prompt())

{

while (queryRun.next())

{

totalRecords++;

}

}

info(strFmt(“Total Records : %1”, totalRecords));

}

Hi All,

Here I create Lookups using X++ Code(without Ax Table or EDT relation). For that i override a String(Text) Control’ s lookup method.

public void lookup()

{
//super();

// Added by Vasanth Arivali

// Declaration
Query   LookupQuery    =   new Query();

QueryBuildDataSource     LookupQueryBuildDataSource;

QueryBuildRange                  LookupQueryBuildRange;
SysTableLookup CustomSysTableLookup =       SysTableLookup::newParameters(tableNum(InventTable), this);

;

// Add fields that you want in Lookups

CustomSysTableLookup.addLookupField(fieldNum(InventTable, ItemId));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemName));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemGroupId));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,NameAlias));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemType));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,DimGroupId));

// Add DataSource, Range and Value

LookupQueryBuildDataSource =

LookupQuery.addDataSource(tableNum(InventTable));

LookupQueryBuildRange=

LookupQueryBuildDataSource.addRange(fieldNum(InventTable,ItemVisibility));

LookupQueryBuildRange.value(queryValue(NOYESCOMBO::Yes));

// Execute the Query

CustomSysTableLookup.parmQuery(LookupQuery);

CustomSysTableLookup.performFormLookup();
// Added by Vasanth Arivali

}

Welcome

What’s happening?

  • RT @jairamguttuvan: கவுண்டமணி நகைச்சுவை வடிவேலு நகைச்சுவை இனிதென்பர் இந்த மழலை நகைச்சுவை காணொளி காணாதவர் https://t.co/VON8g3DlM2 2 hours ago
  • RT @mrpaluvets: #அறிவோம்ஈழம் https://t.co/6YOoy3ZMSt 2 hours ago
  • RT @Nunmathiyon: ஆந்திரால பாலகிருஷ்ணா படத்தையெல்லாம் பார்த்து கைதட்டி விசிலடிச்சி கொண்டாடுறவங்களைப் பார்க்குறப்போ கேணைக் கிறுக்கங்களா தெரி… 2 hours ago
  • RT @Anabhayachozhan: திருடன் திருடன்னு கத்திக்கிட்டு நாம ஓடினா!கூட திருடனும் திருடன் திருடன்னு கத்திக்கொண்டே ஓடி வரான்... கன்னியாகுமரியில்… 2 hours ago
  • RT @ImthiImthiyas: பாபர் மசூதி வேண்டுமா? ராமர் கோவிலை வேண்டுமா?-மோடி எல்லோருக்கும் வேலை வேண்டும், தரமான மருத்துவம் வேண்டும், தரமான கல்… 2 hours ago
  • RT @NaamTamilarOrg: உலகிலேயே வலிமைமிக்க கடற்படையை வைத்திருக்கிற நாடு என்று மார்தட்டிக்கொண்டு புயலில் சிக்கி கடலில் தத்தளிக்கிற சொந்தநாட்டு… 2 hours ago
  • RT @idumbaikarthi: திருமாவின் தலைக்கு ஒரு கோடி ரூபாய் விலை பேசுகிறார்கள் காவிகள். #சீமான் இதனைக் கண்டிக்கிறார். ஆனால், அவரோடு கூட்டணி வகி… 12 hours ago
  • RT @CreativeTwitz: என்னடா மக்கள் மன்றத்தில் மக்கள் அடிக்க வராங்க.... தமிழிசை மீனவர்களை காப்பாற்ற துப்பில்லை என்று தமிழிசைக்கு எதிராக மக்கள்… 12 hours ago
  • RT @idumbaikarthi: தெலுங்கர் தன்னைத் திராவிடர் என்று சொல்லிக்கொண்டு தமிழ்நாட்டை ஆளலாம். தெலுங்கர் தன்னைத் தெலுங்கர் என அறிவித்து தமிழ்நாட்… 21 hours ago
  • மோடி அரசின் FRDI Bill திட்டம். இது என்னடா புது டிசைன் youtu.be/LzTJlBl7utg 22 hours ago

Categories

Join 13 other followers