How to copy only selected column of input file to output file in jcl sort

Agent Mahone picture Agent Mahone · Aug 31, 2014 · Viewed 29.4k times · Source

I am trying to copy data at position (50,10) of my input file to an output file, but I am having problems. My input file size is 100; the needed data is from the 50th position for next 10 bytes.

I have used the following options but each of them cause an abend. I have taken output file as length 10 only, as I only need 10 bytes. But abend says. OUTREC RECORD LENGTH = 10

SORTIN   : RECFM=VB   ; LRECL=   100; BLKSIZE=  1000 
SORTIN   : DSNAME=MNV.TESTS.DF.CPR810S1.EZ2OP        
OUTREC RECORD LENGTH =     10                         
SORTOUT  RECFM INCOMPATIBLE                          
SORTOUT  : RECFM=FB   ; LRECL=      ; BLKSIZE=    

I have used the below options:

OUTREC FIELDS(50,10)              
SORT FIELDS(1,4,CH,A)    
--------didn't work------------

SORT FIELDS=COPY            
OUTREC FIELDS=(115,9,125,10) 
--------didn't work------------

SORT  FIELDS=COPY                        
BUILD=(50,10)                  
--------didn't work------------

INREC FIELDS=(50,10)        
SORT FIELDS=(1,3,CH,A) 
--------didn't work------------

Answer

Bill Woodger picture Bill Woodger · Aug 31, 2014

I know it's pointless to mention that you rarely Accept or provide feedback, and are not that much of a voter either.

For some reason you cut them off, but all those messages you posted come with a WER prefix and a message number. If you consult your SyncSORT manual, you'll find all the messages documented.

Forget that for a moment. You have posted SORTOUT RECFM INCOMPATIBLE. Why go on about the record-length? The RECFM. The RECFM. You have included the text of the message which shows the RECFM of the SORTIN, and also the one which shows the RECFM of SORTOUT. They are VB and FB respectively. If you look at the message in the manual, you'll discover that you haven't done anything explicit to make them different.

You have two choices. VTOF or CONVERT. You can use them on OUTREC (I believe) and OUTFIL (for sure).

 OPTION COPY
 OUTFIL VTOF,
        BUILD=(50,10)

Why you'd want to try SORTing the file, I don't know, and you should be aware by not that just making up syntax does not work.

For SORT, by default, the output file is the same RECFM as the input. A variable-length record must always contain an RDW, 1,4 and the data itself starts at position 5.

If you need an output file of a different RECFM, then you must be explicit about it (with CONVERT, FTOV or VTOF).

When creating an F record, no RDW, so your BUILD=(50,10) is the correct format (if you are four bytes out, remember that for a V record, data starts at position five, so you need to add four to all start-positions which don't take account of the RDW (like a COBOL record-layout).

When creating a V from an F, no RDW, the FTOV/CONVERT will create it.

With V input and V output, always specify (1,4 at the start of your BUILD statement.