Hi everyone …
I know almost 0% about REXX, but am using an exec written about 16 years ago by a predecessor at my shop.
The function of the exec is used in a batch job to send data in a file created by a previous step in the same job to an SMTP gateway on one of the MVS communication server running an SMTP gateway.
This exec has worked fine all these years, but our users have requested that we include a few variables with the passing of the data that I do not believe are system variables (e.g. mvsvar('symdef','jobname')). The variables that are being requested are the JES2 job number and the job's condition code.
I was hoping that someone may have a suggestion on something relatively easy I could implement to grab the data from JES2 about the job that is creating this data using the existing exec I have. Here is the exec we're using today.
Thanks in advance for any suggestions!
I know almost 0% about REXX, but am using an exec written about 16 years ago by a predecessor at my shop.
The function of the exec is used in a batch job to send data in a file created by a previous step in the same job to an SMTP gateway on one of the MVS communication server running an SMTP gateway.
This exec has worked fine all these years, but our users have requested that we include a few variables with the passing of the data that I do not believe are system variables (e.g. mvsvar('symdef','jobname')). The variables that are being requested are the JES2 job number and the job's condition code.
I was hoping that someone may have a suggestion on something relatively easy I could implement to grab the data from JES2 about the job that is creating this data using the existing exec I have. Here is the exec we're using today.
Thanks in advance for any suggestions!
Code:
/* THIS COMMENT IS REQUIRED TO DENOTE THAT THIS IS A REXX EXEC */
PARSE UPPER ARG RECIPDSN BODYDSN
RECIPDSN = STRIP(RECIPDSN)
BODYDSN = STRIP(BODYDSN)
CALL INIT
CALL GET_RECIPIENTS
CALL GET_BODY_OF_NOTE
CALL BUILD_HEADER
CALL BUILD_BODY
CALL BUILD_TRAILER
CALL DISPLAY_IT
CALL MAIL_IT
EXIT
/*--------------------------------------------------------------------*/
INIT:
SYSID = mvsvar('sysname')
Sysplex = mvsvar('sysplex')
Jobname = mvsvar('symdef','jobname')
Userid = userid()
Jobname = translate(Jobname,'________________________________', ,
'~!@#$%¬&*()_+{}|:"<>?`-=¢¦\;'',./')
MAILTIME = Date('Normal') /* dd mon yyyy */ ,
Time('Normal') /* hh:mm:ss 24 hour */
SMTPTASK = 'TCPSMTP'
SMTPSYSID = SYSID
Select
When Sysplex = 'MVS1PLEX' Then SMTPSYSID = 'MVS1'
When Sysplex = 'MVS3PLEX' Then SMTPSYSID = /* 'MVS3' */ 'MVS5'
When Sysplex = 'MVS4PLEX' Then SMTPSYSID = /* 'MVS9' */ 'MVS5'
When Sysplex = 'MVS5PLEX' Then SMTPSYSID = 'MVS5'
When Sysplex = 'MVS7PLEX' Then SMTPSYSID = /* 'MVS7' */ 'MVS5'
When Sysid = 'MVS8' Then SMTPSYSID = /* 'MVS8' */ 'MVS5'
When Sysplex = 'Y2KPLEX' Then SMTPSYSID = /* 'MT2K' */ 'MVS5'
Otherwise
SMTPSYSID = 'MVS5'
end; /* select */
RETURN
/*--------------------------------------------------------------------*/
GET_RECIPIENTS:
/* Read the recipient file into array "RECIP." */
ADDRESS TSO "ALLOCATE DD(RECIPDD) DATASET('"RECIPDSN"') SHR"
"EXECIO * DISKR RECIPDD (STEM RECIP. FINIS)"
ADDRESS TSO "FREE DD(RECIPDD)"
SAY RECIP.0 'RECIPIENTS READ'
/* Clean up recipients ID's */
DO I = 1 TO RECIP.0
RECIP.I = STRIP(RECIP.I)
PARSE UPPER VAR RECIP.I NODE.I '.' NAME.I
If index(RECIP.I,'RSCS1.') Then Do
RECIP.I = Substr(RECIP.I,7,80)
End
If index(RECIP.I,'OCWVM.') Then Do
RECIP.I = Substr(RECIP.I,7,80)
End
If index(RECIP.I,'OCBVM.') Then Do
RECIP.I = Substr(RECIP.I,7,80)
End
If index(RECIP.I,'N14.') Then Do
RECIP.I = Substr(RECIP.I,5,80)
End
If index(RECIP.I,'N15.') Then Do
RECIP.I = Substr(RECIP.I,5,80)
End
If index(RECIP.I,'VM4.') Then Do
RECIP.I = Substr(RECIP.I,5,80)
End
If index(RECIP.I,'VM5.') Then Do
RECIP.I = Substr(RECIP.I,5,80)
End
RECIP.I = strip(RECIP.I)
/* If ID doesn't have an '@' then default recipients to DOMAIN.com */
If index(RECIP.I,'@') = 0 Then Do
RECIP.I = RECIP.I||'@DOMAIN.Com'
End
END
RETURN
/*--------------------------------------------------------------------*/
GET_BODY_OF_NOTE:
ADDRESS TSO "ALLOCATE DD(BODYDD) DATASET('"BODYDSN"') SHR"
"EXECIO * DISKR BODYDD (STEM BODY. FINIS)"
ADDRESS TSO "FREE DD(BODYDD)"
SAY BODY.0 'LINES OF TEXT BODY READ'
If BODY.1 = 'BODY.1' Then BODY.1 = ' '
If BODY.2 = 'BODY.2' Then BODY.2 = ' '
RETURN
/*--------------------------------------------------------------------*/
BUILD_HEADER:
WORK.1 = 'HELO' SMTPSYSID||'.DOMAIN.COM' /* no space */
WORKSUB = 2 /* subscript for work arry */
WORK.WORKSUB = 'MAIL FROM: <'||sysid||'.'||jobname||'@DOMAIN.com>'
WORKSUB = WORKSUB + 1
DO I = 1 TO RECIP.0
WORK.WORKSUB = 'RCPT TO: <'||RECIP.I||'>'
WORKSUB = WORKSUB + 1
END
WORK.WORKSUB = 'DATA' /* end of SMTP commands */
WORKSUB = WORKSUB + 1
WORK.WORKSUB = 'Date:' MAILTIME 'GMT'
WORKSUB = WORKSUB + 1
WORK.WORKSUB = 'From:' sysid||'.'||jobname strip(BODY.1)
WORKSUB = WORKSUB + 1
DO I = 1 TO RECIP.0
WORK.WORKSUB = 'TO:' RECIP.I
WORKSUB = WORKSUB + 1
END
WORK.WORKSUB = 'SUBJECT:' strip(BODY.2)
WORKSUB = WORKSUB + 1
RETURN
/*--------------------------------------------------------------------*/
BUILD_BODY:
If index(BODY.3,':') > 0 then do
WORK.WORKSUB = ' '
WORKSUB = WORKSUB + 1
end
DO I = 3 TO BODY.0
If BODY.I = '.' Then Do
BODY.I = ' ' || BODY.I
End
WORK.WORKSUB = BODY.I
WORKSUB = WORKSUB + 1
END
RETURN
/*--------------------------------------------------------------------*/
BUILD_TRAILER:
WORK.WORKSUB = '_____' /* '' caused note to terminate ' ' is ok */
WORKSUB = WORKSUB + 1
WORK.WORKSUB = '.'
/* WORKSUB = WORKSUB + 1 not for last line */
RETURN
/*--------------------------------------------------------------------*/
DISPLAY_IT:
SAY('The following note is about to be sent:')
SAY('')
DO I = 1 TO WORKSUB
SAY(WORK.I)
END
SAY('')
RETURN
/*--------------------------------------------------------------------*/
MAIL_IT:
SAY('About to mail to:' SMTPSYSID||'.'||SMTPTASK)
ADDRESS TSO "ALLOCATE DD(PROFSDD) SYSOUT(B) ,
DEST("SMTPSYSID") WRITER("SMTPTASK")"
"EXECIO * DISKW PROFSDD (STEM WORK. FINIS"
ADDRESS TSO "FREE DD(PROFSDD)"
RETURN