Thursday 14 June 2012

How dates are converted to string in Ax 2009

Hi friends

Today we are going to convert dates in Ax 2009. Below I am going to publish a simple program for that . Paste the following program in Job and go through it.
Display str balanceDate()
{
str day;
str month;
str currentYear;

str datevalue;
int i;
transdate StartMonth;
str year_format;
;
if(salarymonth)
{
StartMonth = Global::dateStartMth(salarymonth);
day = int2str(dayofMth(any2date(StartMonth)));
month = substr(mthname(mthofyr(any2date(StartMonth))),1,3);
currentYear = int2str(year(any2date(StartMonth)));
year_format = substr(currentYear,3,2);
for(i=1; i<=3; i++)
{
switch(i)
{
case 1:
datevalue += day ;
datevalue += ' ';
break;
case 2 :
datevalue += month;
datevalue += ' ';
break;
case 3:
datevalue += year_format;
break;

}
datevalue = datevalue;
}

}
return datevalue;
}

I hope after seeing the program you will understand a lot more about it.


Vivek Chirumamilla

Friday 8 June 2012

Query using X++ in Ax 2009

Hi Friends,

You know queries are the most easier way to work on than any other statements .

You can derive complex syntax easily by using query.

For first giving us a clear idea we are not going too much deep into the query.

First we have to declare a query by using the following syntax

Query q = new Query();

And we need the following declarations to add datasource, range and to run the query

QueryBuildDataSource qbds;

QueryBuildRange qbr;

QueryRun queryRun;

qbds= q.addDataSource(tablenum(InventTable));
qbds.addSortField(fieldnum(InventTable,ItemId));
qbr = qbds.addRange(fieldnum(InventTable,ItemId));
qbr.value("1104");
qbr1 = qbds.addRange(fieldnum(InventTable,DataAreaId));
qbr1.value(strfmt('(((%3.FromDate >= %1) || (%3.Todate > %1)) && ((%3.Todate<=%2) || (%3.Fromdate<%2)))',Date2StrXpp(LeaveFromDate),
Date2StrXpp(LeaveToDate), q.dataSourceTable(tablenum(InventTable)).name()));

queryRun = new QueryRun(q);
while (queryRun1.next())
{
InventTable= queryRun.get(TableNum(InventTable));

info(strfmt("%1" ,InventTable.ItemId));
}

Vivek Chirumamilla

Thursday 7 June 2012

date,month tips in Ax 2009

Hi Friends,

Today we are going to have tips on month values and how to effectively use them in Ax 2009.

Here are some tips to use::

To get the next month value use "nextMth(Month)"

To get the previous month value use "prevMth(Month)"

To get the stating month date if the value of a month date is in middle use "datestartmth(Month)"

To get the end month date if the value of a month date is in middle use "dateendmth(Month)"



Vivek Chirumamilla

Tuesday 5 June 2012

Calender Update in Ax 2009

Hi friends,

There is a job which update Calender and calender working times.

Below is the job run while updating calender.

static void workCalendarUpdateJob(Args _args)
{
WorkCalendarDate WorkCalendarDate;
;
ttsbegin;
update_recordset WorkCalendarDate
setting WorkTimeControl = WorkTimeControl::Open
where WorkCalendarDate.CalendarId == "CalenderName";
ttscommit;
}


Vivek Chirumamilla

To resolve unbalanced X++ TTSBegin/TTSCommit pair in Ax 2009

Hi friends,

I have an unbalanced X++ TTSBegin/TTSCommit pair has been detected .Cause of this include (a) too many/few TTSBegin or TTS Commit . The current TTS level is '1'

To solve this error there is a job which is to be executed when yo get this error.

static void resetTTS(Args _args)
{
while (appl.ttsLevel() > 0)
ttsAbort;
}



Vivek Chirumamilla