I am fine tuning my aging report and trying to restrict printing records to only those customers with a severely past due balance. However, I want the report to print all the customer's records, not just the ones that are severely past due.
In my aging formula, I am setting a flag that says this customer has severely past due invoices. Once a record is read that is past due, then the flag is set to Y. Only once the customer changes is the flag reset to N.
In the section expert under detail, group header and group footer, I suppress printing records where the value is N.
My problem is that I have a situation where the 1st record is not past due and subsequent records are past due. When I display the flag on the record, it is correct. However, the group header has the value for the 1st record in the group which is N.
When do header records get printed?
Here is my new aging forumula.
numbervar docamount;
global numbervar bucket1;
global numbervar bucket2;
global numbervar bucket3;
global numbervar bucket4;
global numbervar bucket5;
global numbervar bucket6;
global numbervar tmpbucket1;
global numbervar tmpbucket2;
global numbervar tmpbucket3;
global numbervar tmpbucket4;
global numbervar tmpbucket5;
global numbervar tmpbucket6;
global numbervar permbucket1;
global numbervar permbucket2;
global numbervar permbucket3;
global numbervar permbucket4;
global numbervar permbucket5;
global numbervar permbucket6;
numbervar daysold;
global stringvar bucket6flag;
stringvar prevcustno;
numbervar prevdoc;
datevar prevdocdate;
datevar docdate;
//Setting a flag to only print those customers who have an amount in bucket 6
//on change of customer and bucket6flag=y, add tempbuckets to permbuckets this way only customers with amounts in bucket 6
//accumulate totals.
//After the move of data, the tempbuckets are cleared.
If prevcustno <> {ARCUSFIL_SQL.cus_no}
Then
(
If Bucket6flag="Y"
Then
(
permbucket1:=permbucket1 + tmpbucket1;
permbucket2:=permbucket2 + tmpbucket2;
permbucket3:=permbucket3 + tmpbucket3;
permbucket4:=permbucket4 + tmpbucket4;
permbucket5:=permbucket5 + tmpbucket5;
permbucket6:=permbucket6 + tmpbucket6;
)
Else 0;
tmpbucket1:=0;tmpbucket2:=0;tmpbucket3:=0;tmpbucket4:=0;tmpbucket5:=0;tmpbucket6:=0;bucket6flag:="N";
);
//
//set the variables to zero
daysold:=0;docamount:=0;
//
//add the amt 1 and amt 2 field. Amt2 only has an amount if the customer overpaid the account
//
docamount:={AROPNFIL_SQL.amt_1} + {AROPNFIL_SQL.amt_2};
//
//Setting the payment date to the invoice date to sync up the aging.
If (prevdoc={AROPNFIL_SQL.alt_apply_to_no} and {AROPNFIL_SQL.doc_type} = "P") then docdate:=prevdocdate
else docdate:={@docdate};
daysold:=datediff("d",docdate,CurrentDate);
Select daysold
case 0 to 180 :
bucket1:=docamount
case 181 to 365 :
bucket2:=docamount
case 366 to 730 :
bucket3:=docamount
case 731 to 1095 :
bucket4:=docamount
case 1096 to 1460:
bucket5:=docamount
case is >= 1461:
bucket6:=docamount ;
//add bucket amounts to bucket accumulators
tmpbucket1:=tmpbucket1 + bucket1;
tmpbucket2:=tmpbucket2 + bucket2;
tmpbucket3:=tmpbucket3 + bucket3;
tmpbucket4:=tmpbucket4 + bucket4;
tmpbucket5:=tmpbucket5 + bucket5;
tmpbucket6:=tmpbucket6 + bucket6;
If bucket6 <> 0 then bucket6flag:="Y";//allows the customer records to print. This is being handled in section expert.
prevdoc:={AROPNFIL_SQL.alt_apply_to_no};
prevdocdate:={@docdate};
prevcustno:={ARCUSFIL_SQL.cus_no};
//daysold
bucket6flag
Edited by jgh1204 - 14 Apr 2008 at 1:34pm