MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Replace Invalid Characters and Write Good & Bad Record F

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
ayushkavi
Beginner


Joined: 28 Jun 2015
Posts: 2
Topics: 1

PostPosted: Wed Jul 01, 2015 3:45 am    Post subject: Replace Invalid Characters and Write Good & Bad Record F Reply with quote

Could you please help me to create a sort JCL for the below requirement.
I have a file of fixed record length 280. My file structure is like below

1. Emp Number starts from column 8 of length 5.
2. Name start from column 13 of length 30.


As per the design file should contain " A - Z, 0 - 9, /, -, ^, &, spaces" only in the name field Other then those characters everything are considered as invalid for downstream processing.

Code:

***************************** Top of Data ****
00002015-06-25                               
    00012322MRS NEHA PATIL2                   
    00045633MRS VIJETA PATOLE                 
    00078944MR KIRAN/PATIL1                   
    00011155MR PARESH-THOMBARE               
    00022266MR PRAVEEN@DAWAN                 
    00025677MR SUBHAS*YADAV2                 
99990000000006                               
**************************** Bottom of Data **


I want to create 1 output file which will contain all the records from the input file but it should replace all other characters (other then valid one mentioned above) with spaces.

E.g. In the file for employee 22266 names should be changed from PRAVEEN@DAWAN to PRAVEEN DAWAN and for employee 25677 name should be changed from SUBHAS*YADAV2 to SUBHAS YADAV2 :-



Code:

***************************** Top of Data ****
00002015-06-25
00012322MRS NEHA PATIL2
00045633MRS VIJETA PATOLE
00078944MR KIRAN/PATIL1
00011155MR PARESH-THOMBARE
00022266MR PRAVEEN DAWAN
00025677MR SUBHAS YADAV2
99990000000006
**************************** Bottom of Data **


I am using 1.12 level of SORT, if it is required to know the level of sort that I have access. Using FINDREP I am able to replace every single invalid character with spaces. Since I am only aware of valid characters which are allowed for further downstream processing. As there can be many invalid characters, so even if I try to list them under FINDREP to replace with spaces, there are chances that job may fail due to different invalid characters. So better approach would be to allow only valid characters and other then that everything should be replaced with spaces. I hope my requirement is clear.

Could you please help me to creat a sort JCl for my above requirment.
Back to top
View user's profile Send private message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Wed Jul 01, 2015 8:42 am    Post subject: Reply with quote

Here is the solution. The basic idea is to change all the valid characters to x'00' and then subtract the binary value individually.

for example if you have name as 'ABC@'. Now we will replace a,b,c with x'00'

now subtract each individual byte with the replaced value

A in binary is 192 and when subtrac 0 from it, it will still be 192. so the value remains the same. but for @ the subtraction results in 0 as we subtracting its own value. Now we can validate anything which is a binary zero to be replaced with space.

This solution was provided by Kolusu, dont forget to thank him.

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                   
00002015-06-25                                                     
    00012322MRS NEHA PATIL2                                       
    00045633MRS VIJETA PATOLE                                     
    00078944MR KIRAN/PATIL1                                       
    00011155MR PARESH-THOMBARE                                     
    00022266MR PRAVEEN@DAWAN                                       
    00025677MR SUBHAS*YADAV2                                       
