Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Record insertion from one file to another file.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Karthigaiselvan

New User


Joined: 11 Dec 2006
Posts: 35
Location: India

PostPosted: Mon Nov 26, 2007 12:19 pm    Post subject: Record insertion from one file to another file.
Reply with quote

Hi,

I've a requirement such that i need to insert some records read from a file into different places in another file. For example.

I've a File A with some static records as below,

Code:
000001 Dear Customer,
000002 Seasonal greetings!
000003 With warm regards, 
000004 Karthigaiselvan.


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?
Back to top
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Mon Nov 26, 2007 2:28 pm    Post subject:
Reply with quote

karthi,

May be you could tell us how many times does the code in FILEB repeats (is it only 3 three time as shown in example or more)?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Mon Nov 26, 2007 2:36 pm    Post subject: Reply to: Record insertion from one file to another file.
Reply with quote

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.

This is an untested code

Code:
//SYSIN    DD    *                                 
  SORT FIELDS=COPY                                 
  INREC IFTHEN=(WHEN=(1,7,CH,EQ,C'SUBJECT'),       
        BUILD=(1,80,/,C'DEAR CUSTOMER,')),         
        IFTHEN=(WHEN=(1,5,CH,EQ,C'WISH '),         
        BUILD=(1,80,/,C'WARM REGARDS'))           
/*                                                 



If this works you can add similar kind of steps for your requirement. I cannot test the above code as i dont have DFSORT installed in my shop icon_sad.gif
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Mon Nov 26, 2007 2:39 pm    Post subject:
Reply with quote

Aaru,

Quote:
BUILD=(1,80,/,C'DEAR CUSTOMER,')),

'/' is supported only in OUTFIL statement.
Back to top
View user's profile Send private message
Karthigaiselvan

New User


Joined: 11 Dec 2006
Posts: 35
Location: India

PostPosted: Mon Nov 26, 2007 2:58 pm    Post subject: Reply to: Record insertion from one file to another file.
Reply with quote

Quote:
Try this if your FileA content is going to be the same.


What i have given is a sample requirement and FILE A may contain lot of records. So is there any solution with out hard coding them?

Quote:
May be you could tell us how many times does the code in FILEB repeats (is it only 3 three time as shown in example or more)?


FILE B does not always contain emails 3 times. It's a random number.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Mon Nov 26, 2007 3:01 pm    Post subject: Reply to: Record insertion from one file to another file.
Reply with quote

murali,

Quote:
'/' is supported only in OUTFIL statement.


Oh ok Thanks. I guess a sort card for this requirement can be written using IFTHEN,OUTFIL,BUILD with '/'.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Nov 26, 2007 10:00 pm    Post subject:
Reply with quote

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))
/*
Back to top
View user's profile Send private message
Karthigaiselvan

New User


Joined: 11 Dec 2006
Posts: 35
Location: India

PostPosted: Tue Nov 27, 2007 11:06 am    Post subject:
Reply with quote

Thanks Frank,

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.

Could you please help with a DFSORT card?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Nov 27, 2007 11:42 pm    Post subject:
Reply with quote

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?
Back to top
View user's profile Send private message
Karthigaiselvan

New User


Joined: 11 Dec 2006
Posts: 35
Location: India

PostPosted: Wed Nov 28, 2007 8:25 am    Post subject: Reply to: Record insertion from one file to another file.
Reply with quote

Frank,

The file B will have RECFM = FB & RECL=80.
Yes. I'll have only 2 email id's and not more than that.

Thank you for your help!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Nov 29, 2007 12:08 am    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for with any two e-mail ids:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY,STOPAFT=1
  OUTREC BUILD=(C'Name1,''',12,30,C'''',80:X)
//S2    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//IN DD DSN=...  input file (FB/80)
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/80)
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT1) ON(82,8,ZD) KEEPBASE -
  WITHALL WITH(1,80) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(82:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,10,CH,EQ,C'MAIL FROM:',AND,
          12,30,CH,EQ,Name1),OVERLAY=(81:C'1'),HIT=NEXT),
        IFTHEN=(WHEN=(1,10,CH,EQ,C'MAIL FROM:',AND,
          12,30,CH,NE,Name1),OVERLAY=(81:C'2'),HIT=NEXT),
        IFTHEN=(WHEN=(1,10,CH,EQ,C'MAIL FROM:'),
                OVERLAY=(82:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(90:SEQNUM,8,ZD,
                         82:82,8,ZD,SUB,90,8,ZD,TO=ZD,LENGTH=8))
  OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'1'),
    BUILD=(1,80)
  OUTFIL FNAMES=OUT2,SAVE,
    BUILD=(1,80)
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us