Interview Questions

Wednesday, May 14, 2014

How to use join in X++ code

static void DemoJoins(Args _args)
{
    CustTable       custTable;
    DirPartyTable   dirPartyTable;


    while select dirPartyTable order by Name desc join custTable
                  where custTable.Party == dirPartyTable.RecId
    {
        info(strFmt('%1 %2',dirPartyTable.Name, custTable.AccountNum));
    }

}
==================================================================
static void vivek_test(Args _args)
{
SPLPayIncomeTaxDefination       IncomeTaxSetup;
    SPLPayIncomeTaxHead             IncomeTaxHead;
    //SPLPayFormula                   Formula;
    //TransDate                       RunDate;
    AmountCur                       YearlyAmount;
    //AmountCur                       MonthlyAmount;
    TransDate                       salarymonth,x;
    ;
    x = systemdateget();
    info(strfmt("%1",x));
    salarymonth = 5\3\2012;
  while select IncomeTaxHead order by SequenceNo
        where   IncomeTaxHead.Nature    ==  SPLPaynature::IncomeTax
        join IncomeTaxSetup
            where   IncomeTaxSetup.IncomeTaxHeadId ==    IncomeTaxHead.IncomeTaxHeadId
            &&      IncomeTaxSetup.FinancialStart    <=    SalaryMonth
            &&      IncomeTaxSetup.FinancialEnd      >=    SalaryMonth

            {
                if(IncomeTaxSetup.FinancialStart    <=    SalaryMonth)
                    info("done");
            }
     if(x == salarymonth)
     {
        info("double");
     }
}

No comments:

Post a Comment