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: 113
Location: India

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: 113
Location: India

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: 113
Location: India

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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


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