File Comparision Using SORT



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

File Comparision Using SORT

Postby Vineet » Fri Dec 02, 2011 4:33 pm

Hi All,

I am having 2 Sequential Files Say File A (LRECL = 500) & File B(LRECL = 300). I need to Compare 2 Files based on Item Number. For File A Item Number Start Position is 01 & Item Field Length is 06, Where as for File B Start Position of Item Number is 13 And Item Field Length is 06. We need to Write all Records from File A to The Output File (File C).Output File is Having Same Attribute as File A. Before Writing Records to Output File C, We need to Check, If Item Number is > 499999, Then we Need to Move Spaces to a Specific Field which is of Length 2 Bytes with Start Position as 25. If Item Number is < 499999 thn what ever value it is Having need to be Passed. If Item Number is > 499999 Present in File A but Not in File B, No Need to Move Space to the Field Start at Position 25. Below is the Example.

File A:

123456|ABCDE12345|12|XYZ..........
111111|XYZAB44444|20|ABC..........
599999|WQZX55555|30|OPQ..........
699999|ABCDE12345|12|XYZ..........

File B:
123456|ABCDE12345|12|XYZ..........
111111|XYZAB44444|20|ABC..........
599999|WQZX55555|30|OPQ..........

File C: (Output File)
123456|ABCDE12345|12|XYZ.......... Item 123456 Present in File A & File B, But < 499999, O/P File to Have 12.
111111|XYZAB44444|20|ABC.......... Item 111111 Present in File A & File B, But < 499999, O/P File to Have 20.
599999|WQZX55555| |OPQ.......... Item 599999 Present in File A & File B, But > 499999, O/P File to Have Space Instead of 30 (File A).
699999|ABCDE12345|12|XYZ.......... Item Present in File A But Not in File B. But Item Number > 499999. O/P Should have 12 Instead of Space.

Note: O/P Record Count To Be Equal to File A Record Count.

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: File Comparision Using SORT

 

Re: File Comparision Using SORT

Postby Vineet » Fri Dec 02, 2011 6:42 pm

Missed Out One Info. Both Files having Recfm = FB.
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: File Comparision Using SORT

Postby Frank Yaeger » Sat Dec 03, 2011 12:38 am

Your rules seem a bit incomplete. You don't say what to do if the item = 499999, and you don't say what to do if the item is only in FileA but is less than 499999 (I'll assume you want blanks in 25-26 in that case). Anyway, here's a DFSORT job that should give you the idea of how to do this. Modify as needed.

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/500)
//IN2 DD DSN=...  input file2 (FB/300)
//SORTOUT DD DSN=...  output file (FB/500)
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,6,A)
  JOINKEYS F2=IN2,FIELDS=(13,6,A)
  JOIN UNPAIRED,F1
  REFORMAT FIELDS=(F1:1,508,?)
  INREC IFTHEN=(WHEN=(509,1,CH,EQ,C'B',AND,1,6,ZD,GT,499999),
    OVERLAY=(25:2X)),
   IFTHEN=(WHEN=(509,1,CH,EQ,C'1',AND,1,6,ZD,LE,499999),
    OVERLAY=(25:2X))
  SORT FIELDS=(501,8,ZD,A)
  OUTREC BUILD=(1,500)
/*
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: File Comparision Using SORT

Postby Vineet » Sat Dec 03, 2011 1:42 am

Thank Frank. for the 2 Queries U have Raised Reply is . If Item in File A & File B & Item Number = 499999 Or Item is Only in File A & = 49999, No Need to Overlay with Spaces. We Need to Over Lay Position 25-26 2ith Spaces If and Only If Item present in Both Files and Item Number > 499999. In All Other Condition We Don't Need to Overlay.

If ANy Query Concer please do let me know.

Thanks
Rgds.
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: File Comparision Using SORT

Postby Frank Yaeger » Sat Dec 03, 2011 2:21 am

Do you still need help with this?

If so, please show a better example of input and expected output that includes all of the possibilities your rules cover.
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


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post