Posts

Showing posts from August, 2016

TTSCommit level

Image
Today i got this error when i try to run my code. Actually this error is telling that tts level in unbalanced and cant perform edit operations. To resolve this error this TTS level should be ZERO, Run this job to get rid of that error, this job will find the tts level where its greater than zero and make it zero by calling TTSABORT. tts b egin : marks the beginning of a transaction. This ensures data integrity, and guarantees that all updates performed until the transaction ends (by  tts c ommit  or  tts a bort ) are consistent (all or none). ttsCommit: marks the successful end of a transaction. This ends and commits a transaction. MorphX guarantees that a committed transaction will be performed according to intentions. static void TheAxaptaResetTTS(Args _args) { while (appl.ttsLevel() > 0) { info(strfmt("Level %1 aborted",appl.ttsLevel())); ttsAbort; } }

Calculate Age In Day, Months and Years in X++

I got required to display exact age of employee in days, month and years. I used some DateTimeUtil method and achieve my output. public static void getAge(Args args) { int years, months; int64 days; utcDateTime birthDayCurrentYear; str ageInWords; date _birthDate ; months = mthOfYr(systemdateget()) - mthOfYr(_birthDate); years = year(systemdateget()) - year(_birthDate); if (dayOfMth(systemdateget()) < dayOfMth(_birthDate)) { months--; } if (months < 0) { years--; months += 12; } #timeConstants birthDayCurrentYear = DateTimeUtil::addMonths(DateTimeUtil::newDateTime(_birthDate,0), ((years * 12) + months)); days = DateTimeUtil::getDifference(DateTimeUtil::newDateTime(systemdateget(),0) , birthDayCurrentYear) / #secondsPerDay; ageInWords = strFmt("%1 years, %2 months, days %3", years, months, days); info(ageInWords);