Hi! I'm trying to loop through 12 months (starting 12 months ago), setting each month to display the end of the month. With each iteration, I'd like to calculate the monthly backlog by determining whether the created date occurred before the end of the month and the closed date either hasn't occurred yet or occurred after the end of the month. Does anyone know how to do this without using Dialog Manager commands? I can accomplish this with Dialog Manager commands but I was told that unless I'm using a SQL pass through, all of the date manipulations should be done using DEFINE's. Thanks for any help you can provide!This message has been edited. Last edited by: Kerry,
WebFOCUS 7.6.10, Windows Vista, Oracle, Output-Excel/PDF/HTML
June 30, 2009, 04:11 PM
Darin Lee
You have to use DEFINE's when the values are tied to your data fields. In your case, it appears they are not. You just want the last 12 end-of-month dates from today (as determined by &YYMD or something similar.)
You can still calculate the end of month date for the last 12 months using dialogue manager and then compare your fields' values to those & vars.
So calculate in a loop the twelve dates, like &MTH1, &MTH2, etc.. Then use a define like
MONTH1_BKLOG/I9=IF CREATE_DATE LE &MTH1 AND (CLOSE_DATE GT &MTH1 OR CLOSE_DATE EQ MISSING) THEN 1 ELSE 0; MONTH2_BKLOG/I9=IF CREATE_DATE LE &MTH2 AND (CLOSE_DATE GT &MTH2 OR CLOSE_DATE EQ MISSING) THEN 1 ELSE 0;
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
June 30, 2009, 04:11 PM
BlueZone
DM is the most powerful/effecient way to control execution flow in a FOCUS pgm, I would first sincerely suggest reviewing that "do-not-use" rule in the first place.
You can do the date manipulation inside a DEFINE statement by assigining Month & Last-day values in each iteration of a -REPEAT loop.
One suggestion -
-REPEAT RPT_LOOP FOR &I FROM 1 TO 12;
DEFINE CLEAR *
DEFINE FILE xxxx
YR/A4='2009';
MTH/A2= IF &I < 10 THEN ('0' || EDIT(&I))
ELSE EDIT(&I) ;
DY/A2=DECODE &I(1 31 2 28 3 31 .....12 31);
DTE/A10= YR || '-' || MTH || '-' || DY ;
END
TABLE FILE xxx
PRINT xxxxxx
WHERE XXX_DT1 < DTE
END
-RPT_LOOP
------------------------------------------------------------------------------------------------- Blue Cross & Blue Shield of MS WF.76-10 on (WS2003 + WebSphere) / EDA on z/OS + DB2 + MS-SQL MRE, BID, Dev. Studio, Self-Service apps & a dash of fun !!
June 30, 2009, 04:15 PM
Darin Lee
you can't put an entire define within a repeat loop - each time the loop is executed the previous define will be erased. But the idea is feasible, although there's a much easier way to calculate your end-of month dates using DATEADD and DATEMOV.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
July 01, 2009, 11:37 AM
linus
You can do it in the following manner also -- this uses older subroutines. You could place it in a loop and index your &vars with .&ctr. Although the new functions are much easier to code.
-SET &REMAINDER = IMOD(&CURYR, 4, 'I3L');
-SET &EOM = IF ('&CLOSEMM.EVAL' EQ '02') AND (&REMAINDER EQ 0) THEN '29' ELSE
- IF ('&CLOSEMM.EVAL' EQ '02') AND (&REMAINDER NE 0) THEN '28' ELSE
- IF ('&CLOSEMM.EVAL' EQ '01' OR '03' OR '05' OR '07' OR '08' OR '10' OR '12') THEN '31' ELSE '30';
WF 7.7.05 HP-UX - Reporting Server, Windows 2008 - Client, MSSQL 2008, FOCUS Databases, Flat Files HTML, Excel, PDF
July 16, 2009, 04:37 PM
developing
Thanks to you all! I ended up using Darin's first suggestion. I appreciate the help!
WebFOCUS 7.6.10, Windows Vista, Oracle, Output-Excel/PDF/HTML
July 17, 2009, 10:24 AM
ira
Linus, I liked your suggestion, but if I can code less and get the same result - I choose that, so my take on your code would be the same except the last line would be:
quote:
-SET &REMAINDER = IMOD(&CURYR, 4, 'I3L'); -SET &EOM = IF ('&CLOSEMM.EVAL' EQ '02') AND (&REMAINDER EQ 0) THEN '29' ELSE - IF ('&CLOSEMM.EVAL' EQ '02') AND (&REMAINDER NE 0) THEN '28' ELSE - IF ('&CLOSEMM.EVAL' EQ '04' OR '06' OR '09') THEN '30' ELSE '31';
IraThis message has been edited. Last edited by: ira,
You can still calculate the end of month date for the last 12 months using dialogue manager and then compare your fields' values to those & vars.
So calculate in a loop the twelve dates, like &MTH1, &MTH2, etc..
That was what I was suggesting without giving too much away. Subtract a month from today's date and then move to end of month (times 12).
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat