28 March 2014

Split the string value by using saperatror in AX

static void StringSplitter(Args _args)
{
GeneralJournalAccountEntry generalJournalAccountEntry;
TextBuffer buffer;
str value;
Counter cnt;

value = "1000-524-457-524";
//select generalJournalAccountEntry;
buffer = new TextBuffer();
buffer.setText(value);//generalJournalAccountEntry.LedgerAccount);

while (buffer.nextToken(0, '-'))
{
cnt++;

if(cnt == 1)
info (strFmt("first %1",buffer.token()));
if(cnt == 2)
info (strFmt("two %1",buffer.token()));
if(cnt == 3)
info (strFmt("three %1",buffer.token()));
if(cnt == 4)
info (strFmt("four %1",buffer.token()));

}
}

How to get Ledger dimension values individually in AX 2012

static void IndividualDimensionValuesUsingView(Args _args)
{
GeneralJournalAccountEntry generalJournalAccountEntry; //Table that stores ledger transactions
DimensionAttributeLevelValueAllView dimAttrView; //View that will display all values for ledger dimensions
DimensionAttribute dimAttr; //Main dimension attribute table
int i;

setPrefix("Ledger dimension breakup");
while select generalJournalAccountEntry
{
i++;
if (i > 100)
break;

setPrefix(int2str(i) + ". " + DimensionAttributeValueCombination::find(generalJournalAccountEntry.LedgerDimension).DisplayValue);
while select DisplayValue from dimAttrView
where dimAttrView.ValueCombinationRecId == generalJournalAccountEntry.LedgerDimension
join BackingEntityType from dimAttr
where dimAttr.RecId == dimAttrView.DimensionAttribute
{
switch (dimAttr.BackingEntityType)
{
case tableNum(DimAttributeMainAccount):
info(strFmt("Main Account: %1", dimAttrView.DisplayValue));
break;

case tableNum(DimAttributeOMBusinessUnit):
info(strFmt("Business Unit: %1", dimAttrView.DisplayValue));
break;

case tableNum(DimAttributeCustTable):
info(strFmt("Customer: %1", dimAttrView.DisplayValue));
break;

case tableNum(DimAttributeOMDepartment):
info(strFmt("Department: %1", dimAttrView.DisplayValue));
break;

case tableNum(DimAttributeHcmWorker):
info(strFmt("Worker: %1", dimAttrView.DisplayValue));
break;
}
}
}

}

14 March 2014

Deploying Models in Test and Production environment process

Set query Range for Existing report in while running in class PrintMedium settings for Report in class

Method()
{
Args args;
ReportRun reportRun;
str reportName = "ReportNameTest";
str myPath;
int i;
TransDate td;
TransDate vd;
str rangeDate;
;
i = 1;
td = systemDateget();
args = new Args(reportName);
args.caller(reportRun);

reportRun = new reportRun(args);
reportRun.query().interactive(false);
reportRun.query().dataSourceTable(tablenum(TableNmae)).addRange(fieldNum(TableNmae,FeildNmae)).value(SysQuery::value(td));
reportRun.report().interactive(false);

reportRun.setTarget(printMedium::File);
reportRun.printJobSettings().setTarget(PrintMedium::File);
reportRun.printJobSettings().preferredTarget(PrintMedium::File);
reportRun.printJobSettings().format(PrintFormat::PDF);
reportRun.printJobSettings().warnIfFileExists(false);
reportRun.printJobSettings().suppressScalingMessage(true);
pdfFileName = @"\\AXTESTDEV1\D$\Demo\Test.pdf";
reportRun.printJobSettings().fileName(pdfFileName);

reportRun.init();
reportRun.run();
}

06 March 2014

AX 2012 SSRS RDP Class

[SRSReportQueryAttribute(querystr(CustTransQuery))]
public class CustTransdemoDP extends SRSReportDataProviderBase
{
CustTransDemoTmp custTransDemoTmp;
CustTable custTable;
CustTrans custTrans;
AmountCur amountCur;
Voucher voucher;
CustGroupId custGroup;
TransDate transDate;

}
=================
[SRSReportDataSetAttribute(tableStr(CustTransDemoTmp))]
private CustTransDemoTmp getCustTransTmp()
{
select custTransDemoTmp;

return custTransDemoTmp;
}
======================
private void inserrtIntoCustTransTmp()
{
custTransDemoTmp.CustGroup = custTable.CustGroup;
custTransDemoTmp.AmountCur = custTrans.AmountCur;
custTransDemoTmp.Voucher = custTrans.Voucher;
custTransDemoTmp.TransDate = custTrans.TransDate;
custTransDemoTmp.insert();
}
=======================
[SysEntryPointAttribute]
public void processReport()
{
QueryRun queryRun;

queryRun = new QueryRun(this.parmQuery());

while (queryRun.next())
{
custTable = queryRun.get(tablenum(CustTable));
custTrans = queryRun.get(tablenum(CustTrans));

amountCur = custTrans.AmountCur;
voucher = custTrans.Voucher;
custGroup = custTable.CustGroup;
transDate = custTrans.TransDate;

this.inserrtIntoCustTransTmp();
}
}

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->...