Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
compare two records in same file along with other conditions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 120
Location: USA

PostPosted: Wed Sep 17, 2008 6:31 pm    Post subject: compare two records in same file along with other conditions
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    Post subject:
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: 120
Location: USA

PostPosted: Thu Sep 18, 2008 6:24 pm    Post subject: Reply to: compare two records in same file along with other
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us