View previous topic :: View next topic
Author
Message
bhaskar_kanteti Active User Joined: 01 Feb 2007Posts: 123 Location: Hyderabad
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
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
Bhaskar kaneti,
what happens if they key has a combo of RE and CA? which one should be picked?
Back to top
bhaskar_kanteti Active User Joined: 01 Feb 2007Posts: 123 Location: Hyderabad
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
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
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
bhaskar_kanteti Active User Joined: 01 Feb 2007Posts: 123 Location: Hyderabad
Thanks Skolusu.
Job is producing the expected output.
Thank you so much.
Back to top
Please enable JavaScript!