Page 1 of 1

Field Comparision using SORT

PostPosted: Fri Dec 10, 2010 5:38 pm
by Vineet
I have a Fixed length File LRECL = 500. I want To perform field Comparision between 2 Records Appearing at Specific Position remaning all Fields are Same. Below is Example.

ABCD|1234XYZ|77|2010-12-12|HELLO  --> Rec A
ABCD|1234XYZ|00|2010-12-12|HELLO  --> Rec B

ABCD|9999XYZ|11|2010-12-18|HELLO --> Rec C
ABCD|9999XYZ|22|2010-12-18|HELLO --> Rec D

For Above Stated Examples Field Appearing at Col. 14 Only Differs Other fields are same. Comparision has to be Perform Bwteen Rec A & Rec B & O/P File Should have Rec A. Similarly Comparision has to be Perform Bwteen Rec C & Rec D & O/P File Should have Rec D.

O/P File Should have Records
ABCD|1234XYZ|77|2010-12-12|HELLO
ABCD|9999XYZ|22|2010-12-18|HELLO

Thanks
Kind Rgds.

Re: Field Comparision using SORT

PostPosted: Fri Dec 10, 2010 10:00 pm
by Frank Yaeger
You haven't done a very good job of explaining the "rules" for getting from input to output.

Are you comparing each pair of records (1 and 2, 3 and 4, 5 and 6, etc) or are you comparing using some other rule (what)?

Why did you keep the first record for one pair, but the second record for the other pair?

Please show a better example of input and expected output including records that compare on all of the fields, records that don't compare on one of the other fields, etc. Explain the rules completely and clearly.

Also, give the RECFM and LRECL of each input file and the starting position, length and format of each field.

Re: Field Comparision using SORT

PostPosted: Sun Feb 13, 2011 7:33 am
by Vineet
Hi Frank,

My Apologies. I missed out Providing The Required Info. Lets Take the Same file as Input File. Attributes for Input File.
LRECL = 500, RECFM = FB

INPUT FILE:
ABCD|1234XYZ|77|2010-12-12|HELLO --> Rec A
ABCD|1234XYZ|00|2010-12-12|HELLO --> Rec B

ABCD|9999XYZ|11|2010-12-18|HELLO --> Rec C
ABCD|9999XYZ|22|2010-12-18|HELLO --> Rec D

I want to Compare Only Those Records where Record Start from Position 1 To Position 13 (13 Bytes) have same value & want to Print only that Record where value appearing at position 14,15 (2 bytes) is Greater. Below is Output File. Attribute of Output File: LRECL = 500, RECFM = FB

O/P File Should have Records
ABCD|1234XYZ|77|2010-12-12|HELLO
ABCD|9999XYZ|22|2010-12-18|HELLO

Note: I have Compared Rec A & Rec B, Rec C & Rec D. Because For Rec A & Rec B has Inital 13 Bytes in Common, Similarly for Rec C & Rec D.While Writing Record to Output File, having Record as ABCD|1234XYZ|77|2010-12-12|HELLO and
ABCD|9999XYZ|22|2010-12-18|HELLO. Because Value Appearing at Position 14,15 (2 Bytes), when Comparing Rec A & Rec B, Rec A is Greater Than Rec B. Similarly for When Comparing Rec C & Rec D. Rec D Value is Greater Than Rec C.

Thanks
Kind Rgds

Vineet Anand.

Re: Field Comparision using SORT

PostPosted: Mon Feb 14, 2011 10:45 pm
by skolusu
vineet,

Use the following DFSORT/ICETOOL JCL which will give you the desired results.

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN       DD DSN=Your input file,DISP=SHR                   
//OUT      DD SYSOUT=*                                       
//TOOLIN   DD *                                             
  SELECT FROM(IN) TO(OUT) FIRST ON(1,13,CH) USING(CTL1)     
//CTL1CNTL DD *                                             
  SORT FIELDS=(1,13,CH,A,14,2,CH,D)                         
//*