View previous topic :: View next topic
|
Author |
Message |
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
I have two files (LRECL=80, RECFM=FB). There are 10 records in file-1 and 1000 records in file-2. There are 5 matching records between file-1 and file-2.
FILE-1:
Code: |
----+----+----+----+----+----+----+----+----+----+
KEY000 35S960 FIADXERAC%!
KEY111 010K23 XXXXXXXXXXX
KEY222 580A34 YYYYYYYYYYY
KEY333 924T13 XYXYXYXYXYX
KEY444 P65340 #ABJ@!CCTCC
KEY555 00C983 CTXJSERVOLP
KEY666 403060 ASTLFJKA3I@
KEY777 3G9286 UALSAMNUJEL
KEY888 69573V PFISLCJRETX
KEY999 1030X0 ESIRQMECHAL
|
FILE-2: Sample records
Code: |
----+----+----+----+----+----+----+----+----+----+
KEY000 35S960 FIADXERAC%!
KEY001 001200 K;JIWRXKOO3
KEY111 010K23 XXXXXXXXXXX
KEY112 930203 SERIES8AM94
KEY222 580A34 YYYYYYYYYYY
KEY223 45093H TOOLIPTOOLO
KEY333 924T13 XYXYXYXYXYX
KEY334 238992 WOEIASD;FWE
KEY444 P65340 #ABJ@!CCTCC
KEY495 J04511 NLKJIOBEP1X
KEY555 00C983 CTXJSERVOLP
KEY566 93120O GYTONBCZPQM
KEY666 403060 ASTLFJKA3I@
KEY990 1209X5 BIJAMLARTYP
|
My requirement is to overlay "999999" from file-1 onto file-2 at 10th position for all matching records but at the same time output should also have all the records along with changed records. Please help me in achieving this.
Expected Output:
Code: |
----+----+----+----+----+----+----+----+----+----+
KEY000 999999 FIADXERAC%!
KEY001 001200 K;JIWRXKOO3
KEY111 999999 XXXXXXXXXXX
KEY112 930203 SERIES8AM94
KEY222 999999 YYYYYYYYYYY
KEY223 45093H TOOLIPTOOLO
KEY333 999999 XYXYXYXYXYX
KEY334 238992 WOEIASD;FWE
KEY444 999999 #ABJ@!CCTCC
KEY495 J04511 NLKJIOBEP1X
KEY555 999999 CTXJSERVOLP
KEY566 93120O GYTONBCZPQM
KEY666 999999 ASTLFJKA3I@
KEY990 1209X5 BIJAMLARTYP
|
Please help.
Thanks. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Hi Ramsri:
You can try this job:
Code: |
//STEP01 EXEC PGM=SORT
//SORTJNF1 DD *
KEY000 35S960 FIADXERAC%!
KEY111 010K23 XXXXXXXXXXX
KEY222 580A34 YYYYYYYYYYY
KEY333 924T13 XYXYXYXYXYX
KEY444 P65340 #ABJ@!CCTCC
KEY555 00C983 CTXJSERVOLP
KEY666 403060 ASTLFJKA3I@
KEY777 3G9286 UALSAMNUJEL
KEY888 69573V PFISLCJRETX
KEY999 1030X0 ESIRQMECHAL
//SORTJNF2 DD *
KEY000 35S960 FIADXERAC%!
KEY001 001200 K;JIWRXKOO3
KEY111 010K23 XXXXXXXXXXX
KEY112 930203 SERIES8AM94
KEY222 580A34 YYYYYYYYYYY
KEY223 45093H TOOLIPTOOLO
KEY333 924T13 XYXYXYXYXYX
KEY334 238992 WOEIASD;FWE
KEY444 P65340 #ABJ@!CCTCC
KEY495 J04511 NLKJIOBEP1X
KEY555 00C983 CTXJSERVOLP
KEY566 93120O GYTONBCZPQM
KEY666 403060 ASTLFJKA3I@
KEY990 1209X5 BIJAMLARTYP
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,6,A)
JOINKEYS FILE=F2,FIELDS=(1,6,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F2:1,30,F1:10,6),FILL=C'?'
OPTION COPY
INREC IFTHEN=(WHEN=(31,6,CH,EQ,C'??????'),BUILD=(1,30)),
IFTHEN=(WHEN=NONE,OVERLAY=(10:C'999999'))
OUTREC BUILD=(1,30) |
Output:
Code: |
KEY000 999999 FIADXERAC%!
KEY001 001200 K;JIWRXKOO3
KEY111 999999 XXXXXXXXXXX
KEY112 930203 SERIES8AM94
KEY222 999999 YYYYYYYYYYY
KEY223 45093H TOOLIPTOOLO
KEY333 999999 XYXYXYXYXYX
KEY334 238992 WOEIASD;FWE
KEY444 999999 #ABJ@!CCTCC
KEY495 J04511 NLKJIOBEP1X
KEY555 999999 CTXJSERVOLP
KEY566 93120O GYTONBCZPQM
KEY666 999999 ASTLFJKA3I@
KEY990 1209X5 BIJAMLARTYP |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You don't need the OUTREC.
If you use IFOUTLEN=30 on the INREC, then all the output will have 30 bytes, but you can have access to the data beond the 30 bytes in any IFTHENs.
Code: |
INREC IFOUTLEN=30,
IFTHEN=(WHEN=(31,6,CH,NE,C'??????'),
OVERLAY=(10:C'999999')) |
|
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Thanks Bill. :-)
Initially I tried BUILD=(1,30) on WHEN=INIT condition but in next WHEN condition, I was not able to access data after 30 bytes. So used OUTREC. |
|
Back to top |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Wonderful mistah kurtz..........you saved my day. Thanks a lot |
|
Back to top |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
this is without using FILL on REFORMAT -
Code: |
INREC IFTHEN=(WHEN=(10,6,CH,EQ,31,6,CH),
OVERLAY=(10:C'999999',31:C' '))
OUTREC BUILD=(1,30)
|
Thanks. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Ramsri,
Did you read everything? You don't need the OUTREC or an INREC with all of that.
You didn't indicate that space is not a valid value for your field, so the FILL was chosen, The default for FILL is space. |
|
Back to top |
|
|
|