99990000000006                                                     
//SORTOUT  DD SYSOUT=*                                             
//BAD      DD SYSOUT=*                                             
//SYSIN    DD *         
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(281:13,30)),                     
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=281,OUT=X'00',                 
          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'0',         
              C'1',C'2',C'3',C'4',C'5',C'6',C'7',C'8',C'9',         
              C'&',C'-',C'/',C'^',C' '))),                           
  IFTHEN=(WHEN=INIT,OVERLAY=(281:13,1,BI,SUB,281,1,BI,BI,LENGTH=1,   
                             282:14,1,BI,SUB,282,1,BI,BI,LENGTH=1,   
                             283:15,1,BI,SUB,283,1,BI,BI,LENGTH=1,   
                             284:16,1,BI,SUB,284,1,BI,BI,LENGTH=1,   
                             285:17,1,BI,SUB,285,1,BI,BI,LENGTH=1,   
                             286:18,1,BI,SUB,286,1,BI,BI,LENGTH=1,   
                             287:19,1,BI,SUB,287,1,BI,BI,LENGTH=1,   
                             288:20,1,BI,SUB,288,1,BI,BI,LENGTH=1,   
                             289:21,1,BI,SUB,289,1,BI,BI,LENGTH=1,   
                             290:22,1,BI,SUB,290,1,BI,BI,LENGTH=1,   
                             291:23,1,BI,SUB,291,1,BI,BI,LENGTH=1,   
                             292:24,1,BI,SUB,292,1,BI,BI,LENGTH=1,   
                             293:25,1,BI,SUB,293,1,BI,BI,LENGTH=1,   
                             294:26,1,BI,SUB,294,1,BI,BI,LENGTH=1,   
                             295:27,1,BI,SUB,295,1,BI,BI,LENGTH=1,   
                             296:28,1,BI,SUB,296,1,BI,BI,LENGTH=1,   
                             297:29,1,BI,SUB,297,1,BI,BI,LENGTH=1,   
                             298:30,1,BI,SUB,298,1,BI,BI,LENGTH=1,   
                             299:31,1,BI,SUB,299,1,BI,BI,LENGTH=1,   
                             300:32,1,BI,SUB,300,1,BI,BI,LENGTH=1,   
                             301:33,1,BI,SUB,301,1,BI,BI,LENGTH=1,   
                             302:34,1,BI,SUB,302,1,BI,BI,LENGTH=1,   
                             303:35,1,BI,SUB,303,1,BI,BI,LENGTH=1,   
                             304:36,1,BI,SUB,304,1,BI,BI,LENGTH=1,   
                             305:37,1,BI,SUB,305,1,BI,BI,LENGTH=1,   
                             306:38,1,BI,SUB,306,1,BI,BI,LENGTH=1,   
                             307:39,1,BI,SUB,307,1,BI,BI,LENGTH=1,   
                             308:40,1,BI,SUB,308,1,BI,BI,LENGTH=1,   
                             309:41,1,BI,SUB,309,1,BI,BI,LENGTH=1,   
                             310:42,1,BI,SUB,310,1,BI,BI,LENGTH=1)),
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=281,IN=X'00',OUT=X'40')) 
                                                               
  OUTFIL IFOUTLEN=280,                                         
  IFTHEN=(WHEN=(13,30,CH,NE,281,30,CH),OVERLAY=(13:281,30))     
                                                               
  OUTFIL FNAMES=BAD,INCLUDE=(13,30,CH,NE,281,30,CH),           
  BUILD=(1,280)                                                 
//*                                                             


Regards,
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 01, 2015 10:41 am    Post subject: Reply with quote

ayushkavi,

Please use meaningful topics . Use a descriptive title to explain your problem. The title "sort file issue" has got nothing to do with what you are trying to accomplish. You are NOT sorting the data. You are merely replacing the invalid characters with a space. I edited your topic title for now. Going forward please keep that in mind.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 01, 2015 11:53 am    Post subject: Reply with quote

Updated post # 2 to account for the correct LRECL of 280 instead of 243.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ayushkavi
Beginner


Joined: 28 Jun 2015
Posts: 2
Topics: 1

PostPosted: Thu Jul 02, 2015 4:47 am    Post subject: Reply with quote

Thanks Kolusu & Magesh for providing the solution. It was a great help.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Jul 06, 2015 11:01 am    Post subject: Reply with quote

Magesh_J wrote:
This solution was provided by Kolusu, dont forget to thank him.


Magesh,

I would really appreciate if you can stop posting the solutions by me on competitive board. The same author has posted the question here and got a solution and I am not really sure as to why you need to post this solution on the other board.

Thanks
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Mon Jul 06, 2015 11:19 am    Post subject: Reply with quote

Kolusu,

Sorry for the inconvenience.

Regards,
Magesh
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group