Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

copy a record from file-1 to file-2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: copy a record from file-1 to file-2
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Thu Dec 22, 2011 6:16 pm    Post subject:
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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Dec 22, 2011 7:37 pm    Post subject: Reply to: copy a record from file-1 to file-2
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    Post subject: Reply to: copy a record from file-1 to file-2
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Dec 22, 2011 9:26 pm    Post subject: Reply to: copy a record from file-1 to file-2
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    Post subject:
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    Post subject:
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    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 syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us