0

I want to create 3 outfiles depending on the below INCLUDE criteria from the input file. In addition I want only part of the record in the output file given by the below 3 BUILD's.

The issue now I think is that having multiple BUILD/OUTREC gives a duplicate error.

Is there any other way of achieving the same in JCL?

SORT  FIELDS=COPY                                              
OUTFIL FILES=01,                                               
   INCLUDE=(38,8,CH,EQ,C'AMSAM00'),                            
   BUILD=(1,4,5:366,8)                                         
OUTFIL FILES=02,                                               
   INCLUDE=(38,8,CH,EQ,C'AMSAM00',AND,390,1,CH,EQ,C'Y'),       
   BUILD=(1,4,5:382,8)                                         
OUTFIL FILES=03,                                               
   INCLUDE=(38,8,CH,EQ,C'AMSAM00',AND,545,4,CH,NE,C'0000'),    
   BUILD=(1,4,5:C'013,',9:545,4) 
1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
change
  • 3,400
  • 7
  • 32
  • 42
  • What is issuing the message? DFSORT/SYNCSORT or a subsequent program reading the files? – zarchasmpgmr Jul 14 '12 at 13:55
  • What exactly you are getting? Does the below answer suffice? – Raja Reddy Jul 16 '12 at 04:35
  • @zarchasmpgmr: JCL does not allow multiple BUILD/OUTREC statements. you can have a common BUILD for all the includes I guess. – change Jul 16 '12 at 07:51
  • JCL does not have BUILD/OUTREC statements. The sort utility you use does have them. Please do not use JCL as a general term for utilities. It confuses people trying to give you an answer. JCL is for those statements that begin with // like DD, EXEC, JOB, OUTPUT, etc. If you use PGM=SORT, for example, that's a utility. Although you may invoke it via JCL, it is NOT JCL. – zarchasmpgmr Jul 17 '12 at 16:29
  • There's nothing "wrong" with the control cards. If your logic is wrong, that'd be the problem. – Bill Woodger Jan 30 '13 at 19:17

2 Answers2

1

This got a random poke, so...

Deuian I think was on the right lines, but left some complication and for user change didn't use the correct positions or type of output file, so would have been too much typing to apply to the situation...

OPTION COPY                                              
INCLUDE COND=(38,8,CH,EQ,C'AMSAM00')

OUTFIL FILES=02,                                               
  INCLUDE=(390,1,CH,EQ,C'Y'),       
  BUILD=(1,4,382,8)                                         

OUTFIL FILES=03,                                               
  INCLUDE=(545,4,CH,NE,C'0000',
          AND,390,1,CH,NE,C'Y'),    
  BUILD=(1,4,C'013,',545,4) 

OUTFIL FILES=01,SAVE,
  BUILD=(1,4,366,8)                                         

This presumes that SORTOUT will not be needed (it would just be a copy of the input file).

All the AMSAM00 records are INCLUDED, everything else (which is unwanted for the OUTFILs) is ignored.

OUTFIL 02 gets all the 'Y's.

OUTFIL 03 gets all the not 0000s which are not 'Y'

OUTFIL 01, moved to make it easier to follow, gets all the records which are not selected on another OUTFIL (by using SAVE).

All of the data which passes the INCLUDE will be on one of the three OUTFILs, and only one.

I have used OPTION COPY for clarity. SORT FIELDS=(... logically appears after the INCLUDE (wherever you code it) and by using OPTION COPY it is clear, up front, and in a logical place, that it is a COPY operation.

I have taken out the "columns" from the BUILDs (those numbers followed by a colon). If the data is going into that column automatically (which it is), then using the columns only creates work, introduces a new possibility of error, and makes the Sort Control Cards more difficult to maintain.

The question is unclear, so this is just a guess at what was wanted.

There was mention of OUTREC.

From the context, this is OUTREC on OUTFIL. There is a separate OUTREC statement. To avoid confusion (due to the "overloading" of OUTREC), don't use OUTREC on OUTFIL, which is for "backwards compatability", use the modern BUILD instead, which is entirely equivalent.

BUILD exists on INREC, OUTREC and OUTFIL, separately and as part of an IFTHEN. OUTREC as equivalent of BUILD is only on OUTFIL.

On INREC and OUTREC, FIELDS also has the "overloading" for the same reason (the backwards thing).

Don't use INREC FIELDS=, or OUTREC FIELDS= or OUTFIL OUTREC=, use BUILD in their place.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
0

The below is what I think you are trying to do. Include 1 excludes what Include 2 and 3 will select, likewise Include 2 excludes what 1 and 3 will select. Include 3 is doing the same except excluding 1 and 2 includes.

Each FILE DD has only 1 record from the below and all the records are copied to the sortout

//SORTIN  DD *
AMSAM00Y0000
AMSAM00N0001
AMSAM00Y0001
AMSAM00N0000
//SORTOUT DD SYSOUT=*
//SYSIN    DD *
  SORT  FIELDS=COPY
     OUTFIL FNAMES=FILE1,
        INCLUDE=(1,7,CH,EQ,C'AMSAM00',
                 AND,8,1,CH,NE,C'Y',AND,9,4,CH,EQ,C'0000'),
        BUILD=(1,12)
     OUTFIL FNAMES=FILE2,
        INCLUDE=(1,7,CH,EQ,C'AMSAM00',AND,
                 8,1,CH,EQ,C'Y',AND,
                 9,4,CH,EQ,C'0000'),
        BUILD=(1,12)
     OUTFIL FNAMES=FILE3,
        INCLUDE=(1,7,CH,EQ,C'AMSAM00',AND,
                 8,1,CH,NE,C'Y',AND,
                 9,4,CH,NE,C'0000'),
        BUILD=(1,12)


FIlE1
AMSAM00N0000

FILE2
AMSAM00Y0000

FILE3
AMSAM00N0001

SORTOUT
AMSAM00Y0000
AMSAM00N0001
AMSAM00Y0001
AMSAM00N0000
Deuian
  • 831
  • 1
  • 6
  • 12
  • confused.. Can you please explain how this would work over the syntax i have tried. Also this INCLUDE will not give me the file i want. – change Jul 16 '12 at 07:49
  • Maybe I have it wrong but I was trying to have the first include exclude what would get selected in the second an subsequent includes. Do you have an example of the input and expected output? – Deuian Jul 17 '12 at 14:29