I've another File B containing multiple email records as below.
Code:
000001 MAIL FROM: <karthi@yahoo.com>
000002 RCPT TO: <emailid01@yahoo.com>
000003 DATA
000004 SUBJECT: My Best Wishes
000005
000006 Wish you & your family a very best new year.
000007 .
000008 MAIL FROM: <karthi@yahoo.com>
000009 RCPT TO: <emailid02@yahoo.com>
000010 DATA
000011 SUBJECT: My Best Wishes
000012
000013 Wish you & your family a very best new year.
000014 .
000015 MAIL FROM: <karthi@yahoo.com>
000016 RCPT TO: <emailid03@yahoo.com>
000017 DATA
000018 SUBJECT: My Best Wishes
000019
000020 Wish you & your family a very best new year.
000021 .
A full stop(.) in row# 7,14,21 and so on, donotes the end of each email. Now each mail should go as per
below sample.
Code:
MAIL FROM: <karthi@yahoo.com>
RCPT TO: <emailid01@yahoo.com>
DATA
SUBJECT: My Best Wishes
Dear Customer,
Seasonal greetings!
Wish you & your family a very best new year.
With warm regards,
Karthigaiselvan.
Hence, i need to read the records from File A and insert each record read in appropriate rows into multiple emails from another file B. This is just a sample requirement. Insertion rule from File A to B can be assumed as based on the row #. For example, record #1 from File A needs to be inserted in every 7th row starting from 6th row (i.e.13th, 20th, etc). Could any one please help if this can be achieved using DFSORT?
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
Karthi,
Try this if your FileA content is going to be the same.
Use a SORT step with File B as input. Use IFTHEN and BUILD to check for SUBJECT (7 bytes fom col 1) and WISH (4 bytes from col 1). If found add a new line using ("/") and then the strings that need to be added.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Karthigaiselvan,
You haven't made it very clear what you want in the way of a "general solution", but here's a DFSORT job that will do the specific task you showed in your example. Hopefully, you can extrapolate that to other similar tasks.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
Dear Customer,
Seasonal greetings!
With warm regards,
Karthigaiselvan.
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
* Create an Snn,'string' DFSORT symbol for each line in input file1
OUTREC BUILD=(C'S',SEQNUM,2,ZD,C',''',1,40,C'''',80:X)
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD *
MAIL FROM: <karthi@yahoo.com>
RCPT TO: <emailid01@yahoo.com>
DATA
SUBJECT: My Best Wishes
Wish you & your family a very best new year.
.
MAIL FROM: <karthi@yahoo.com>
RCPT TO: <emailid02@yahoo.com>
DATA
SUBJECT: My Best Wishes
Wish you & your family a very best new year.
.
MAIL FROM: <karthi@yahoo.com>
RCPT TO: <emailid03@yahoo.com>
DATA
SUBJECT: My Best Wishes
Wish you & your family a very best new year.
.
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
* Use the Snn symbols created in step S1 to insert lines
OUTFIL IFOUTLEN=80,
IFTHEN=(WHEN=(1,40,CH,EQ,C' '),
BUILD=(1,80,/,S01,/,S02)),
IFTHEN=(WHEN=(1,8,CH,EQ,C'Wish you'),
BUILD=(1,80,//,S03,/,S04))
/*
I think I can explore this to my exact requirement.
I've another requirement. In the same File B as discussed in this thread,
I want to split into 2 files based an "From Email ID". That is, File B contains set of emails having 2 different "From Email ID's" totally.
For example, Mails having FROM: <karthi@yahoo.com> should be written into an o/p file (Say File1). Mails having FROM: <vikki@yahoo.com> should be written into another o/p file (Say File2). Assume that full stop is the end of each mail.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
For your new requirement: What is the RECFM and LRECL of file B?
Do you only have two different e-mail addresses in the file? Or can there be more? If more, what is the maximum number of e-mail addresses in the file?