Page 1 of 1

Validating a word in SORT in fixed positions

PostPosted: Mon Jan 12, 2015 9:06 pm
by rockstar2020
Hello All,

First of thanks for all your help in every topic. I'm trying to achieve the below requirement using JCL without writing a program.
As you can see CAUGHT will be in either of 3 fixed positions for a group, between 001 to 002 or 001 to 003. it will b mostly in 002 or 003 and only once or it maynot available for that group.
If CAUGHT is seen in any one of fixed poostions in 002 or 003 in that group, i just want to write the name to the o/p, (i.e) LISA, TINA, RAGG in the below example and neglect MATT and DINO as they dont have CAUGHT.

INPUT CODE -
    001AAALISA    MATHS  MATHS
    002BBBLISA           MATHS  CAUGHT     
    001AAATINA    PHYSI  PHYSI
    002BBBTINA           PHYSI                   CAUGHT
    001AAAMATT    CHEM   CHEM
    002BBBMATT           CHEM       
    003BBBMATT                       
    001AAADINO    MATHS  MATHS
    002BBBDINO           MATHS   
    001AAARAGG    BIOLO  BIOLO
    002BBBRAGG           BIOLO                                  CAUGHT
    003BBBRAGG           


expected o/p
LISA
TINA
RAGG

Re: Validating a word in SORT in fixed positions

PostPosted: Mon Jan 12, 2015 10:05 pm
by BillyBoyo
If the CAUGHTs don't require further validation (if the can only appear correctly to your requirement) then you can use a field-type of SS to do a sub-string search.

You can do that on INCLUDE/OMIT (bot COND and on OUTFIL) or on IFTHEN=(WHEN=(logical expression).

For here, an OUTFIL INCLUDE with a BUILD for the name field. OUTFIL INCLUDE=(startoffirstfield,lenghtofallthreefields,SS,EQ,C'CAUGHT')

Re: Validating a word in SORT in fixed positions

PostPosted: Tue Jan 13, 2015 1:49 am
by rockstar2020
Thank you Bill. I wrote all the records having CAUGHT to one file. I did that now. I used OUTFIL INCLUDE, BUILD for this.

However I need to write all the records that doesnt have CAUGHT to another file. IS it possible in the same step?

Re: Validating a word in SORT in fixed positions

PostPosted: Tue Jan 13, 2015 3:49 am
by BillyBoyo
A second OUTFIL, naming a different DD, and specify SAVE for it. All records which aren't written to another OUTFIL will be written to the OUTFIL with SAVE on.