|
View previous topic :: View next topic
|
| Author |
Message |
to_sreeni
New User
Joined: 08 Jul 2009 Posts: 17 Location: bangalore
|
|
|
|
Hi, we have two VB files (496 length including RDW). Now i have to segregate the input file based on a key. If this key is present in second file i have to write that record to MATCH file (Out file1). If not then i have to write file1 records to UNMATCH file (Out file2). Here the key is in hexa decimal format.
Thanks,
Sreenivas |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Sreenivas,
Welcome to the forums.
It does not matter in which format your key is, you just need to mention the starting position and length of the key-field in both the files in the JOINKEYS statement provided key-fields in both the files have the same format and length.
| Code: |
JOINKEYS FILE=F1,FIELDS=(p1,l1,A)
JOINKEYS FILE=F2,FIELDS=(p2,l2,A) |
|
|
| Back to top |
|
 |
to_sreeni
New User
Joined: 08 Jul 2009 Posts: 17 Location: bangalore
|
|
|
|
Hi,
Thanks for the quick response. Please find the below code which i am using. The hexa decimal number is at 9-11 position. If i exclude the hexa part in the key, it was giving the correct result. Otherwise , it is giving incorrect result. Please help.
| Code: |
//SORT1 EXEC PGM=SORT
//SORTJNF1 DD DISP=SHR,DSN=MSP1116.S.M0W109.ASRTCPY.TEST1
//SORTJNF2 DD DISP=SHR,DSN=MSP1116.S.M0W109.ASRTCPY.TEST2
//SORTOF01 DD DSN=MSP1116.MATCHED.RECORDS.FILE1,
// DISP=(OLD,CATLG),
// UNIT=SYSDA,SPACE=(TRK,(20,10),RLSE),
// DCB=MSP1116.S.M0W109.ASRTCPY.TEST1
//SORTOF02 DD DSN=MSP1116.UNMAT.RECORDS.FILE1,
// DISP=(OLD,CATLG),
// UNIT=SYSDA,SPACE=(TRK,(20,10),RLSE),
// DCB=MSP1116.S.M0W109.ASRTCPY.TEST1
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(8,1,A,9,3,A,20,5,A)
JOINKEYS FILES=F2,FIELDS=(8,1,A,9,3,A,20,5,A)
REFORMAT FIELDS=(F1:1,496,F2:1,496),FILL=X'FF'
JOIN UNPAIRED,F1
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(501,1,BI,NE,X'FF'),
OUTREC=(5,492),FTOV,VLTRIM=X'FF'
OUTFIL FILES=02,SAVE,OUTREC=(5,492),FTOV,VLTRIM=X'FF' |
Edited: Please use BBcode when You post some code/error, that's rather readable, Thanks... Anuj |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Quote: |
| If i exclude the hexa part in the key, it was giving the correct result. Otherwise , it is giving incorrect result. Please help |
You need to show a sample of input records, what u r expecting and what output you're getting currently. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Just a guess, but there may be numerically equal values with different signs. . .
As Arun requests,
| Quote: |
| You need to show a sample of input records, what u r expecting and what output you're getting currently. |
|
|
| Back to top |
|
 |
to_sreeni
New User
Joined: 08 Jul 2009 Posts: 17 Location: bangalore
|
|
|
|
Hi,
Input records in file1 are
| Code: |
é.P.ù.......JìC1A35 ..*...á...TOM....C.........D.........
é.P.ù.......JìC1A36 ..*...ß...TOM........................
é.P.ù.......JìC1A37 ..*...ß...TOM...............£ò.......
é.P.ù.......JìE1A05....*..&....TOM.....KITCHEN*MRS
îxP..õ......JìC1A56 ..*.......TOM.....Õø........²-....... |
Input records in file2 are
| Code: |
| é.P.ù.......JìE1A05....*..&....TOM.....KITCHEN*MRS |
The Output i am expecting in
Match File (MSP1116.MATCHED.RECORDS.FILE1)
| Code: |
| é.P.ù.......JìE1A05....*..&....TOM.....KITCHEN*MRS |
Unmatch records of file1(MSP1116.UNMAT.RECORDS.FILE1)
| Code: |
é.P.ù.......JìC1A35 ..*...á...TOM....C.........D.........
é.P.ù.......JìC1A36 ..*...ß...TOM........................
é.P.ù.......JìC1A37 ..*...ß...TOM...............£ò.......
îxP..õ......JìC1A56 ..*.......TOM.....Õø........²-....... |
Please can anybody help?
Warm Regards,
Sreenivas |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
You need to re-post your data using "HEX ON" and use the "Code" tag (which will preserve alignment).
When we can better see your data, we wioll be able to offer better suggestions. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
I've "Code"ed your data, but we still need the HEX ON display. . . |
|
| Back to top |
|
 |
