View previous topic :: View next topic
|
Author |
Message |
maki_psg
New User
Joined: 28 Jan 2010 Posts: 47 Location: India
|
|
|
|
Hi,
I have a requirement to combine the data from 2 files and create a new file. For e.g., I have the following data from 2 files.
File 1:-
ABCD 0001002
File 2:-
PQRS 1001 MAINFRAMEUSER 0009999
Now, I have to replace column - 0009999 from File 2 with the content of File 1 (00010002) and write it into another new file as shown below.
PQRS 1001 MAINFRAMEUSER 0001002
Please let me know how we can do it through DFSORT.
Thank you. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Is this one-to-one record merging? I mean first record value 0001002 should be overlaid to 0009999 value of File 2' first record and so on.
Or there are rules to merge? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
the info provided is not enough to provide any help |
|
Back to top |
|
|
maki_psg
New User
Joined: 28 Jan 2010 Posts: 47 Location: India
|
|
|
|
There will be only 1 record in each file. I would like to merge the record from each file into a new file as I mentioned above. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
if the problem is exactly as described and the two files have the same lrecl
this should work
Code: |
000004 //S1 EXEC PGM=ICEMAN
000005 //SYSOUT DD SYSOUT=*
000006 //SORTIN DD *
000007 ABCD 0001002
000008 // DD *
000009 PQRS 1001 MAINFRAMEUSER 0009999
000010 //SORTOUT DD SYSOUT=*,
000011 // DCB=(RECFM=FB,LRECL=80)
000012 //SYSIN DD *
000013 SORT FIELDS=COPY
000014 INREC IFTHEN=(WHEN=GROUP,
000015 BEGIN=(01,04,CH,EQ,C'ABCD'),PUSH=(25:06,7))
000016 OUTFIL OMIT=(01,04,CH,EQ,C'ABCD') |
output
Code: |
********************************* TOP OF DATA **********************************
PQRS 1001 MAINFRAMEUSER 0001002
******************************** BOTTOM OF DATA ******************************** |
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Alternatively you can use the following DFSORT's JOINKEYS job to get the desired results
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
ABCD 0001002
//INB DD *
PQRS 1001 MAINFRAMEUSER 0009999
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(81,1,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(81,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F2:1,24,F1:6,7,32,49)
//*
//JNF1CNTL DD *
OPTION STOPAFT=1
INREC OVERLAY=(81:C'A')
//*
//JNF2CNTL DD *
OPTION STOPAFT=1
INREC OVERLAY=(81:C'A')
//* |
|
|
Back to top |
|
|
|