Page 1 of 1

Sort Depending on Field Length

PostPosted: Tue Jul 20, 2010 4:41 pm
by vegafacundodaniel
I have an input VARIABLE dataset. Something like this :
-TEST1
-123456
-ABCDEF
-BFDSS

My field starts at the 1st position of the file and it takes 6 positions. X(6)

I must sort all records with :
- For the records with 6 characters in the field, I have to take the last 5 characters. For ex: For ABCDEF, I need to take BCDEF.
- For the records with 5 characters in the field, I have to take the 5 characters. For ex: For TEST1, I need to take TEST1

The sorted output file must be:
-BCDEF
-BFDSS
-TEST1
-23456

It is important to consider that the input file is variable.

Re: Sort Depending on Field Length

PostPosted: Tue Jul 20, 2010 9:24 pm
by skolusu
vegafacundodaniel wrote:It is important to consider that the input file is variable.


vegafacundodaniel,


Did you mean to say that the input file is DCB is VB which has the RDW in the first 4 bytes? or the file is FB file but the DATA in the file is variable?

Since you did not provide the LRECL and RECFM , for now I am going to assume it is FB recfm and LRECL of 80.


The following DFSORT JCL will give you the desired results

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                               
-TEST1                                         
-123456                                       
-ABCDEF                                       
-BFDSS                                         
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                               
  INREC OVERLAY=(81:2,6,JFY=(SHIFT=RIGHT))     
  SORT FIELDS=(82,5,CH,A)                     
  OUTREC BUILD=(1,1,82,5,X,8,73)               
//*


The output of this is

-BCDEF
-BFDSS
-TEST1
-23456

Re: Sort Depending on Field Length

PostPosted: Wed Jul 21, 2010 4:36 pm
by vegafacundodaniel
Thanks Skolusu for your help,

My input file is VB of 1000 characters (which has the RDW in the first 4 bytes) and my output file is FB 996.

Thanks in advance !!!

Re: Sort Depending on Field Length

PostPosted: Wed Jul 21, 2010 11:20 pm
by skolusu
vegafacundodaniel wrote:Thanks Skolusu for your help,

My input file is VB of 1000 characters (which has the RDW in the first 4 bytes) and my output file is FB 996.

Thanks in advance !!!



*Sigh* You show an example of 6 characters out of which you removed just 1 character . But now you show that need 4 bytes to be taken off from the input. What is the position and format of the input field that you want to sort and what are the complete rules?

Here is a sample job which assumes that your sorting start starts at pos 6 for 6 bytes and you want to remove the first byte of it. The output file is VB with LRECL of 999

//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD DSN=Your input VB 1000 byte file,DISP=SHR               
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                               
  INREC BUILD=(1,4,6,6,JFY=(SHIFT=RIGHT),5)   
  SORT FIELDS=(6,5,CH,A),EQUALS                     
  OUTREC BUILD=(1,4,11,1,6,5,18)             
//*

Re: Sort Depending on Field Length

PostPosted: Thu Jul 22, 2010 1:08 am
by NicC
errr...Kolusu - he wants a RECFM=FB LRECL=996 output file

Re: Sort Depending on Field Length

PostPosted: Thu Jul 22, 2010 2:01 am
by skolusu
NicC wrote:errr...Kolusu - he wants a RECFM=FB LRECL=996 output file


oops . just noticed that. Thanks, In that case he needs to use the following control cards.
//SYSIN    DD *                                   
  INREC BUILD=(1,4,6,6,JFY=(SHIFT=RIGHT),5)       
  SORT FIELDS=(6,5,CH,A)                         
  OUTFIL VTOF,BUILD=(11,996)                     
//*