Send attachement in email using CICS.

Customer Information Control System. Middleware and MQ Series.
Post Reply
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

Send attachement in email using CICS.

Post by Dino »

hi,

I know that we can send an email using mainframe in batch but can we send an email with an attachment using a CICS transaction? If we can do that, how can we do that? Please share your suggestion.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Send attachement in email using CICS.

Post by Robert Sample »

You need a TDQ in the CICS region that points to the internal reader (or use the CICS SPOOL interface commands). Your CICS program copies the batch JCL to the spool (or TDQ) and closes it (for TDQ) or uses SPOOLCLOSE. The batch JCL includes the usual copy to SMTP with the correct format for the attachment and boundaries and the rest of the email. The batch JCL could be hard-coded in the program or it could be read from a VSAM data set. Note that the manuals indicate putting more than 1000 lines of JCL into the spool could cause performance issues for the region (which would include all other users of that region).
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

Re: Send attachement in email using CICS.

Post by Dino »

Robert Sample wrote: Thu Feb 08, 2018 9:12 pmYou need a TDQ in the CICS region that points to the internal reader (or use the CICS SPOOL interface commands). Your CICS program copies the batch JCL to the spool (or TDQ) and closes it (for TDQ) or uses SPOOLCLOSE. The batch JCL includes the usual copy to SMTP with the correct format for the attachment and boundaries and the rest of the email. The batch JCL could be hard-coded in the program or it could be read from a VSAM data set. Note that the manuals indicate putting more than 1000 lines of JCL into the spool could cause performance issues for the region (which would include all other users of that region).
Thanks. So I shall have a COBOL CICS program having the entire JCL in it which it will copy to TDQ?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Send attachement in email using CICS.

Post by Robert Sample »

So I shall have a COBOL CICS program having the entire JCL in it which it will copy to TDQ?
Not necessarily -- reread my response. Your COBOL program could read a VSAM data set that has the JCL stored in it and copy that JCL to the TDQ. Or, you could use the EXEC CICS SPOOLOPEN, SPOOLWRITE, SPOOLCLOSE commands from the API.
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

Re: Send attachement in email using CICS.

Post by Dino »

Thanks Robert. I have not worked on this requirement as it was dropped and I could not follow up in this. I had been searching for an example where VSAM file can have a JCL and copy it to TDQ but I could not get one. How exactly this is done actually? We just create a VSAM, have just one record in it which is JCL to send the email? Is this correct?
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Send attachement in email using CICS.

Post by nicc »

A valid JCL is going to have more than one record. For example, it will contain at least a jobcard (probably spanning more than one record) and an exec statement (possibly spanning more than one record) and, possibly, a variety of DD statements (each probably spanning several records).
Regards
Nic
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Send attachement in email using CICS.

Post by Robert Sample »

I've seen this done two ways -- where the key of the KSDS is just a sequence number, and where the key of the KSDS is job name + sequence number (this application had multiple jobs that could be submitted from CICS). Each line (record) of JCL is stored in the KSDS as a separate record with its own unique sequence number. It is easiest when the entire 80-byte JCL record is stored in the KSDS. The CICS program reads each record of the KSDS sequentially (by job name if job name is part of the key), strips off the key, and writes the remaining part of the record to the TDQ. Changes to the JCL are usually accomplished by doing a delete / define of the KSDS.
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

Re: Send attachement in email using CICS.

Post by Dino »

Robert Sample wrote: Mon Jul 02, 2018 4:56 pmI've seen this done two ways -- where the key of the KSDS is just a sequence number, and where the key of the KSDS is job name + sequence number (this application had multiple jobs that could be submitted from CICS). Each line (record) of JCL is stored in the KSDS as a separate record with its own unique sequence number. It is easiest when the entire 80-byte JCL record is stored in the KSDS. The CICS program reads each record of the KSDS sequentially (by job name if job name is part of the key), strips off the key, and writes the remaining part of the record to the TDQ. Changes to the JCL are usually accomplished by doing a delete / define of the KSDS.
Thank you so much Robert. I shall try it now.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “CICS, Middleware and MQ Series.”