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

copy a record from file-1 to file-2


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Dec 22, 2011 3:12 pm
Reply with quote

Hello
I have two input files.

File-1 --> FB,LRECL=80
Code:

ABCDEFGHIJKLMNO


File-2 --> FB,LRECL=80
Code:

111
222
333
444
555
NNN


Expected output
Code:

111
222
333
444
555
NNN ABCDEFGHIJKLMNO


File-1 will always have one single record of the length 15 bytes.
and want this single record to be copied to file-2 whenever first three bytes in file-2 is 'NNN'. File tow will always have only one single occurence of 'NNN' at position 1.

Thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Dec 22, 2011 4:31 pm
Reply with quote

i can think of two ways to do this:

1. use two sort steps.
a. sort step one: create a SYMNAME out of file 1.
b. sort step two: COPY file 2 to file 3 with IFTHEN nnn then overlay with SYMNAME constant created in step one.

2. use JOINKEYS with a J1CNTL that creates NNN........

in the future, use the PREVIEW button, and 'desk check' your post
before SUBMIT.
one place, file 1 is 80, and in another you say file 1 is 15.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Dec 22, 2011 5:27 pm
Reply with quote

@dbzTHEdinosauer
Thanks for the reply

File-1 has LRECL = 80, but the only record in the file is of 15 bytes.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Dec 22, 2011 5:35 pm
Reply with quote

techslam wrote:
@dbzTHEdinosauer
Thanks for the reply

File-1 has LRECL = 80, but the only record in the file is of 15 bytes.


That makes absolutely no sense...........................................
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Thu Dec 22, 2011 6:10 pm
Reply with quote

Hello,

Assuming the record has constant value as NNN

Code:
//STEP1 EXEC PGM=ICETOOL                                               
//IN1      DD *                                                         
ABCDNNNNN                                                               
//IN2      DD *                                                         
111                                                                     
222                                                                     
333                                                                     
444                                                                     
555                                                                     
NNN                                                                     
//OUT1     DD SYSOUT=*                                                 
//DFSMSG DD SYSOUT=*                                                   
//TOOLMSG DD SYSOUT=*                                                   
//TOOLIN DD *                                                           
  COPY FROM(IN2) TO(OUT1) USING(CTL2)                                   
  COPY FROM(IN1) TO(OUT1) USING(CTL1)                                   
/*                                                                     
//CTL1CNTL DD *                                                         
  INREC OVERLAY=(5:1,15,4:X,1:C'NNN')                                   
/*                                                                     
//CTL2CNTL DD *                                                         
  SORT FIELDS=(1,3,CH,A)                         
  OMIT COND=(1,5,CH,EQ,C'NNN  ')                 
/*


Try and let us know

Note: This is not a perfect solution, if the value 'NNN' is not constant maybe Joins could help you as DBz post (if it is dynamic) this is just handy to met the criteria.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Dec 22, 2011 6:16 pm
Reply with quote

dbzTHEdinosauer wrote:
techslam wrote:
@dbzTHEdinosauer
Thanks for the reply

File-1 has LRECL = 80, but the only record in the file is of 15 bytes.


That makes absolutely no sense...........................................

To a sotfware engineer, it does; the 65 trailing spaces are somehow "not really" part of the record.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Dec 22, 2011 6:39 pm
Reply with quote

@xknight

My file-2 does not have any key field.
Actually my file 2 has an email text as below :
Code:

Hi Team,
Todays key value  is xxxxxxxxxxxxxxx


Here the XXXXXXXXXXXXXXX is to be replaced with the 15 bytes data from file-1
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Thu Dec 22, 2011 7:15 pm
Reply with quote

Hello,

Can you post the e-mail text with the position layout, so we wouldn't need to assume the position for 15 digit data.

If you need to try on your own, using (INREC) you shall validate and extract the values (OUTREC FIELDS) from desired position and send it to the file as we needed.

Need help in assistance, please post the layout and content.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 22, 2011 7:37 pm
Reply with quote

Another possibility. As dbz has said, you can put in a step to generate the symnames, this time from your outline text file. Lots of ways to crack an egg, if we know it is an egg.

Code:

//EMAILREF EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SYMNAMES DD *                                 
TEXT-LINE-1,'HI TEAM'                           
TEXT-LINE-2,'TODAYS KEY VALUE  IS '             
//SORTIN   DD *                                 
123456789012345                                 
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                 
  OPTION COPY                                   
  OUTFIL BUILD=(1:TEXT-LINE-1,/,TEXT-LINE-2,1,15)
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Dec 22, 2011 9:19 pm
Reply with quote

techslam,

use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
HI TEAM,                                                         
----+----1----+----2----+----3----+----4----+----5----+----6----+
TODAYS KEY VALUE  IS ABCDEFGHIJKLMNO                             
//SORTOUT  DD DSN=&&SYM,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)     
//SYSIN    DD *                                                 
  OPTION COPY,SKIPREC=1,STOPAFT=1                               
  INREC BUILD=(C'KEYVAL,C',C'''',22,15,C'''',80:X)               
//*                                                             
//STEP0200 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SYMNAMES DD DSN=&&SYM,DISP=SHR                                 
//SORTIN   DD *                                                 
111                                                             
222                                                             
333                                                             
444                                                             
555                                                             
NNN                                                             
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'NNN'),OVERLAY=(5:KEYVAL))     
//*


Bill,

IMHO using Joinkeys for this job would be an overkill
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 22, 2011 9:26 pm
Reply with quote

Readily conceded. You certainly don't need the H, in my opinion :-)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Dec 22, 2011 9:31 pm
Reply with quote

Kolusu wrote:
Bill,

IMHO using Joinkeys for this job would be an overkill


i think i am going to duck under this one.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Sun Dec 25, 2011 2:48 pm
Reply with quote

@Skolusu

Thanks a lot. This is exactly what I wanted. Appreciate it.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top