Thursday, April 14, 2011

Axapta Sample Codings................

1.TO PRINT MULTIPLICATION TABLE

static void MultiplyJob(Args _args)

{
int i,j;
int r ;
;
j = 7;
r = i*j;
for (i = 1; i <=10; i++)
{
print strfmt("%1 * %2 = %3",j,i, i*j);
}
pause;
}

2. ADDITION OF TWO NUMBERS

static void AdditionJob(Args _args)
{
int a,b,c;
;
a = 50;
b = 70;
c = a+b;
print strfmt("The value of c is %1",c);
pause;

3. TO PRINT THE A/C no NAME OF THE CUST TABLE
static void Add(Args _args)
{
CustTable custTable;
;
while select accountNum, name, address from CustTable
// where CustTable.AccountNum =="4000";
print CustTable.AccountNum, " ", CustTable.Name, " ",
CustTable.Address,CustTable.phone;
pause;
}

4. TO PRINT THE NAME(ANY DETAILS) OF PERTICULAR ACCOUNT NUMBER

static void Address(Args _args)
{
CustTable custTable;
;
select custTable
where custTable.AccountNum =="1103";
print "This is the address of Customer " +
custTable.AccountNum + ":/// " + custTable.Address;
pause;
}
5.TO PRINT THE NAME BY USING strfmt FUNCTION
static void WelcomeStrfmt(Args _args)
{
str name;
real a;
;
name = "world of AX 2009";
a = 100.00;
print strfmt("%1: Welcome to %2", a, name);
pause;
}
6.TO PRINT A BOX MESSAGE
static void Mainbox(Args _args)
{
Box box;
;
box::info('Main Text', 'Title', 'This is the help text');
}

7.TO PRINT NAMES BY USING string FUNCTIONS(subStr)
static void Letter(Args _args)
{
str letters;
;
letters ="Microsoft DynamicsAx";
print subStr(letters, 2, 12);
print subStr(letters, 15, -8);
pause;
}

8.TO INSERT A RECORD INTO A TABLE (CUST TABLE)

static void CustJob(Args _args)
{
custTable custTable;
;
custTable.accountNum ="9999";
custTable.name ="Suresh";
custTable.insert();}

9. TO GET MESSAGES BY USING MULTIPLE BOXES
static void SimpleJob(Args _args)
{
box box;
;
box :: info('Hi', 'Title', 'This is the help text');
box :: info('Suresh', 'Title');
box :: info('How are you', 'Title');
box :: info('Now', 'Title');
pause;
}

10. TO CHECK THE VALUE WHICH IS MAX
static void Max(Args _args)
{
int i = 12;
int j = 10;
int x;
;
x = i > j ? i : j;
print strfmt('The value of x is %1',x);
pause;
}

11. TO PRINT THE PASSED TIME BY USING timestr FUNCTION

static void DisplayTime(Args _args)
{
str timeStr;
timeofday time;
;
timeStr = "11:38";
time = str2Time(timeStr);
info(strfmt("%1 seconds has passed since midnight when the clock is %2", time, timeStr));
}
12.TO PRINT A NAME IN INFOLOG BOX BY USING do-while
static void Infolog(Args _args)
{
Counter counter = 1;
;
do
{
info(strFmt("Axapta %1", counter));
print "welcome";
counter++;
}
while (counter <= 10);
}

13. TO PRINT MULTIPLE NAME IN INFOLOG BOX BY USING CONTAINER

static void Intro(Args _args)
{
Container names = ["Borusu", "Uday", "Bhaskar", "Krishna", "Babu"];
Counter counter;
;
for (counter=1; counter <= conlen(names); counter++)
{
info(strFmt("%1: Name: %2", counter, conpeek(names, counter)));
print "Welcome to Axaptians";
pause;
}
}

14. TO PRINT THE ACCOUNT NUMBER, NAME OF THE CUST TABLE IN THE INFO BOX

static void Info11(Args _args)
{
CustTable CustTable;
;
while select AccountNum, Name from CustTable order Name
{
print(CustTable.Name+', '+CustTable.AccountNum);
info(CustTable.Name+', '+CustTable.AccountNum);
pause;
}
}

15.TO PRINT THE SALES TYPE IN THE INFO LOG
static void Info5(Args _args)
{
SalesType salesType; // a standard enum in Ax
;
salesType = SalesType::Sales;
info(strfmt("The name of the current sales-type is '%1'",enum2str(salesType)));
}
16. TO PRINT “WELCOME ”BY USING for LOOP
static void Welcome(Args _args)
{
int i;
;
for (i = 1; i <= 20; i++)
{
//print counter;
print "welcome";
pause;
}
}
17. TO PRINT NAMES BY USING MULTIPLE print STATEMENTS
static void Name(Args _args)
{
PrintMyName PrintMyName;
;
PrintMyName = new PrintMyName();
PrintMyName.setMyName();
PrintMyName.printMyName();
print "life is beautiful";
pause;
print "Generation Awakenss";
pause;
}

18. MULTIPLICATION OF TWO NUMBERS

static void Multiplication(Args _args)
{
int a,b,c;
;
a = 10;
b = 20;
c = a*b;
print strfmt("The value of c is %1",c);
pause;
}
19.TO MULTIPLICATE A VALUE BY USING counter VARIABLE(KEYWORD)

static void Multi1(Args _args)
{
int counter = 1;
;
do
{
print counter * 3;
counter++;
}
while(counter <= 30);
pause;
}

20.TO PRINT A NAME IN MULTIPLE LINES BY USING counter
static void multilines(Args _args)
{
int counter = 1;
;
while (counter <= 25)
{
//print counter * 2;
counter++;
print "welcome to the cool world of Ax 2009";
pause;
}
}
21. To Get YES NO BOX
static void Db(Args _args)
{
Box box;
;
box::yesNo('Choose Yes or No', DialogButton::Yes, 'Yes NoBox Example', 'Answer Yes or No');
}

22. DIVISON OF TWO NUMBERS BY USING A strfmt FUNCTION

static void Divison(Args _args)
{
int x = 24;
int y = 4;
int res = x/y;
;
print strfmt("%1 / %2 = %3", x, y, x/y);
pause;
}

23. PROGRAME BY USING EXCEPTIONS

static void Exception(Args _args)
{
CustTable custTable;
;
try
{
Select custTable
where custTable.accountNum == '1109';
if (!custTable.RecId)
throw error("Customer does not exist");
}
catch (exception::error)
{
error ("Process was aborted");
}
}

24.PROGRAME TO DEMONSTRATE THE EXCEPTIONS(try,catch,throws)

static void Exception1(Args _args)
{
CustTable custTable;
;
try
{
custTable.AccountNum ="0002";
custTable.custGroup ="20";
custTable.Name ="Demonstration of try catch";
if (!custTable.validateWrite())
{
throw error("Record failed validation");
}
custTable.insert();
info("Record was inserted in database");
}
catch (Exception::error)
{
error("There was an error while inserting the record.");
}
}
25.TO PRINT A VALUE A BY USING COUNT AND BREAK

static void IntroBreak(Args _args)
{
Counter counter;
;
for (counter=1; counter <= 10; counter++)
{
print counter;
if (counter == 5)
{
break;
}
}
pause;
}

26.TO PRINT A NAME USING COUNTER

static void IntroContinue(Args _args)
{
Counter counter;
;
for (counter=1; counter <= 10; counter++)
{
if (counter MOD 3 == 0)
{
continue;
}
print counter;
//print "welcome";
}
pause;
}

27.UPDATE A CUST TABLE

static void Job11(Args _args)
{
CustTable custTable;
;
ttsbegin;
Select forUpdate custTable
where custTable.accountnum =="2033";
custTable.delete();
ttscommit;
 }

1 comment:

Leave your comments and solutins