Page 1 of 1

VB to multiple FB files using sort, but with a condition.

Posted: Mon Jul 28, 2014 2:21 pm
by Dark Fantasy
Hi,

I've an input variable block file.The data file is like this:

Code: Select all

FD004A001<some varibale data> 
FD004A001<some varibale data> 
FD005A001<some varibale data> 
FD005A002<some varibale data> 
.
.
.
FD100A006<some varibale data> 
All the records records can be in any sequence. I need the records starting with FD004 all in one file, FD005 in one file and so on. All these files should be FB.

I tried the following:

Code: Select all

//STEP01   EXEC PGM=SORT                     
//SORTIN   DD  DSN=MY.INPUT.FILE,      --> vb, recl - 2053
//             DISP=SHR                                  
//SORTOF01 DD  DSN=FILE004.OUTPUT.FILE,      
//             UNIT=(,5),SPACE=(1,(20,20),RLSE),AVGREC=M, 
//             DATACLAS=SXXXFB,LRECL=256,                
//             DISP=(,CATLG,DELETE)                      
//SORTOF02 DD  DSN=FILE005.OUTPUT.FILE,      
//             UNIT=(,5),SPACE=(1,(20,20),RLSE),AVGREC=M, 
//             DATACLAS=SXXXFB,LRECL=89,                  
//             DISP=(,CATLG,DELETE)                      
//SYSIN    DD  *                
SORT   FIELDS=COPY                    
OUTREC FIELDS=(1,2049),CONVERT        
OUTFIL FILES=01,                      
       INCLUDE=(1,5,CH,EQ,C'F0004')  
OUTFIL FILES=02,                      
       INCLUDE=(1,5,CH,EQ,C'F0005')  
Above job executes correct but the required records are not copied. Please help.

Re: VB to multiple FB files using sort, but with a condition

Posted: Tue Jul 29, 2014 1:35 pm
by Anuj Dhawan
Hi,

Your Job looks good to me apart from that you should have used field start position as 5. As you're using VB files - on the OUTREC you should use 5 as start position. Said that, try this and you should be good:

Code: Select all

 SORT   FIELDS=COPY                    
 OUTREC FIELDS=(5,2049),CONVERT        
 OUTFIL FILES=01,INCLUDE=(1,5,CH,EQ,C'F0004')  
 OUTFIL FILES=02,INCLUDE=(1,5,CH,EQ,C'F0005')  

Re: VB to multiple FB files using sort, but with a condition

Posted: Wed Jul 30, 2014 1:43 pm
by Dark Fantasy
Thanks Anuj this has worked but why do you use '5' as starting position?

Re: VB to multiple FB files using sort, but with a condition

Posted: Thu Jul 31, 2014 1:23 pm
by Dark Fantasy
Thanks Anuj this has worked but why do you use '5' as starting position?

Re: VB to multiple FB files using sort, but with a condition

Posted: Thu Jul 31, 2014 4:49 pm
by Anuj Dhawan
You're using a variable-block file for which the data starts at position 5 - first 4 bytes are reserved for record descriptor word (RDW).

In RDW the first 2 bytes contain the length of the logical record. The last 2 bytes must be 0 because these are used for spanned records. When using variable-length records on output, you must provide the RDW; for input, the operating system provides the RDW.

Here is an image from IBM to describe more about RDW:

[center]Image[/center]

Hope this helps.

Re: VB to multiple FB files using sort, but with a condition

Posted: Fri Aug 08, 2014 2:35 pm
by Dark Fantasy
Thanks Anuj.

Re: VB to multiple FB files using sort, but with a condition

Posted: Fri Aug 08, 2014 6:51 pm
by Anuj Dhawan
You're welcome! :)