Focal Point
Report Caster "Advanced" Advanced Schedule

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4741023332

June 19, 2007, 05:24 PM
Krysti
Report Caster "Advanced" Advanced Schedule
Hi,

I have a report set up in Report Caster that I need to run the next working day after the end of the month. So, if the last day of the month falls on a Friday, I need the report to run that Monday. If the last day of the month is Wednesday, I need the report to run Thursday.

This means I cannot schedule the report to run on a specific date and I cannot schedule the report to run on a specific day of the week.

I'm sure this is no simple solution to set this up, but does anyone know of any code or anything to do this?

Thanks for your help,

Krysti


WF 767
June 19, 2007, 05:56 PM
Prarie
What Version are you on. 7.6 is supposed to be able to do 1st Business Day processing...but I have not looked yet.


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Not sure about the 'first business day' feature in 7.6. Otherwise, you can use regular WebFOCUS code to calculate the first business day of the month, and then use Report Caster APIs to create the schedule. However, this would mean that you would use your own custom built interface for the application users.


Diptesh
WF 7.1.7 - AIX, MVS
In Report Caster, schedule the job to run every day. Then do the following.

FILEDEF RUNFEX DISK pathname/runfex.ftm ( LRECL 8 RECFM V
-RUN
-READ RUNFEX &RUNDT.8.
-RUN
-IF &RUNDT NE &YYMD THEN GOTO FINISHED;
.
.
. Your Fex
.
.
.
DEFINE FILE MACGYVER
RUNDT/YYMD=&YYMD;
NEXT_RUNDT/YYMD=DATEADD(DATEMOV(RUNDT,'EOM'),'BD',1);
END
-*
TABLEF FILE MACGYVER
SUM NEXT_RUNDT
WHERE COUNTER EQ 1
ON TABLE SAVE AS RUNFEX
END
-*
DEFINE FILE MACGYVER CLEAR
END
-RUN
-*
-FINISHED

We have a file name MACGYVER.FOC we use whenever we use the MACGYVER technique. For this purpose, you can use any file and just limit your read to 1 record. Note the 'BD' in DATEADD, that is for business days. The 'BD" parameter will take in to account holidays as well if you set up a Holiday file. For example, this year Labor Day (Sep 3rd) is the 1st Monday in September. Using the above, when you add 1 business day to August 31st, you will get Sept 3rd. However, if you set up a holiday file with with 20070903, you will get Sept 4th when adding 1 business day to Aug 31st.

Hope this helps.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
You ought to use the pre-process functionality of Report Caster schedules to achieve this - no need for a GOTO FINISHED.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
Thanks for the reply. I'm on version 7.14.


WF 767
Thank you for the code.

I'm not used to doing anything like this so I tried to modify it using my tables, but I'm not sure I even did it right.

When I run it I get the following error:

A VALUE IS MISSING FOR: &RUNDT

I'm not sure where the value for it is supposed to come from (?).

Here is my code - do you mind taking a look at it to see if it looks correct to you?

FILEDEF ftpcp020 DISK \\drummond\sys\share\transfer\database\ftpcp020.ftm ( LRECL 8 RECFM V
-RUN
-READ ftpcp020 &RUNDT.8.
-RUN
-IF &RUNDT NE &YYMD THEN GOTO FINISHED;
-
TABLE FILE AGENT
PRINT
COMPUTE COMP/A25 = '@drummondamerican.com'; NOPRINT
COMPUTE COMMA/A1 = ','; NOPRINT
COMPUTE COMMA/A1 = ','; NOPRINT
COMPUTE DOLLAR/A1 = '$'; NOPRINT
COMPUTE CONCAT/A40 = AGT_NUMBER||COMP||COMMA||AGT_NUMBER||COMMA||DOLLAR; AS ''
BY AGT_NUMBER NOPRINT
WHERE AGT_COMPCOD EQ '03';
WHERE AGT_TERM_FLAG NE '1';
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
END
-*
DEFINE FILE AGENT
RUNDT/YYMD=&YYMD;
NEXT_RUNDT/YYMD=DATEADD(DATEMOV(RUNDT,'EOM'),'BD',1);
END
-*
TABLEF FILE AGENT
SUM NEXT_RUNDT
WHERE RECORDLIMIT EQ 1
-*WHERE COUNTER EQ 1
ON TABLE SAVE AS RUNFEX
END
-*
DEFINE FILE AGENT CLEAR
END
-RUN
-*
-FINISHED


WF 767
Krysti,

Did you create your file? You need to initially create your file. Also, at the end, the ON TABLE SAVE AS RUNFEX should be ON TABLE SAVE AS ftpcp020. This is how the next run date gets saved.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
Thanks.

I did create the file, but I figured out it wasn't reading it because I didn't have it saved on the server and I don't have access to the server. Ugh! I'm trying to get access...

By the way, is there a way to print out the data from the saved file when doing the FILEDEF to see if it is reading the file? Does anyone know?

Thanks for all your help guys (and gals),

Krysti


WF 767
If you do not care about holidays this little code should work just use it as a preprocessing procedure. Schedule the job to run on the 1, 2, and 3 of each month
  
-SET &DAY = EDIT(&YMD, '$$$$99');
-SET &DAYOFWEEK = DOWK(&YYMD, 'A3');
-SET &KILL_RPC = IF &DAY EQ 1 AND (&DAYOFWEEK EQ 'MON' OR &DAYOFWEEK EQ 'TUE' OR &DAYOFWEEK EQ 'WED' OR &DAYOFWEEK EQ 'THU' OR &DAYOFWEEK EQ 'FRI')  THEN 'N' ELSE
-                 IF &DAY EQ 2 AND (&DAYOFWEEK EQ 'MON') THEN 'N' ELSE
-                 IF &DAY EQ 3 AND (&DAYOFWEEK EQ 'MON') THEN 'N' ELSE 'Y';

-TYPE &DAYOFWEEK 
-TYPE &DAY
-TYPE &KILL_RPC


The -TYPE in the code is just to see the variable values.

Hope this helps




Scott

From what I've read, to do the pre-processing, the file has to be saved on the server also. Is this not true or is there a way around it?

Thanks,

Krysti


WF 767
FILEDEF ftpcp020 DISK \\drummond\sys\share\transfer\database\ftpcp020.ftm ( LRECL 8 RECFM V
-RUN
-WRITE ftpcp020 20070702
-RUN

As for the pre-processing procedure you can use the following.

FILEDEF RUNFEX DISK pathname/runfex.ftm ( LRECL 8 RECFM V
-RUN
-READ RUNFEX &RUNDT.8.
-RUN
-SET &&KILL_RPC=IF &RUNDT EQ &YYMD THEN 'N' ELSE 'Y';

In doing some research on this, the only downside is that using &&KILL_RPC cause Report Caster to generate an error notification.

(I just love this board, I learn something new almost every day and I've been using FOCUS and WebFOCUS for over 20 years. I never knew about &&KILL_RPC.)

This message has been edited. Last edited by: jgelona,


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
Thanks for a way to test if it could see the file.

If I FTP the file first, it sees it!!

Thanks so much!

Now, I just have to figure out by the info you guys gave me the proper way to set it up.

Thanks again,

Krysti


WF 767
Ugh, my mistake! It doesn't see the file afterall....


WF 767