27 July 2016

Get Dimension attribute value for Customer creation and for journal lines

Struct struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;

custTable.company(custTableStagging.LegalEntity);
custTable.initValue();
name = custTableStagging.FirstName + " "+ custTableStagging.LastName;
//CustTable
custTable.AccountNum = NumberSeq::newGetNum(CustParameters::numRefCustAccount()).num();//customer.parmAccountNum();
custTable.CustGroup = custTableStagging.CustGroup;
custTable.Currency = CompanyInfo::standardCurrency();
if (custTableStagging.Region != '')
{
struct.add('Region', custTableStagging.Region);
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
custTable.DefaultDimension = DimensionDefault;
}

// custTable.KPMGPayeeName = name;
custTable.insert(DirPartyType::Organization, name);
============


container cont1,cont2,offSetAcctPattern;
int cnt;
DimensionDynamicAccount ledgerDim, offsetledgerDim;

if(mLegalEntity != '')
{
cnt++;
cont2 += ['LegalEntity',mLegalEntity];
}
if(mLocationFacility != '')
{
cnt++;
cont2 += ['LocationFacility',mLocationFacility];
}
if(mDepartment != '')
{
cnt++;
cont2 += ['Department',mDepartment];
}
if(mCustomerGroup != '')
{
cnt++;
cont2 += ['CustomerGroup',mCustomerGroup];
}
if(mBusinessUnit != '')
{
cnt++;
cont2 += ['BusinessUnit',mBusinessUnit];
}
if(mLocationType != '')
{
cnt++;
cont2 += ['LocationType',mLocationType];
}
if(mCompetency != '')
{
cnt++;
cont2 += ['Competency',mCompetency];
}
if(mProject != '')
{
cnt++;
cont2 += ['Project',mProject];
}

if(mRegion != '')
{
cnt++;
cont2 += ['Region',mRegion];
}
if(mWorker != '')
{
cnt++;
cont2 += ['Worker',mWorker];
}

if(ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger)
{
cont1 += ['MainAccount',AccountNumb,cnt];
cont1 += cont2;
ledgerDim = AxdDimensionUtil::getLedgerAccountId(cont1);

if(ledgerDim == 0)
{
offSetAcctPattern = [AccountNumb,AccountNumb];
ledgerDim = AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern);
}

ledgerJournalTrans.LedgerDimension = ledgerDim;
}
else
{
ledgerDim = DimensionStorage::getDynamicAccount(AccountNumb,ledgerJournalTrans.AccountType);
ledgerDimension += cnt;
ledgerDimension += cont2;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.LedgerDimension = ledgerDim;
LedgerJournalTrans.modifiedField(fieldNum(LedgerJournalTrans,LedgerDimension));
ledgerJournalTrans.DefaultDimension = DimensionDefault;

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...