Sunday, 12 July 2026

Sending reports via email in the Web interface, continued

Continuing from what I wrote1 the other day, I have converted the code to be a trigger within the 'func' screen (i.e. a library of routines) to make life easier for any procedure that needs this functionality. Thus within 'func' there is now a trigger called PRIV_WEBSENDEMAIL.

/* PRIV_WEBSENDEMAIL- No'am, 09/07/26 send a report by email to a group in the web interface. Inputs: PAR1: report name PAR2: group name */ SELECT SQL.TMPFILE INTO :PRIV_FILESIZE FROM DUMMY ; LINK STACK TO :PRIV_FILESIZE ; GENMSG 1001 WHERE :RETVAL @lt;= 0; :PRIV_TMPFILE = '' ; SELECT STRCAT (SQL.TMPFILE, '.HTML') INTO :PRIV_TMPFILE FROM DUMMY; EXECUTE ACTIVATF '-R', :PAR1, '-o', :PRIV_TMPFILE; EXECUTE GETSIZE :PRIV_TMPFILE, :PRIV_FILESIZE; GOTO 99 WHERE NOT EXISTS ( SELECT 1 FROM STACK WHERE ELEMENT > 0); MAILMSG 600 TO GROUP :PAR2 DATA :PRIV_TMPFILE ; LABEL 99; UNLINK AND REMOVE STACK;

This trigger is invoked in a procedure as follows

/* Send report by email */ :PAR1 = 'PRIV_IMPORT_ORDSON'; :PAR2 = 'SPORDER'; GOTO 1 WHERE :SQL.NET = 1; EXECUTE WINACTIV '-R', :PAR1, '-g', :PAR2; GOTO 2 ; LABEL 1; #INCLUDE func/PRIV_WEBSENDEMAIL LABEL 2;

The only other definition that is required and is not described above is message #600 in the calling procedure; this message will be used as the title for the email sent from the web interface. This is because the message number passed to mailmsg has to be a numeric literal and not a variable.

Internal links
[1] 141

No comments:

Post a Comment