add total field to report id 109 customer summary ageing

ahmedbaahmedba Member Posts: 424
in report id 109 customer summary aging simple in reports default in dynamic nav i found this code written in after get report trigger:

PrintCust := FALSE;
FOR i := 1 TO 5 DO BEGIN
DtldCustLedgEntry.SETCURRENTKEY("Customer No.","Initial Entry Due Date","Posting Date");
DtldCustLedgEntry.SETRANGE("Customer No.","No.");
DtldCustLedgEntry.SETRANGE("Posting Date",0D,StartDate);
DtldCustLedgEntry.SETRANGE("Initial Entry Due Date",PeriodStartDate,PeriodStartDate[i + 1] - 1);
DtldCustLedgEntry.CALCSUMS("Amount (LCY)");
CustBalanceDueLCY := DtldCustLedgEntry."Amount (LCY)";
IF CustBalanceDueLCY <> 0 THEN
PrintCust := TRUE;
END;
IF NOT PrintCust THEN
CurrReport.SKIP;
that found before is 0-30,31-60,61-90
what i need is to total variable that consist of amount( debit -credit)
meaning how i write this by coding
total =amount for 0-30+amount for 31-61+amount for 61-91
thanks

Comments

  • krikikriki Member, Moderator Posts: 9,112
    TotalAmount := 0; //NEW LINE
    
    PrintCust := FALSE;
    FOR i := 1 TO 5 DO BEGIN
      DtldCustLedgEntry.SETCURRENTKEY("Customer No.","Initial Entry Due Date","Posting Date");
      DtldCustLedgEntry.SETRANGE("Customer No.","No.");
      DtldCustLedgEntry.SETRANGE("Posting Date",0D,StartDate);
      DtldCustLedgEntry.SETRANGE("Initial Entry Due Date",PeriodStartDate[i],PeriodStartDate[i + 1] - 1);
      DtldCustLedgEntry.CALCSUMS("Amount (LCY)");
      CustBalanceDueLCY[i] := DtldCustLedgEntry."Amount (LCY)";
      
      TotalAmount += TotalAmount + DtldCustLedgEntry."Amount (LCY)"; //NEW LINE
      
      IF CustBalanceDueLCY[i] <> 0 THEN
        PrintCust := TRUE;
    END;
    IF NOT PrintCust THEN
      CurrReport.SKIP;
    
    // "TotalAmount" contains the total amount
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ahmedbaahmedba Member Posts: 424
    OK thanks it run but i have another question if i want to calculate debit amount(debit amount(lcy)) from 1 to 5 and total as i make before what the modification that must make in code
    meaning
    total 0-30 31-60 61-91
    debit-credit(already made) debit amount(lcy) debit amount(lcy) debit amount(lcy)
    what is the modification i must make to make this formula
    please help me.
    thanks
  • krikikriki Member, Moderator Posts: 9,112
    Instead of using "Amount (LCY)", you can use "Debit Amount (LCY)" and "Credit Amount (LCY)" for debit and credit amounts.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ahmedbaahmedba Member Posts: 424
    OK I make this code as following :

    PrintCust := FALSE;
    total:=0;
    FOR i := 1 TO 5 DO BEGIN
    DtldCustLedgEntry.SETCURRENTKEY("Customer No.","Initial Entry Due Date","Posting Date");
    DtldCustLedgEntry.SETRANGE("Customer No.","No.");
    DtldCustLedgEntry.SETRANGE("Posting Date",0D,StartDate);
    DtldCustLedgEntry.SETRANGE("Initial Entry Due Date",PeriodStartDate,PeriodStartDate[i + 1] - 1);
    DtldCustLedgEntry.CALCSUMS("Amount (LCY)");
    DtldCustLedgEntry.CALCSUMS("Debit Amount (LCY)");
    CustBalanceDueLCY :=DtldCustLedgEntry."Debit Amount (LCY)";
    CustBalanceDueLCYAm :=DtldCustLedgEntry."Amount (LCY)";
    total:=total+DtldCustLedgEntry."Amount (LCY)";
    IF CustBalanceDueLCY <> 0 THEN
    PrintCust := TRUE;
    END;
    IF NOT PrintCust THEN
    Curr Report.SKIP;
    but message error display there are too many dimension the variable defined with little dimension.
    why this message display
    what i need is display total(debit -credit to all package) and debit amount to every package as following 0-30,31-60,61-90.
    thanks
  • krikikriki Member, Moderator Posts: 9,112
    You need to give dimensions to your new variable. Check the properties of the old variable to see what I mean.

    BTW: you really should take some C/AL courses or have you assisted by a senior C/AL developer. This is very basic stuff!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.