Page 1 of 1

Elimination of Special Char. Using SORT.

PostPosted: Wed Jan 16, 2013 9:31 pm
by Vineet
Hi,

I am having a sequential file having LRECL = 80, RECFM = FB. Each Record is combination of Alphabets (Combination of Upper Case & Lower Case) & Numbers. My Requirement is

(1) If for any Record there is a Character like , " %$ @ * . etc at any position, other than Alphabet (both Upper Case & Lower Case) & Numbers should get written to File A
(2) If for any record having Alphabets (both Upper Case & Lower Case) & Numbers should get written to File B.

Below is Example. Both File A & B Having LRECL = 80 & RECFM = FB.

Example:

ABCDERT123456eeefghnkl9876MMOP ---> No Special char. Should get written to File B.
ABCDFRGT'MN,34567iolkmn..OOPMQ ---> Having Special char. (' , ..) Should get written to Fil A. Having Multiple Occurence of Special Char.
POLMNB'123456789opnmcb ----> Having Special Char (') should get written to file A. Having Single Occurence of Special Char.

Can above stated request be perform using SORT.

Thanks
Kind Rgd's

Vineet Anand

Re: Elimination of Special Char. Using SORT.

PostPosted: Wed Jan 16, 2013 11:52 pm
by skolusu
vineet,

