End-Job task to send a report file

This example shows an $end_job_tasks sequence which e-mails a report file to a bureau client.  This would typically be used when the bureau user wishes to have a job report file which can be loaded into Excel for further analysis.

The first step is to specify a batch file to be run at end of job.  This batch file will normally reside in the Program Files\Copia folder but need not do so.  The batch file will be passed the path and basename of the current job, defined in variable FFCJOB. The following command is normally entered in the system or owner UJP file, depending on the scope you require:

$end_job_tasks "CMD /c @PFC\EOJREPT.CMD ""@FFCJOB""" 0

The command file has two tasks, first to extract the data for the job using JOBXDATA and second to use the job NotifyFS function to send the e-mail to the bureau client.  The EOJREPT command file contains the following commands to do these tasks:




The JOBXDATA command above creates an extracted data file named JOBxxxxx.TAB in the same folder as the job instance properties. This contains the fields extracted as specified by default in JXFIELDS.LST or overridden by the field list specified on an $extract_fields command.  You could equally use JOBDDATA to extract data into a .DBF file.

The JOBCALL command above calls the job function library NotifyFS function. The NOBATCH parameter discards the result of the call (see below for an alternative).  The first parameter to the NotifyFS action is the job path and base name, and the second is the template FS file which will be used to send the report.

The NotifyFS action requires a template FS file which should be created as follows:

No $fax_user command is needed, the Job Instance UJP filename will always be inserted

$email_address must be specified and a ? parameter will cause it to be filled from $notify_email in the job properties. Note that $notify_fax should not be specified for bureau clients to whom you wish to e-mail a report.

$email_from and $email_esender must be specified and a ? parameter will cause them to be filled from $email_esender and $email_from in FAXFACTS.CFG.

$email_attach must attach the generated report file.

$email_body should specify an e-mail body but will use first the file from $report_embody if present, or "`FFJOBS\EMREPORT.TXT" if not specified and that file is present. The email body can use normal variable expansion to report job information such as `JOB_TOTAL, `JOB_SENT, `JOB_FAIL, etc.

A typical template file would therefore be as follows:


$email_address  ?   ; from $notify_email [UJP]

$email_from     ?   ; from $email_from [CFG]

$email_esender  ?   ; from $email_esender [CFG]

$email_body     ?   ; from $report_embody [UJP] or `FFJOBS\EMREPORT.TXT

$email_subject  "Report for JOB `JOB_INSTANCE"

$email_attach   "`FFCJOB.TAB" "text/tab-separated-values"

The success or failure of the report transmission will be recorded in the job item status in JOBADMIN.  Normally once the command and template files above have been written and tested the submission of the job report can be assumed to have succeeded, but to detect and report submission failure, replace the NOBATCH above with "%1.CMD" and then execute this batch file on the next line of EOJREPT.CMD.  You can then test the value of the JOBCALL environment variable to determine the result of the call. For more information, see JOBCALL.