vendredi 3 décembre 2010

How to find the max/min of a column in a table from X++

Here is the code :)

static void Maximum(Args _args)
{
     Amount                             taxablesalary, maxim;
     PayrollpayTypeTransaction          payrollPayTypeTransaction ;
     Container                          c;
     PayrollIncrement                          i;
      #macrolib.PayrollpaytypeNum
      ;
    
    
     while select payrollpaytypeamount from payrollPayTypeTransaction where payrollPayTypeTransaction.PayrollPaytypeNum == #PayrollPaytypeNumC3
        {
        c = c + [ payrollPayTypeTransaction.PayrollPaytypeAmount ];
        }
       
        maxim = conpeek ( c ,1);
        for(i=1; i< conlen(c)+1 ;i++)
        {
              maxim = max( maxim, conpeek ( c, i+1));
              info(conpeek(c, i));
        }
}
The same with the min using min function


Well we can do this using Array DataType also 
 Here is the link :
 http://kashperuk.blogspot.com/


Happy Daxing :) !

Aucun commentaire:

Enregistrer un commentaire