IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to send an Email from a COBOL program.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Wed Feb 20, 2008 11:15 am
Reply with quote

Dear Experts,

My requirement is to send an automatic email to support services by using a new program, when an abend occurs in an existing COBOL-DB2 program.

To be in detailed:

I have a table ABC_LOCATION with the fields location_id, capacity, locaton_name. All are CHAR(3) And the table contains 12 rows as of now.

In my COBOL-DB2 program, I am retrieving the corresponding location_id and capacity depends on location_name coming from a file which is producing by Up-stream system.

There is another table XYZ_LOCATION which is the base table contains many fields includes location_id and locaton_name.

When ever a new location details are added into the table XYZ_location in the upstream system then my program will give an SQLCODE +100 because there is no row correspond to that new location in the table ABC_LOCATION

OfCourse, they need to do the impact analasys and to inform our team to do necessary amendments in our relative tables.

In the worst case scenario, To avoid the abending of the batch job which impacts all other down-stream batches, we are looking for a solution to write a program to send an automatic mail to support services and inform them to insert a new row into the table ABC_LOCATION and then rerun the job again.

Please suggest me the way to do this. I couldn't get any sample program in our system.
Back to top
View user's profile Send private message
shitij

New User


Joined: 09 Sep 2005
Posts: 31
Location: Delhi

PostPosted: Wed Feb 20, 2008 12:54 pm
Reply with quote

Hi mkk,


If i have understood ur problem correctly:

This can very well be done thru JCL itself (and making a minor change in ur current program)...Now whenever there is a new location thats currently not existing i.e. SQLCODE = 100...after SQLCODE=100 set a RETURN-CODE in the program to end ur pgm with ur desired choice of return code (that indicates a new entry is reqd...say may be return code of 88 or 99).

Once u get ur desired return code...in the jcl after the step which runs ur pgm add a new step that will run only if the previous return code is 88 or 99 (or whatever return code u wanted).

Pls note that this additional step would be a SMTP mail step that would send the mailer to all the reqd users...SMTP step i think u can easily get by following few SMTP jcl's in ur system.

I hope this might help u.

Regards,
Shitij
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Wed Feb 20, 2008 1:15 pm
Reply with quote

But shitij,

Thanks for ur reply.

I can get sample SMTP JCL from our system

To achieve this I need to make the content of the mail with the Location_id and capacity values which are coming from an upstream system file.
To do this, I need to amend the existing program, with some piece of code to retrieve and store those values as a content of the mail.

How should I proceed to achieve this with the help of a new program without amending the actual program .
Back to top
View user's profile Send private message
shitij

New User


Joined: 09 Sep 2005
Posts: 31
Location: Delhi

PostPosted: Wed Feb 20, 2008 2:41 pm
Reply with quote

Hi MKK,

I think u can send the content of a file via SMTP mail job (that is the contents stored in the new file which u will make)...actually i dont have any sample SMTP job to refer right now but i am +ve that contents of a file could be sent via mail.

All u need to do is write the info required to a new file (in ur existing pgm itself) and use that file as a part of SMTP step added.

Say the new file says:

"This is to inform you that WS-LOCATION-ID and WS-CAPACITY-VAL1, WS-CAPACITY-VAL2, WS-CAPACITY-VAL3 was missing in XXX Table and should be added to ASAP"

U can fill the WS- variables with the known value and write the file to a mail.


So a new file in ur present jobstep and this new file in the next SMTP step.

Hope i understood what u wanted.


Regards,
Shitij
Back to top
View user's profile Send private message
shitij

New User


Joined: 09 Sep 2005
Posts: 31
Location: Delhi

PostPosted: Wed Feb 20, 2008 3:19 pm
Reply with quote

Code:
//*=========================================
//**  SENDS E-MAIL TO ALL USERS DURING EXCEPTIONS       **
//*=========================================
//SENDNOTE EXEC PGM=IEBGENER,COND=(99,NE,STEP00X)
//SYSIN    DD DUMMY
//SYSPRINT DD SYSOUT=(,),OUTPUT=(*.SITE)
//SYSUT2   DD SYSOUT=(B,SMTP)
//SYSUT1   DD DSN=LIBNAME(MWMAILHR),DISP=SHR
//         DD DSN=NEWFILENAME(+1),DISP=SHR
//         DD DSN=LIBNAME(MWMAILTR),DISP=SHR
//*


Here is the sample SMTP job i was telling u about.


Regards,
Shitij
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Wed Feb 20, 2008 3:41 pm
Reply with quote

Thanks Shitji,

Its very helpful for me.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top