/* */ /* SPLF2EMAIL: A basic means of e-mailing AS/400 spoolfiles... */ /* */ SPLF2EMAIL: PGM PARM(&PQJOB &PSPLFNAM &PSPLFNBR &PINTNETADR + &PMSG) DCL VAR(&PQJOB) TYPE(*CHAR) LEN(26) /* Qualified job + name... */ DCL VAR(&PSPLFNAM) TYPE(*CHAR) LEN(10) /* Spoolfile + name... */ DCL VAR(&PSPLFNBR) TYPE(*CHAR) LEN(4) /* Spoolfile + number... */ DCL VAR(&PINTNETADR) TYPE(*CHAR) LEN(253) /* Recipient + internet address... */ DCL VAR(&PMSG) TYPE(*CHAR) LEN(256) /* An additional + message to go with the spoolfile... */ /* */ /* Spoolfile name and number... */ /* */ DCL VAR(&SPLFNAM) TYPE(*CHAR) LEN(10) DCL VAR(&SPLFNBR) TYPE(*DEC) LEN(5) /* Spoolfile number: *CHAR... */ DCL VAR(&SPLFNBR_C) TYPE(*CHAR) LEN(5) /* Recipient internet address... */ DCL VAR(&INTNETADR) TYPE(*CHAR) LEN(253) /* A message to go with the spoolfile... */ DCL VAR(&MSG) TYPE(*CHAR) LEN(256) /* */ /* Break out the qualified job name... */ /* */ DCL VAR(&JOB) TYPE(*CHAR) LEN(10) DCL VAR(&JOBUSER) TYPE(*CHAR) LEN(10) DCL VAR(&JOBNBR) TYPE(*CHAR) LEN(6) /* */ /* Spoolfile attributes, used to find spoolfile record length... */ /* */ DCL VAR(&SPLFA) TYPE(*CHAR) LEN(1142) /* Used for spoolfile record length... */ DCL VAR(&RLEN) TYPE(*DEC) LEN(9) /* */ /* Temporary workfile and folder names... */ /* */ DCL VAR(&SPLFPF) TYPE(*CHAR) LEN(10) + VALUE(#$SPLFPF) DCL VAR(&SPLFFLR) TYPE(*CHAR) LEN(12) + VALUE(#$SPLF.FLR) /* Working document name... */ DCL VAR(&DOCNAM) TYPE(*CHAR) LEN(12) /*---------------------------------------------------------------------------*/ /* */ /* Global monitor message... */ /* */ MONMSG MSGID(CPF0000 CPF9999 MCH0000) EXEC(GOTO + CMDLBL(STDERR)) /*---------------------------------------------------------------------------*/ /* */ /* Get parameter values into working fields... */ /* */ CHGVAR VAR(&JOB) VALUE(%SST(&PQJOB 1 10)) CHGVAR VAR(&JOBUSER) VALUE(%SST(&PQJOB 11 10)) CHGVAR VAR(&JOBNBR) VALUE(%SST(&PQJOB 21 6)) CHGVAR VAR(&INTNETADR) VALUE(&PINTNETADR) CHGVAR VAR(&MSG) VALUE(&PMSG) CHGVAR VAR(&SPLFNAM) VALUE(&PSPLFNAM) CHGVAR VAR(&SPLFNBR) VALUE(%BIN(&PSPLFNBR)) /* */ /* Convert special-values for *ONLY and *LAST... */ /* */ IF COND(&SPLFNBR *EQ 0) THEN(DO) CHGVAR VAR(&SPLFNBR_C) VALUE('*ONLY') ENDDO ELSE CMD(IF COND(&SPLFNBR *EQ -1) THEN(DO)) CHGVAR VAR(&SPLFNBR_C) VALUE('*LAST') ENDDO ELSE CMD(DO) CHGVAR VAR(&SPLFNBR_C) VALUE(&SPLFNBR) ENDDO /* */ /* Get Spoolfile Attributes structure for the specified spoolfile name and */ /* number and job name. Note that job name '*' can't be broken out into */ /* its qualified parts (unless we retrieve the current job's name first)...*/ /* */ IF COND(&PQJOB *EQ '*') THEN(DO) RTVSPLFAST SPLFA(&SPLFA) JOB(*) SPLFNAM(&SPLFNAM) + SPLFNBR(&SPLFNBR) ENDDO ELSE CMD(DO) RTVSPLFAST SPLFA(&SPLFA) JOB(&JOBNBR/&JOBUSER/&JOB) + SPLFNAM(&SPLFNAM) SPLFNBR(&SPLFNBR) ENDDO /* Extract the spoolfile record length... */ CHGVAR VAR(&RLEN) VALUE(%BIN(&SPLFA 429 4) + 1) /* */ /* Delete any temporary workfile we might've created earlier... */ /* */ DLTF FILE(QTEMP/&SPLFPF) MONMSG MSGID(CPF2105) /* Create a workfile appropriate to our current spoolfile... */ CRTPF FILE(QTEMP/&SPLFPF) RCDLEN(&RLEN) /* */ /* Copy our current spoolfile into our temporary workfile. Note that we use */ /* *FCFC for forms control. Note that job name '*' can't be broken out into*/ /* its qualified parts (unless we retrieve the current job's name first)...*/ /* */ IF COND(&PQJOB *EQ '*') THEN(DO) CPYSPLF FILE(&SPLFNAM) TOFILE(QTEMP/&SPLFPF) + SPLNBR(&SPLFNBR_C) CTLCHAR(*FCFC) ENDDO ELSE CMD(DO) CPYSPLF FILE(&SPLFNAM) TOFILE(QTEMP/&SPLFPF) + JOB(&JOBNBR/&JOBUSER/&JOB) + SPLNBR(&SPLFNBR_C) CTLCHAR(*FCFC) ENDDO /* */ /* Delete any temporary work folder we might've created earlier... */ /* */ DLTDLO DLO(&SPLFFLR) MONMSG MSGID(CPF8A16) /* Create a work folder for our spoolfile document... */ CRTFLR FLR(&SPLFFLR) MONMSG MSGID(CPF8A18) /* Create a document name based on spoolfile name... */ CHGVAR VAR(&DOCNAM) VALUE(%SST(&SPLFNAM 1 8) *TCAT + '.TXT') /* */ /* Get our spoolfile from our workfile into our work document... */ /* */ CPYTOPCD FROMFILE(QTEMP/&SPLFPF) TOFLR(&SPLFFLR) + TODOC(&DOCNAM) REPLACE(*YES) SNDDST TYPE(*DOC) TOINTNET((&INTNETADR)) + DSTD('AS/400 report') MSG(&MSG) + DOC(&DOCNAM) FLR(&SPLFFLR) /* */ /* General cleanup before exit... */ /* */ DLTF FILE(QTEMP/&SPLFPF) DLTDLO DLO(&DOCNAM) FLR(&SPLFFLR) DLTDLO DLO(&SPLFFLR) RETURN /* */ /* Standard error processing... */ /* */ STDERR: MOVDIAGMSG MONMSG MSGID(CPF0000 MCH0000) RSNESCMSG MONMSG MSGID(CPF0000 MCH0000) RETURN ENDPGM