to_sreeni
New User
Joined: 08 Jul 2009 Posts: 17 Location: bangalore
|
|
|
|
Hi,
Input records in file1 are
| Code: |
é.P.ù.......JìC1A35 ..*...á...TOM....C.........D.........
450D0D2000000D5CFCFF440151034000EDD0000C000000000C000000000
01176D600000018311350097C1305000364000030000000004000000000
-----------------------------------------------------------
é.P.ù.......JìC1A36 ..*...ß...TOM........................
450D0D2000000D5CFCFF440151035000EDD000000000000000100000000
01176D600000018311360097C1309000364000000000000003560000000
-----------------------------------------------------------
é.P.ù.......JìC1A37 ..*...ß...TOM...............£ò.......
450D0D2000000D5CFCFF440151035000EDD0000000000000005C0000000
01176D600000018311370097C1309000364000000000000007BDC000000
-----------------------------------------------------------
é.P.ù.......JìE1A05....*..&....TOM.....KITCHEN*MRS
450D0D2000000D5CFCFF000151051000EDD00000DCECCCD5DDE
01176D600000018511050097C13030003640000B2933855C492
-----------------------------------------------------------
îxP..õ......JìC1A56 ..*.......TOM.....Õø........²-.......
45AD02C000000D5CFCFF440151011000EDD00000E700000000E60000000
067779F00000018311560097C150700036400000F000000000A00000000 |
Input records in file2 are
| Code: |
é.P.ù.......JìE1A05....*..&....TOM.....KITCHEN*MRS
450D0D2000000D5CFCFF000151051000EDD00000DCECCCD5DDE
01176D700000018511050097C13030003640000B2933855C492 |
Please help me. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
The values in the 5-byte field do not match. . .
Suggest you check the processes that create these files and determine whether the first 2 bytes of this field should be x'40' or x'00'. |
|
| Back to top |
|
 |
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
Dick,
I think you forgot to take into account the 4-byte RDW. The first byte of sample data shown is really position 5. Therefore, (20,5) is C1A35 in the first record.
Sreenivas,
| Quote: |
| If this key is present in second file i have to write that record |
If you mean that you want the matched record from File2 written to the first OUTFIL, then modify the code as follows:
| Code: |
OUTFIL FILES=01,INCLUDE=(501,1,BI,NE,X'FF'),
OUTREC=(501,492),FTOV,VLTRIM=X'FF' |
If this is not what you meant, then please be more specific and show us what you are getting in the output. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Alissa,
| Quote: |
| I think you forgot to take into account the 4-byte RDW |
Yup - Didn't forget - left it out intentionally due to the leading x'40'. Also because x'1D7' = 471 and the original "spec" is "496 length including RDW".
My guesser wasn't working so well
I didn't look at the code and probably should have. . . |
|
| Back to top |
|
 |
to_sreeni
New User
Joined: 08 Jul 2009 Posts: 17 Location: bangalore
|
|
|
|
Hi Alissa,
I want the matching records of file 1 should be written to Match file.
This logic is working when i specify the single key (20,5,A);
Also, when i specify two keys (8,1,A) and (20,5,A)
But it is giving the empty MATCH file when i specify three keys (8,1,A), (9,3,A) and (20,5,A).
The reason for this is , the key (9,3,A) - the format here is hexadecimal value (It is not Packed decimal where the sign is speified in the last nibble).
PS: 9,3 gives the number (which is in hexa format in the record). It will never have a nagative value.
Please help me.
Thanks,
Sreenivas |
|
| Back to top |
|
 |
to_sreeni
New User
Joined: 08 Jul 2009 Posts: 17 Location: bangalore
|
|
|
|
Hi Alissa
Can you please help me?
Your help is very much appreciated.
Thanks,
Sreenivas |
|
| Back to top |
|
 |
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
All JOINKEYS fields are treated as binary format for purposes of comparison during the match processing.
With the sample data you provided, (9,3) does not match, so I would not expect there to be any matched records in the output. In File 1, the value is X'06DD26' whereas the value in File 2 is X'06DD27' . They simply don't match. If this is not the data you expected in the key field, then I would recommend that you verify your offsets. |
|
| Back to top |
|
 |
to_sreeni
New User
Joined: 08 Jul 2009 Posts: 17 Location: bangalore
|
|
|
|
HI Alissa,
It is working now. thanks a lot for your help.
Your help is very much appreciated.
Thanks,
Sreenivas |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|