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

Select a record based on three values in a field


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: Mon Dec 15, 2008 6:26 pm
Reply with quote

Hi,

I need to select records based on a field which can have 3 different values.
Here is my input file:
Code:

M0001AAAAB0001EX
M0001AAAAB0002EX
M0001AAAAB0003EX
M0001AAAAB0004RE
M0001AAAAB0005RE
M0002AAAAB0001EX
M0002AAAAB0002EX
M0002AAAAB0003CA
M0002AAAAB0004EX
M0003AAAAB0001EX
M0003AAAAB0002EX
M0003AAAAB0003EX

RECFM=FB, LRECL=16
Key Position is (1,5)
Position (15,2) can have either (EX,RE,CA)
Each key can have combinations of (EX,RE) or (EX,CA) or (EX)
If the combination had (EX,RE) then the first RE should be written to output.
If the combination had (EX,CA) then the first CA should be written to output.
If the had only EX records then the first EX record should be written to output.

Here is my output file:
Code:

M0001AAAAB0004RE
M0002AAAAB0003CA
M0003AAAAB0001EX


Guide me how to get this output.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Dec 15, 2008 10:14 pm
Reply with quote

Bhaskar kaneti,

what happens if they key has a combo of RE and CA? which one should be picked?
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Mon Dec 15, 2008 10:36 pm
Reply with quote

Hi Skolusu,
The key will not have combinationg of RE and CA.
It will have only the below combinations.
(EX, CA) or (EX, RE) or (EX).
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Dec 15, 2008 10:39 pm
Reply with quote

bhaskar_kanteti,

The following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN       DD *                                             
M0001AAAAB0001EX                                             
M0001AAAAB0002EX                                             
M0001AAAAB0003EX                                             
M0001AAAAB0004RE                                             
M0001AAAAB0005RE                                             
M0002AAAAB0001EX                                             
M0002AAAAB0002EX                                             
M0002AAAAB0003CA                                             
M0002AAAAB0004EX                                             
M0003AAAAB0001EX                                             
M0003AAAAB0002EX                                             
M0003AAAAB0003EX                                             
//OUT      DD SYSOUT=*                                       
//TOOLIN   DD *                                             
 SELECT FROM(IN) ON(1,5,CH) TO(OUT) FIRST USING(CTL1)       
//CTL1CNTL DD *                                             
  INREC IFTHEN=(WHEN=(15,2,CH,EQ,C'EX'),OVERLAY=(17:C'2')), 
        IFTHEN=(WHEN=(15,2,SS,EQ,C'CA,RE'),OVERLAY=(17:C'1'))
  SORT FIELDS=(1,5,CH,A,17,1,CH,A)                           
  OUTFIL FNAMES=OUT,BUILD=(1,16)                             
/*
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Tue Dec 16, 2008 1:28 pm
Reply with quote

Thanks Skolusu.
Job is producing the expected output.
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 How to split large record length file... DFSORT/ICETOOL 8
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top