Vasanth Arivali's Blog

Posts Tagged ‘how to use common table in Ax

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


Welcome

What’s happening?

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Categories

Join 13 other followers