Here is the code I want to use, but will not work. if I exit after the last hold file, it rows of data for each hold file.
-* ----------------------------------------------------------------------------------------------------
-* upcoming payments report - header
-* created by gje 2012-04-12
-* provides the header information for this coordinated report
-* creates a list of dealers
-* who have upcoming payments in the next 60 days
-* or have overdue and upcoming account charges
-* ----------------------------------------------------------------------------------------------------
-*-INCLUDE TRACE_FOC_NORUN
-DEFAULT &NUMBEROFDAYS = 60;
-PROMPT &NUMBEROFDAYS.(7,14,30,60).Number of Days.
-DEFAULT ®IONNAME = '''South Central''';
-DEFAULT &MARKETNAME = '''Jackson''';
-SET &TODAYSDATE = &YYMD;
-*-SET &TODAYSDATE = 20120401;
-SET &STARTDATE = DATECVT(DATEMOV(DATECVT(&TODAYSDATE,'I8YYMD','YYMD'), 'BOW'),'YYMD','I8YYMD');
-SET &ENDDATE = DATECVT(DATEADD(DATECVT(&STARTDATE,'I8YYMD','YYMD'),'D', &NUMBEROFDAYS),'YYMD','I8YYMD');
-SET &PRINTSTARTDATE = DATETRAN(DATECVT(&STARTDATE, 'I8YYMD', 'YYMD') , '(MDYY)', '(Dtrdxr)', 'EN', 30, 'A30');
-SET &PRINTENDDATE = DATETRAN(DATECVT(&ENDDATE, 'I8YYMD', 'YYMD'), '(MDYY)', '(Dtrdxr)', 'EN', 30, 'A30');
-SET &PRINTDATERANGE = SQUEEZ( 100, &PRINTSTARTDATE || ' - ' | &PRINTENDDATE, 'A100');
SET NODATA = ' ';
-* ----------------------------------------------------------------------------------------------------
-* create hold upcoming payment detail (H_UPDTL)
-* ----------------------------------------------------------------------------------------------------
JOIN CLEAR *
JOIN
INNER RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSID IN RP_BUSINESSVIEW TO MULTIPLE
FLOORPLAN.FLOORPLAN.BUYERBUSINESSID IN FLOORPLAN TAG FP AS FP
END
JOIN
INNER FP.FLOORPLAN.FLOORPLANID IN RP_BUSINESSVIEW TO UNIQUE
CURTAILMENT.CURTAILMENT.FLOORPLANID IN CURTAILMENT TAG CRTLMT AS CRTLMT
END
JOIN
INNER FP.FLOORPLAN.FLOORPLANID IN RP_BUSINESSVIEW TO UNIQUE
FLOORPLANCACHE.FLOORPLANCACHE.FLOORPLANID IN FLOORPLANCACHE TAG FPC AS FPC
END
JOIN
INNER CRTLMT.CURTAILMENT.TERMPLANPERIODID IN RP_BUSINESSVIEW TO UNIQUE
TERMPLANPERIOD.TERMPLANPERIOD.TERMPLANPERIODID IN TERMPLANPERIOD TAG TPP AS TPP
END
-* ----------------------------------------------------------------------------------------------------
TABLE FILE RP_BUSINESSVIEW
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSID
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSNO
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSNAMEACTUAL
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSNAMENUMBERUPPER
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSNAMENUMBER
BY RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSEMAIL
WHERE FP.FLOORPLAN.FLOORPLANSTATUSID EQ 1;
WHERE CRTLMT.CURTAILMENT.ISVOIDED EQ 0;
WHERE CRTLMT.CURTAILMENT.ISWAIVED EQ 0;
WHERE CRTLMT.CURTAILMENT.PAYOFFFINANCIALRECORDID EQ '';
WHERE CRTLMT.CURTAILMENT.EXPECTEDPRINCIPALPAYMENT GT 0;
WHERE ( CRTLMT.CURTAILMENT.DUEDATE GE &STARTDATE ) AND ( CRTLMT.CURTAILMENT.DUEDATE LT &ENDDATE );
WHERE RP_BUSINESSVIEW.RP_BUSINESSVIEW.ISDELINQUENTDEFAULT EQ 'N';
WHERE RP_BUSINESSVIEW.RP_BUSINESSVIEW.REGION EQ ®IONNAME.(OR(FIND RP_BUSINESSVIEW.RP_BUSINESSVIEW.REGION,RP_BUSINESSVIEW.RP_BUSINESSVIEW.REGION IN rp_businessview)).Region.;
WHERE RP_BUSINESSVIEW.RP_BUSINESSVIEW.BRANCH EQ &MARKETNAME.(OR(FIND RP_BUSINESSVIEW.RP_BUSINESSVIEW.BRANCH,RP_BUSINESSVIEW.RP_BUSINESSVIEW.BRANCH IN rp_businessview)).Market.;
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS H_UPDTL FORMAT FOCUS
END
-* ----------------------------------------------------------------------------------------------------
-* create hold overdue and upcoming payment detail (H_ACTFEE)
-* ----------------------------------------------------------------------------------------------------
JOIN CLEAR *
JOIN
INNER RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSID IN RP_BUSINESSVIEW TO MULTIPLE
FINANCIALRECORD.FINANCIALRECORD.RESPONSIBLEBUSINESSID IN FINANCIALRECORD TAG FR
AS FR
END
JOIN
INNER FR.FINANCIALRECORD.FINANCIALRECORDID IN RP_BUSINESSVIEW TO UNIQUE
FINANCIALRECORDCACHE.FINANCIALRECORDCACHE.FINANCIALRECORDID
IN FINANCIALRECORDCACHE TAG FRC AS FRC
END
JOIN
INNER FR.FINANCIALRECORD.FEETYPEID IN RP_BUSINESSVIEW TO UNIQUE
FEETYPE.FEETYPE.ID IN FEETYPE TAG FT AS FT
END
-* ----------------------------------------------------------------------------------------------------
TABLE FILE RP_BUSINESSVIEW
PRINT
FR.FINANCIALRECORD.DESCRIPTION AS 'Description'
COMPUTE OVERDUE/A7 = IF FR.FINANCIALRECORD.EFFECTIVEDATE LT &YYMD THEN 'Yes' ELSE 'No'; AS 'Over,Due'
FR.FINANCIALRECORD.AMOUNTAPPLIED/P21.2CM AS 'Fee'
FRC.FINANCIALRECORDCACHE.BALANCE/P21.2CM AS 'Balance'
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSNO
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSID
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSNAMEACTUAL
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSNAMENUMBERUPPER
BY LOWEST RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSNAMENUMBER
BY RP_BUSINESSVIEW.RP_BUSINESSVIEW.BUSINESSEMAIL
BY TOTAL COMPUTE DUEDATE/MDYY = HDATE(FR.FINANCIALRECORD.EFFECTIVEDATE, 'YYMD'); AS 'Due Date'
BY LOWEST FT.FEETYPE.TYPE AS 'Fee Type'
WHERE FR.FINANCIALRECORD.FLOORPLANID EQ '';
WHERE FR.FINANCIALRECORD.FINANCIALCONTEXTTYPEID NE 9;
WHERE FRC.FINANCIALRECORDCACHE.BALANCE GT 0;
WHERE RP_BUSINESSVIEW.RP_BUSINESSVIEW.ISDELINQUENTDEFAULT EQ 'N';
WHERE RP_BUSINESSVIEW.RP_BUSINESSVIEW.REGION EQ ®IONNAME.(OR(FIND RP_BUSINESSVIEW.RP_BUSINESSVIEW.REGION,RP_BUSINESSVIEW.RP_BUSINESSVIEW.REGION IN rp_businessview)).Region.;
WHERE RP_BUSINESSVIEW.RP_BUSINESSVIEW.BRANCH EQ &MARKETNAME.(OR(FIND RP_BUSINESSVIEW.RP_BUSINESSVIEW.BRANCH,RP_BUSINESSVIEW.RP_BUSINESSVIEW.BRANCH IN rp_businessview)).Market.;
ON TABLE NOTOTAL
ON TABLE HOLD AS H_ACTFEE FORMAT FOCUS
END
-* ----------------------------------------------------------------------------------------------------
-* creates hold upcoming payment and account fee (H_ACTFEE)
-* this creates the list fo dealers who either have a upcoming payment
-* or an overdue or upcoming account fee
-* ----------------------------------------------------------------------------------------------------
MATCH FILE H_UPDTL
BY H_UPDTL.SEG01.BUSNO
BY H_UPDTL.SEG01.BUSINESSID
BY H_UPDTL.SEG01.BUSINESSNAMEACTUAL
BY H_UPDTL.SEG01.BUSINESSNAMENUMBERUPPER
BY H_UPDTL.SEG01.BUSINESSEMAIL
RUN
FILE H_ACTFEE
BY H_ACTFEE.SEG01.BUSNO
BY H_ACTFEE.SEG01.BUSINESSID
BY H_ACTFEE.SEG01.BUSINESSNAMEACTUAL
BY H_ACTFEE.SEG01.BUSINESSNAMENUMBERUPPER
BY H_ACTFEE.SEG01.BUSINESSEMAIL
AFTER MATCH HOLD AS H_UCPFEE OLD-OR-NEW
END
-* ----------------------------------------------------------------------------------------------------
-* creates output for each dealer for header
-* ----------------------------------------------------------------------------------------------------
SET ASNAMES = ON
TABLE FILE H_UCPFEE
PRINT
H_UCPFEE.H_UCPFEE.BUSNO AS 'VALUE'
COMPUTE DEST/A100 = 'gentrican@discoverdsc.com'; AS 'DEST'
WHERE H_UCPFEE.H_UCPFEE.BUSNO EQ 11723 OR 20887 OR 47733;
ON TABLE PCHOLD
END
WebFOCUS 7.7.03
MS SQL Server
Windows, Excel