|
View previous topic :: View next topic
|
| Author |
Message |
Mithun MF
New User
Joined: 09 Sep 2010 Posts: 7 Location: Chennai
|
|
|
|
Hi all,
I have the requirement that has to merge the files F1 and F2
based on the keys ( In F1 -> 10th byte to 22nd Byte , F2 -> 1st - 13th byte) if this key match replace the value from F2 (14,3) into F1(343,3).
If key dosent match (Unpaired records in F1) dont skip write it in the sorted out file.
Where F1 is VB , F2 - LRecl 16.
Please help me on this.
Thanks,
Mithun |
|
| Back to top |
|
 |
prahalad
New User
Joined: 14 Sep 2010 Posts: 18 Location: Pune
|
|
|
|
Hi Mithun,
Can you please provide me some more information.
1) For unpaired records in F1 what will be the values in F1(343,3)?
do you want SPACES or values as it is in F1 for position F1(343,3)?
2) Is The output file format will be as like F1.
3) Instead of using ICETOOL, whether SORTJOIN(joinkeys) will work for you? |
|
| Back to top |
|
 |
Mithun MF
New User
Joined: 09 Sep 2010 Posts: 7 Location: Chennai
|
|
|
|
Hi Prahald,
@ 1 -> What ever the record present in file(F1) will be written for unpaired. Data Type is PIC S9(3)V9 COMP-3.
@ 2 -> Yes the format should be same as F1
@ 3 -> YEs Join keys thru sort will work for me.
Thanks,
Mithun |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Mithun MF,
Could you have duplicates in any of the files (File1 and/or File2)? Please show sample input data and expected output with all possible combinations (i.e. dups in file1 and/or file2).
| Quote: |
| If key dosent match (Unpaired records in F1) dont skip write it in the sorted out file. |
Do you want all the fields or just key(10th byte to 22nd Byte) in your output file? Please show that in your sample data.
Thanks, |
|
| Back to top |
|
 |
prahalad
New User
Joined: 14 Sep 2010 Posts: 18 Location: Pune
|
|
|
|
Mithun,
Assuming the F1 file has LRECL = 500. As it is a VB file so LRECL = 500+ 4 = 504.
As F1 is VB in the below code we use keys starting pos as 14 (10 + 4)
JOINKEYS FILES=F1,FIELDS=(14,13,A)
You can use the following SORT:
| Code: |
//SORTOUT DD DSN=dataset name,
// DISP=(NEW,CATLG),
// DCB=(RECFM=VB,LRECL=504),
// SPACE=(CYL,(500,500),RLSE),UNIT=TSTDA
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(14,13,A)
JOINKEYS FILES=F2,FIELDS=(1,13,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:5,500,F2:14,3)
SORT FIELDS=COPY
OUTFIL IFTHEN=(WHEN=(501,3,CH,EQ,C' '),BUILD=(1,500)),
IFTHEN=(WHEN=(501,3,CH,NE,C' '),BUILD=(1,342,501,3,346,155)),
FTOV
|
|
|
| Back to top |
|
 |
Mithun MF
New User
Joined: 09 Sep 2010 Posts: 7 Location: Chennai
|
|
|
|
Hi All,
Here is my sample input file and expected output file
F1
----+----1----+----2----+--------------------------------343-----------------
**********************************************************
439523216002010003055106472............................................
439523216002010003055605561...................007...................
439523216002010003055606472...................007...................
439523216002010003055906472...........................................
F2
----+----1----+----2-
*********************
0020100030551005
0020100030553006
0020100030556009
Expected O/P
----+----1----+----2----+--------------------------------343-----------------
**********************************************************
439523216002010003055106472............................................
439523216002010003055605561.................009.................
439523216002010003055606472.................009.................
439523216002010003055906472........................................
Now can anyone help me on this |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Mithun MF,
If I am not mistaken, your input and output doesn't seem to match per requirements. Your F1 shows a record for key (0020100030551) and F2 has a record with the same key and a value of 005. Now, in your expected output you don't show 005 overlaid on position 343 for 3 bytes. But again for the key 0020100030556, in your expected output you show that value of 009 from F2 overlays 007 from F1.
Is that a typo or do you just want to overlay records in File1 if it already has some value in it?
| Quote: |
| Now can anyone help me on this |
Please don't get frustrated with questions but everyone here tries to get clear picture of the requirements and refrain from making assumptions only to find out it doesn't suit your need(s).
Thanks, |
|
| Back to top |
|
 |
Mithun MF
New User
Joined: 09 Sep 2010 Posts: 7 Location: Chennai
|
|
|
|
Hi Sqlcode1,
I Could explain it clearly now
F1
----+----1----+----2----+--------------------------------343-----------------
**********************************************************
439523216002010003055106472............................................ ( 10th byte to 22nd Byte)
439523216002010003055605561...................007................... ( 10th byte to 22nd Byte)
439523216002010003055606472...................007................... ( 10th byte to 22nd Byte)
439523216002010003055906472........................................... ( 10th byte to 22nd Byte)
F2
----+----1----+----2-
*********************
0020100030550005 (1-13 Byte)
0020100030553006 (1-13 Byte)
0020100030556009 (1-13 Byte)
Expected O/P
----+----1----+----2----+--------------------------------343-----------------
**********************************************************
439523216002010003055106472............................................ (Not paired with F1/F2 , Write the record as in F1 )
439523216002010003055605561.................009.................
(Paired with F1 and F2 replace 343,3 in F1 with 14,3 in F2 { replaced 007 with 009} )
439523216002010003055606472.................009.................
(Paired with F1 and F2 replace 343,3 in F1 with 14,3 in F2 { replaced 007 with 009} )
439523216002010003055906472........................................
(Not paired with F1/F2 , Write the record as in F1 )
Hope this gives better understanding.
Thanks,Mithun |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Mithun MF,
See if below jcl works for you.
Since your input F1 is VB, I am assuming that the key starts at 14th position, if it indeed starts 10th position, change the joinkeys statement accordingly.
| Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DISP=SHR,DSN=INPUT F1, VB-500
//SORTJNF2 DD DISP=SHR,DSN=INPUT F2, FB-016
//SORTOUT DD OUTPUT
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(14,13,A)
JOINKEYS FILE=F2,FIELDS=(01,13,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,4,?,F2:14,3,F1:5)
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(5,1,CH,EQ,C'B'),OVERLAY=(348:6,3))
OUTREC BUILD=(1,4,9)
/* |
Thanks, |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|