Field Comparision using SORT



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Field Comparision using SORT

Postby Vineet » Fri Dec 10, 2010 5:38 pm

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.
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Field Comparision using SORT

 

Re: Field Comparision using SORT

Postby Frank Yaeger » Fri Dec 10, 2010 10:00 pm

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.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Field Comparision using SORT

Postby Vineet » Sun Feb 13, 2011 7:33 am

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.
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Field Comparision using SORT

Postby skolusu » Mon Feb 14, 2011 10:45 pm

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)                         
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post