OUTFIL - INCLUDE - OUTREC



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

OUTFIL - INCLUDE - OUTREC

Postby vegafacundodaniel » Mon May 19, 2014 5:34 pm

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
vegafacundodaniel
 
Posts: 61
Joined: Tue Jul 20, 2010 4:27 pm
Has thanked: 1 time
Been thanked: 0 time

Re: OUTFIL - INCLUDE - OUTREC

 

Re: OUTFIL - INCLUDE - OUTREC

Postby BillyBoyo » Mon May 19, 2014 6:01 pm

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.

These users thanked the author BillyBoyo for the post:
vegafacundodaniel (Mon May 19, 2014 6:32 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: OUTFIL - INCLUDE - OUTREC

Postby vegafacundodaniel » Mon May 19, 2014 6:34 pm

Thanks Billy! It works fine with BUILD.
vegafacundodaniel
 
Posts: 61
Joined: Tue Jul 20, 2010 4:27 pm
Has thanked: 1 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post