How to use Join in AX 2012

Description:-

In this Example we will see How to use join in ax table. For your information I have created table “A_Marks” and Count Each person Subject marks and join with different table object which one I have created in Job. Also I’m using sum () function for counting total of particular subject marks in table. Let’s create job and understand how to use join or many more function we can use in ax. i have here took join example for working with it.

Create table and Name it “A_Marks”
 
Create Job from AOT
  • In the AOT, click Job.
  • Right-click the Job node, and then select New Job.

static void CheckJoin(Args _args)
{
    A_Marks _Marks,_Marks1,_Marks2,_Marks3,_Marks4,_Marks5,_Marks6;
    A_Student _Student,_Student1,_Student2,_Student3;
    str name,name1;
    select sum(Maths) from _Marks;
    info("----------------Maths-------------------");
    while Select _Student
    join _Marks1
    where _Marks1.Mark_Student == _Student.Student_ID
    {
        name = (_Student.Student_Name);
        if(_Marks1.Maths)
        {
            info(strFmt(" %1 Has Maths Marks- %2",name,_Marks1.Maths));
        }
    }
    info("-----------------Total-------------------");
    info(strfmt("The total Maths Marks is %1", _Marks.Maths));   

    select sum(Phygics) from _Marks4;
    info("---------------Phygics------------------");
    while Select _Student2
    join _Marks3
    where _Marks3.Mark_Student == _Student2.Student_ID
    {
        name1 = (_Student2.Student_Name);
        if(_Marks3.Phygics)
        {
            info(strFmt(" %1 Has Phygics Marks- %2",name1,_Marks3.Phygics));
        }
    }
    info("-----------------Total-------------------");
    info(strfmt("The total Phygics Marks is %1", _Marks4.Phygics));
    info("-----------------------------------------");   

    select sum(Chemistry) from _Marks6;
    info("---------------Chemistry------------------");
    while Select _Student3
    join _Marks5
    where _Marks5.Mark_Student == _Student3.Student_ID
    {
        name1 = (_Student3.Student_Name);
        if(_Marks5.Chemistry)
        {
            info(strFmt(" %1 Has Chemistry Marks- %2",name1,_Marks5.Chemistry));
        }
    }
    info("-----------------Total-------------------");
    info(strfmt("The total Chemistry Marks is %1", _Marks6.Chemistry));
    info("-----------------------------------------");
}

Here you can Understand I have taken little Example to Understand it. So Now run your job and check info Log what Information we are getting.

Related Posts

Previous
Next Post »