Page 1 of 1

OUTFIL - INCLUDE - OUTREC

PostPosted: Mon May 19, 2014 5:34 pm
by vegafacundodaniel
Hello.

I want to separate a input file in 2 output files (OUTFIL) on a condition(INCLUDE) and then I want to reformat(OUTREC) theses output files. That, in this order.
//STEP001N EXEC PGM=SORT,
...
//SYSIN        DD *                       
    SORT FIELDS=COPY                       
    OUTFIL FNAMES=OUT1,                 
    INCLUDE=(07,1,CH,EQ,C'A') 
    OUTREC FIELDS=(30,08,72X)             
    OUTFIL FNAMES=OUT2,                 
    INCLUDE=(07,1,CH,EQ,'B') 
    OUTREC FIELDS=(30,08,72X)             


When I run the JCL, I get this error:

OUTREC STATEMENT : DUPLICATE STATEMENT FOUND

Could anyone help me, please ?

Thks in advance

Code'd

Re: OUTFIL - INCLUDE - OUTREC

PostPosted: Mon May 19, 2014 6:01 pm
by BillyBoyo
Which SORT product do you use?

You have confused things somewhat.

Once upon a time, the original INREC/OUTREC used FIELDS= to specify changes to records. The original OUTFIL used OUTREC as part of the OUTFIL itself.

Along came BUILD. BUILD can be used instead of FIELDS on INREC and OUTREC, and instead of OUTREC on OUTFIL. Note that FIELDS is also used for other things in various places (SORT, MERGE, REFORMAT...).

So, FIELDS is "overloaded" (same word has more than one use). So is OUTREC. Their original use is retained for backwards-compatability.

BUT
. It is much clearer, now that it is available, to use BUILD, and only BUILD.

        SORT FIELDS=COPY                       

        OUTFIL FNAMES=OUT1,                 
               INCLUDE=(07,1,CH,EQ,C'A'),
               BUILD=(30,08,72X)             

        OUTFIL FNAMES=OUT2,                 
               INCLUDE=(07,1,CH,EQ,'B'),
               OUTREC FIELDS=(30,08,72X)             


Note, only A and B exist on you file, you can simplify things (making it less error-prone) by using SAVE:

        SORT FIELDS=COPY                       

        OUTFIL FNAMES=OUT1,                 
               INCLUDE=(07,1,CH,EQ,C'A'),
               BUILD=(30,08,72X)             

        OUTFIL FNAMES=OUT2,                 
               SAVE,
               BUILD=(30,08,72X)             


Are you interested in the SORTOUT, which, if you have the DD present in the JCL, is producing a copy of the file?

If not:

        SORT FIELDS=COPY                       

        INREC BUILD=(30,08,72X)             

        OUTFIL FNAMES=OUT1,                 
               INCLUDE=(07,1,CH,EQ,C'A'),

        OUTFIL FNAMES=OUT2,                 
               SAVE


Now you have the BUILD in one place, the INCLUDE only coded once, and it should be easier to understand and maintain.

Re: OUTFIL - INCLUDE - OUTREC

PostPosted: Mon May 19, 2014 6:34 pm
by vegafacundodaniel
Thanks Billy! It works fine with BUILD.