use the following DFSORT JCL which will give you the desired results. I accounted for most of the special characters, but if you have more ,you can just add them.
//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD *                               
ABCDERT123456eeefghnkl9876MMOP               
ABCDFRGT'MN,34567iolkmn..OOPMQ               
POLMNB'123456789opnmcb                       
//FILEA    DD SYSOUT=*                       
//FILEB    DD SYSOUT=*                       
//SYSIN    DD *                               
  OPTION COPY                                               
  INREC IFTHEN=(WHEN=(1,80,SS,EQ,C'`',OR,1,80,SS,EQ,C'`',OR,
                      1,80,SS,EQ,C'!',OR,1,80,SS,EQ,C'@',OR,
                      1,80,SS,EQ,C'#',OR,1,80,SS,EQ,C'$',OR,
                      1,80,SS,EQ,C'%',OR,1,80,SS,EQ,C'¢',OR,
                      1,80,SS,EQ,C'&',OR,1,80,SS,EQ,C'*',OR,
                      1,80,SS,EQ,C'(',OR,1,80,SS,EQ,C')',OR,
                      1,80,SS,EQ,C'_',OR,1,80,SS,EQ,C'-',OR,
                      1,80,SS,EQ,C'+',OR,1,80,SS,EQ,C'=',OR,
                      1,80,SS,EQ,C'¬',OR,1,80,SS,EQ,C'{',OR,
                      1,80,SS,EQ,C'¦',OR,1,80,SS,EQ,C'}',OR,
                      1,80,SS,EQ,C'',OR,1,80,SS,EQ,C'/',OR,
                      1,80,SS,EQ,C'|',OR,1,80,SS,EQ,C';',OR,
                      1,80,SS,EQ,C'[',OR,1,80,SS,EQ,C']',OR,
                      1,80,SS,EQ,C':',OR,1,80,SS,EQ,C',',OR,
                      1,80,SS,EQ,C'<',OR,1,80,SS,EQ,C'>',OR,
                      1,80,SS,EQ,C'.',OR,1,80,SS,EQ,C'?',OR,
                      1,80,SS,EQ,C'"',OR,1,80,SS,EQ,C'''',OR,
                      1,80,SS,EQ,C'^',OR,1,80,SS,EQ,X'05'), 
  OVERLAY=(81:C'B'))                                         
                                                             
  OUTFIL FNAMES=FILEA,BUILD=(1,80),INCLUDE=(81,1,CH,EQ,C' ')
  OUTFIL FNAMES=FILEB,BUILD=(1,80),SAVE                     
//*

Re: Elimination of Special Char. Using SORT.

PostPosted: Thu Jan 24, 2013 1:07 am
by Vineet
Hi Skolusu,
Thanks for the update. I have another query. I am having a sequential file having LRECL = 150, RECFM=FB. There is a Field Which start at Position 11 & having lenght of 16. If for said field we encounter any special char. that particular record to be written to File A (LRECL = 150, RECFM=FB), where as for all other records where there is no special char. starting from Position 11, should get written to File B(LRECL = 150, RECFM=FB).

In the Sort Card I just want to check for Alphabets (Both Upper Case & Lower Case) & Numbers. I wrote a SORT card but not getting desire O/P. Please have a look & suggest.

OPTION COPY
INREC IFTHEN=(WHEN=(11,16,SS,EQ,C'abcdefghijklmnopqrstuvwxyz',OR,
11,16,SS,EQ,C'ABCDEFGHIJKLMNOPQRSTUVWXYZ',OR,
11,16,SS,EQ,C'0123456789'),
OVERLAY=(151:C'B'))
OUTFIL FNAMES=FILEA,BUILD=(1,150),INCLUDE=(151,1,CH,EQ,C' ')
OUTFIL FNAMES=FILEB,BUILD=(1,150),SAVE

Re: Elimination of Special Char. Using SORT.

PostPosted: Thu Jan 24, 2013 1:36 am
by BillyBoyo
Did you look at the example you were given?

Re: Elimination of Special Char. Using SORT.

PostPosted: Thu Jan 24, 2013 1:58 am
by Vineet
It's Not an Example. Its the SORT card I am using & not getting the desired result.

Re: Elimination of Special Char. Using SORT.

PostPosted: Thu Jan 24, 2013 2:01 am
by BillyBoyo
I'll try again. Did you look at the example you were given by Kolusu?

If you want to include "positively" you will need 36 tests along the lines that Kolusu showed for excluding special characters.

Re: Elimination of Special Char. Using SORT.

PostPosted: Thu Jan 24, 2013 2:08 am
by Vineet
Yes I went thru the example which KOLUSU gave & I ran my query & it went fine. I am having another query, is there a way to check for Alphabets (both Upper & Lower Case) & Numeric Values only.

Re: Elimination of Special Char. Using SORT.

PostPosted: Thu Jan 24, 2013 2:15 am
by dick scherrer
Hello,

Please post your attempt at checking for the 36 values mentioned by BB. This is NOT your original requirement and needs different sort control . . .

Re: Elimination of Special Char. Using SORT.

PostPosted: Thu Jan 24, 2013 3:41 am
by skolusu
Vineet wrote:It's Not an Example. Its the SORT card I am using & not getting the desired result.


You need to check each byte individually. You would need 16(uppercase)+16(lowercase)+16(numeric) = 48 conditions checking each individual byte.

ex:
INREC IFTHEN=(WHEN=(11,1,SS,EQ,C'ABCDEFGHIJKLMNOPQRSTUVWXYZ',OR,
                    12,1,SS,EQ,C'ABCDEFGHIJKLMNOPQRSTUVWXYZ',OR,
....
                    26,1,SS,EQ,C'ABCDEFGHIJKLMNOPQRSTUVWXYZ',OR,


The other option is to copy the field temporarily at end and use FINDREP to replace all the known values and filter the records.

//STEP0100 EXEC PGM=SORT         
//SYSOUT   DD SYSOUT=*           
//SORTIN   DD DISP=SHR,DSN=Your input FB 150 byte lrecl file
//FILEA    DD SYSOUT=*                                         
//FILEB    DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(151:11,16)),                 
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=151,OUT=C'',             
  IN=(C'A',C'B',C'C',C'D',C'E',C'F',C'G',C'H',C'I',C'J',C'K',   
      C'L',C'M',C'N',C'O',C'P',C'Q',C'R',C'S',C'T',C'U',C'V',   
      C'W',C'X',C'Y',C'Z',                                     
      C'a',C'b',C'c',C'd',C'e',C'f',C'g',C'h',C'i',C'j',C'k',   
      C'l',C'm',C'n',C'o',C'p',C'q',C'r',C's',C't',C'u',C'v',   
      C'w',C'x',C'y',C'z',                                     
      C'0',C'1',C'2',C'3',C'4',C'5',C'6',C'7',C'8',C'9')))     
                                                               
  OUTFIL FNAMES=FILEA,BUILD=(1,150),INCLUDE=(151,1,CH,EQ,C' ') 
  OUTFIL FNAMES=FILEB,BUILD=(1,150),SAVE                       
//*