Elimination of Special Char. Using SORT.



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Elimination of Special Char. Using SORT.

Postby Vineet » Wed Jan 16, 2013 9:31 pm

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
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Elimination of Special Char. Using SORT.

Postby skolusu » Wed Jan 16, 2013 11:52 pm

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                     
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Elimination of Special Char. Using SORT.

Postby Vineet » Thu Jan 24, 2013 1:07 am

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
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Elimination of Special Char. Using SORT.

Postby BillyBoyo » Thu Jan 24, 2013 1:36 am

Did you look at the example you were given?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Elimination of Special Char. Using SORT.

Postby Vineet » Thu Jan 24, 2013 1:58 am

It's Not an Example. Its the SORT card I am using & not getting the desired result.
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Elimination of Special Char. Using SORT.

Postby BillyBoyo » Thu Jan 24, 2013 2:01 am

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Elimination of Special Char. Using SORT.

Postby Vineet » Thu Jan 24, 2013 2:08 am

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.
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Elimination of Special Char. Using SORT.

Postby dick scherrer » Thu Jan 24, 2013 2:15 am

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 . . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Elimination of Special Char. Using SORT.

Postby skolusu » Thu Jan 24, 2013 3:41 am

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                       
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post