IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

compare two records in same file along with other conditions


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Wed Sep 17, 2008 6:31 pm
Reply with quote

Hi,

I want to know whether can we compare two records which are in same file and write to output file based on conditions.
Here is my requirement.

Input file is FB and LRECL is 23.
UNUM is 9(6)
ACCNO is 9(6)
CUST is 9(6)
NO is 9(3)
ID is x(2) will have either DM or SPACES

Code:

Condition 1:
Input file:
UNUM  ACCNO CUST  NO ID
11111 22222 33331 10 DM
11111 22222 33332 20   

Output File:
11111 22222 33331 10 DM

If there are two records of same 'UNUM' and 'ACCNO', then check whether 'ID' field is populated or having spaces. If 'ID' is populated then we need to write that particular record to output

Code:

Condition 2:
Input file:
UNUM  ACCNO CUST  NO ID
11111 22222 33331 10 DM
11111 22222 33332 20 DM 

Output File:
11111 22222 33332 20 DM

If there are two records of same 'UNUM' and 'ACCNO', and for those both records if the 'ID' field is having same VALUE or SPACES, then we need to compare 'NO' field. The record which has least 'NO' value should be written to output

Code:

Condition 3:
Input file:
UNUM  ACCNO CUST  NO ID
11111 22222 33331 20 DM
11111 22222 33332 20 DM 

Output File:
11111 22222 33332 20 DM

If there are two records of same 'UNUM' and 'ACCNO', and for those both records if the 'ID' field is having same VALUE or SPACES and 'NO' field is having same value, then we need to compare 'CUST' field. The record which has greater 'CUST' value should be written to output
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Sep 17, 2008 9:04 pm
Reply with quote

bhaskar_kanteti,

Your condition2 does not match the output. You say you need to pick the least 'NO' valued record but in your output you picked 20 record which is the highest number record. If it indeed is a typo then the following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD *                                         
111111222222333331010DM                                 
111111222222333332020                                   
222222222222333331010DM                                 
222222222222333332020DM                                 
333333222222333331020DM                                 
333333222222333332020DM                                 
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                         
  SELECT FROM(IN) TO(OUT) ON(01,12,CH) FIRST USING(CTL1)
//CTL1CNTL DD *                                         
  SORT FIELDS=(01,06,CH,A,   $ UNUM                     
               07,06,CH,A,   $ ACCNO                     
               22,02,CH,D,   $ ID                       
               19,03,ZD,A,   $ NO                       
               13,06,ZD,D)   $ CUST                     
//*                                                     


Hope this helps...

Cheers
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Thu Sep 18, 2008 6:24 pm
Reply with quote

Hi Skolusu,

Thanks for your beautiful solution.
This gave me the desired output.
Its really so simple and easy.

Thank you so much.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top