Page 1 of 1

How to extract records from binary field

PostPosted: Mon Jan 16, 2012 12:11 pm
by Jayakumar CR
Hi,

I have an input file of 80 bytes length. Position 9 contains a binary field of 4 digits.
I want to extract records from this binary field (ie 9,4,BI), and write the outputs to 5 different files.

Condition is that, all the records ending with 1 from this binary field should go to file 1, all the records ending with 2 should go to file 2 and so on...
For eg:, if the binary field contains a value 12345, that record should go to FILE 5 (as the last digit of "12345" is 5)

Can you help me write a sort card for this

Thanks,
Jay

Re: How to extract records from binary field

PostPosted: Mon Jan 16, 2012 1:17 pm
by BillyBoyo
I've assumed FB for your input. The overlay "edits" the binary field, but only gives it a length of 1, appended to the record. This is then tested, and dropped as the output goes to files 1-5. Note: anything ending in 6, 7, 8, 9 or 0 will just disappear. You might not want that...

//SPLIT5 EXEC PGM=SORT
//SYSIN DD *
                                                 
 INREC OVERLAY=(81:9,4,BI,M11,LENGTH=1)
 OPTION COPY
 OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'1'),
           BUILD=(1,80)
 OUTFIL FNAMES=OUT2,INCLUDE=(81,1,CH,EQ,C'2'),
           BUILD=(1,80)
 OUTFIL FNAMES=OUT3,INCLUDE=(81,1,CH,EQ,C'3'),
           BUILD=(1,80)
 OUTFIL FNAMES=OUT4,INCLUDE=(81,1,CH,EQ,C'4'),
           BUILD=(1,80)
 OUTFIL FNAMES=OUT5,INCLUDE=(81,1,CH,EQ,C'5'),
           BUILD=(1,80)
                                                 
//SYSOUT DD SYSOUT=*
//OUT1 DD DSN=your output 1
//OUT2 DD DSN=your output 2
//OUT3 DD DSN=your output 3
//OUT4 DD DSN=your output 4
//OUT5 DD DSN=your output 5
//SORTIN DD DSN=your input