Subscribe to keep this site alive! Under new management but as always, still 100% FREE. Anyone with the IBM i is a friend of ours.
The Challenge: Create a function that would write the Distribution List in the bottom of the report based on a table (P4DLEMAIL) fed with the &REPORTNAME. While assembling the distribution list, the entries are logged in P4CCLOG with the Job Details and report name. After updating the spool file on disk (SPOOLNFILE), the physical file is copied to the IFS for emailing to the list of emails previously saved/logged in P4CCLOG.
When you print any report and CPYSPLF the report to the work file SPOOLNFILE, this function will append the following records:
The Solution: We will learn to define two files in this exercise: P4DLEMAIL and P4CCLOG. The P4CCFOOTER function is being created will have a 32-byte parameter passed to it which will contain the report name, which will be the value to fetch the records in the P4DLEMAIL. It is assumed that the SPOOLNFILE (using CRTPF at 198 in length) will be already populated with the report being transmitted using CPYSPLF.
The records selected are posted to the P4CCLOG file along with the Job Details captured in the Program Status Data Structure. The "cc" email addresses will be appended o the report and he bcc will only contain a count on the footer.
The P4SNDEMAIL (CLP) program will receive the &REPORTNAME as a parameter which will be used to select records from the P4CCLOG previously updated P4CCFOOTER along with the job details as retrieved using the RTVJOBA CL Command. The records selected will be put into a work file which will be the basis for The updated SPOOLNFILE will be sent to the IFS for attachment to the IFS and eventually attached to the email (SNDSMTPEMM) sent using the list from the generated work file from the P4CCLOG.
Do you have a new CHALLENGE? Let us know HERE.