H DFTACTGRP(*NO) OPTION(*SRCSTMT: *NODEBUGIO) BNDDIR('UTILITIES') ?******************************************************************************************* ?* Program: EMAILPDF * ?* Desc: Convert Spooled file to PDF and email back to user * ?* * ?* Date Who What * ?* ---------- --- ---- * ?* 12/15/2016 JJF Program created * ?******************************************************************************************* f*usid if e k disk usropn d ccsid s 10U 0 INZ(1252) d Count s 10i 0 inz d CRLF c CONST(X'0d25') d CurrentUser s 10 inz d Decimal6 s 6 0 inz d DefaultEmail s 100 inz('jamieF@rockfordballscrew.com') d ErrorReturned s n inz d FMTNM s 8a d Inuser s 10 d Inapplication s 20 d Insubject s 80 d Inmessage s 512 d INTJOB s 16a d INTSPL s 16a d KeepLooping s n inz('1') d MyTableName s 36 inz d SpoolFound s n inz('0') d SpoolNumber s 6a inz d today s d datfmt(*iso) inz d Usrdta s 10a inz d SpoolInfo ds d Function 10 d RecordType 2 d QualJobName 26 d JobName 10 Overlay(QualJobName:1) d JobUser 10 Overlay(QualJobName:11) d JobNumber 6 Overlay(QualJobName:21) d FileName 10 d FileNumber 10i 0 d QualQueueName 20 d QueueName 10 Overlay(QualQueueName:1) d QueueLibrary 10 Overlay(QualQueueName:11) d Filler 56 d $ReadDataq pr extpgm('QRCVDTAQ') d queuename_ 10 const d queuelibrary_ 10 const d queuesize_ 5 0 const d queuemessage_ 128 const d queuewait_ 5 0 const /copy qprcsrc,COMMAND_CP /copy qprcsrc,GETGUID_CP /copy qprcsrc,GETEMLA_CP /copy qprcsrc,GETUSDD_CP /copy qprcsrc,SDEMAIL_CP /copy qprcsrc,SPL2PDF_CP /free *inlr = *on; exsr $ProcessDataQueue; //-------------------------------------------------------- // loop forever looking for spooled files to convert //-------------------------------------------------------- begsr $ProcessDataQueue; dow KeepLooping; $ReadDataq('EMAILPDF':'*LIBL':128: SpoolInfo: -1); Decimal6 = %dec(FileNumber:6:0); SpoolNumber = %editc(Decimal6:'X'); // get the PDF name MyTableName = GetGuid(); // set the path and name of document FullPathToPDF = '/tmp/' +%trim(MyTableName) + '.pdf'; // new spooled file has arrived ErrorReturned = SpoolToPDF(FileName:Jobnumber:JobUser:JobName: SpoolNumber:FullPathtoPDF:QueueName); if not(ErrorReturned); exsr $sendTHeEmail; // delete the spooled file // DLTSPLF FILE(EMAILPDF) JOB(588743/MSFLANARY/QPADEV0003) SPLNBR(*LAST) OneThousandLong = 'DLTSPLF FILE(' + %trim(filename) + ') JOB(' + %trim(JobNumber) + '/' + %trim(JobUser) + '/' + %trim(JobNAME) + ') SPLNBR(*LAST)'; monitor; runcommand(OneThousandLong); on-error; endmon; endif; enddo; endsr; //-------------------------------------------------------- // send the report out via email //-------------------------------------------------------- begsr $SendTheEmail; // get email address defaultemail = GetEmailAddress(Jobuser); if defaultemail = *blanks; reset defaultemail; endif; // possible 20 email addresses -- unsure of default email (correct later) mydata.emailaddresses.address(1) = %trim(defaultemail); mydata.emailaddresses.type(1) = '*PRI'; // possible 10 attachments (see procedure for full list of types) mydata.attachments.fullpath(1) = %trim(FullPathToPDF); mydata.attachments.type(1) = '*PDF'; mydata.subject = 'RBS Auto Report Distribution'; mydata.body = 'Please review attached document.'; sendemail(Mydata.allmydata); endsr; /end-free