Thursday 13 February 2014

jobs

1. How to copy object data to other object :
static void Job15(Args _args)
{
    Table2 a,b;
    a.CustAccount = "2014";
    a.Description = "hi";
    b =a;
    b.Description = "hello";
    info(strFmt("%1,%2",b.CustAccount,b.Description));

}
=====================================================================
static void jobjoinwherorderby(Args _args)
{
    InventSum inventsum;
    InventDim inventdim;
    InventLocation inventlocation;
    InventBatch inventbatch;
    int tot;
    while select * from inventsum
        join * from inventdim where inventsum.InventDimId == inventdim.inventDimId          
            join * from inventlocation where inventlocation.InventLocationId == inventdim.InventLocationId
                && inventlocation.InventLocationType == InventLocationType::Standard
                    join * from  inventbatch order by prodDate desc where inventdim.inventBatchId == inventbatch.inventBatchId                      
                 
    {
        tot++;
       
        //info(strFmt("%1,%2%3",inventsum.ItemId,inventsum.InventDimId,inventsum.PhysicalInvent));
    }
 info(strFmt("%1",tot));
}

Thursday 6 February 2014

How to get balance in a year for a customer

static void PreviousYearBalance(Args _args)
{
int nowyear;
    transdate fromdate;
    transdate  enddate;
    CustTrans custtransloc;

    nowyear = year(today())-1;

    fromdate = str2DateDMY(strFmt("1/1/%1", nowyear));
    enddate = today();

    select sum (AmountMST) from custtransloc

        where custtransloc.AccountNum == "2014" &&
              custtransloc.TransDate       >= fromdate        &&
              custtransloc.TransDate       <= enddate ;

    info(strFmt("%1",custtransloc.AmountMST));
    //info(strFmt("%1",todate));
}