Tuesday 29 March 2016

To get Customers total amount Transaction using X++ Code


static void CustOpenTrans(Args _args)
{
     CustTrans custtrans;
    CustTable custtbl;
    while select custtbl
    {
    select sum(AmountMST) from custtrans where custtrans.AccountNum == custtbl.AccountNum;
        info(strFmt("Customer - %1  Amount - %2",custtbl.AccountNum,custtrans.AmountMST));
    } }

6 comments:

  1. Hi Rajendra, I want to find find the name of customers with the total transaction amount less then a specific amount for instance amount less the 10000 how should I modify this query to suit my requirement. Can you please help ?

    ReplyDelete
    Replies
    1. Thanks for viewing my blog !!!!

      just add
      select sum(AmountMST) from custtrans where CustTrans.AmountMST < 10000 && custtrans.AccountNum == custtbl.AccountNum
      This may helpful for you

      Delete
    2. Hey thanks for replying I tried this earlier as well but it gives negative values as well. Can we do it only using CustTrans and also remove negative values without using if clause ?

      Delete
    3. Hii Pranay
      try this once
      select sum(AmountMST) from custtrans where CustTrans.AmountMST > 0
      && CustTrans.AmountMST <10000 && custtrans.AccountNum == custtbl.AccountNum ;

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. who to print the sum of amount for each accountnum from CustTrans

    ReplyDelete