Page 1 of 1

How to use OUTREC in IFTHEN=(WHEN

PostPosted: Thu Jul 10, 2014 6:29 pm
by Ramsee
Hi All,

Warm greeting!!

I am trying to update the 190 column as ' ' (Two blank spaces) by validaing the 1st position of the file using the following sortcard:
Input :
1234567      11  20140101
1234568      12  20140102
1234569           20140103

SYSIN :
OPTION COPY
OUTREC IFTHEN=(WHEN=(1,7,CH,EQ,C'1234567'),OVERLAY=(10:C' ')), -
IFTHEN=(WHEN=NONE,BUILD=(1:1,20))

Expected Output:
1234567           20140101
1234568     12  20140102
1234569     01  20140103    (01 is not present in the input)

In the above code, i am facing an issue that remaining records (other than "1234567" in position 1) are filled with junk values.
I need to write the unmatched records as it is.

Please suggest me a correct sortcard.

Thanks

Re: How to use OUTREC in IFTHEN=(WHEN

PostPosted: Thu Jul 10, 2014 6:36 pm
by BillyBoyo
What is the LRECL of your input? Not 20, is it? What do you want to do with that second IFTHEN=?

Re: How to use OUTREC in IFTHEN=(WHEN

PostPosted: Thu Jul 10, 2014 6:39 pm
by Ramsee
the second IF then is used to write the input record as it is for all the unmatched records.

Re: How to use OUTREC in IFTHEN=(WHEN

PostPosted: Thu Jul 10, 2014 6:47 pm
by BillyBoyo
OK, I think you misunderstand how it works:

Record is read; INCLUDE/OMIT processing; INREC processing; SORT/MERGE processing (if not COPY); OUTREC processing; OUTFIL processing where records are written per OUTFIL; record is written to SORTOUT if DD present, and no OUTFIL for SORTOUT.

You don't need to do anything to get a record written (unless you want multiple output records from one input record). You sometimes need to do things (OMIT/INCLUDE COND=, OMIT=/INCLUDE=) to prevent records being written.

Remove that second IFTHEN (the the comma preceding it) and run again. If that doesn't give you what you want, show sample input, actual output and expected output, as well as the Sort Control Cards you used and the sysout from the step.