Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Select a record based on three values in a field

 
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: Mon Dec 15, 2008 6:26 pm    Post subject: Select a record based on three values in a field
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    Post subject: Reply to: Select a record based on three values in a field
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: 120
Location: USA

PostPosted: Mon Dec 15, 2008 10:36 pm    Post subject: Reply to: Select a record based on three values in a field
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    Post subject:
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: 120
Location: USA

PostPosted: Tue Dec 16, 2008 1:28 pm    Post subject: Reply to: Select a record based on three values in a field
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    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 Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us