1. It contains the following characters that I want to retain ( and maintain the same column position ) -
'A' through 'Z'
'a' through 'z'
0 through 9
Special characters like '!', '@', '#', '$' etc. ( did not want to list the entire set here, as I can add them once I know the correct jcl)
2. Want to remove junk characters like X'AD', X'00', X'15' etc. from the record and replace EACH of them with space ( X'40').
I know the 'good' characters, but I do not know all the 'bad' characters.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Wouldn't the "bad" characters be the set of characters that are NOT the good characters? If you really don't know the bad characters, how could you specify them using any method? Are you expecting a "program" to figure out the "bad" characters by magic rather than by logic?
Looking at Frank work wonders, I thought I might ask here.
If I 'define' the set of good characters, then obviously it follows that the rest of the character set has junk data. Hence, this list might be longer, but given the range of value - from x'00' to x'ff', yes it can be done.
Here First name = MERCEDES
and Last name = \AESTRO
For the above two records, I have to remove \(fwd slash) ,(comma) and "(double quotes). After removal of these special chars. the records should look as follows:
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You seem to want to "remove" some characters and "overlay" other characters with blank, but it isn't clear exactly what you want to do. Are you trying to "remove" or "overlay" characters only in certain columns or everywhere in the record or what? You need to do a better job of explaining the "rules" for getting from input to output.
Joined: 07 Jun 2008 Posts: 34 Location: Harrisburg, Pennsylvania
1) In above two records, from column 23 to column 62 , I have to overlay \ (fwd slash) and "(double quotes) and to remove , (comma).
Overall if the special charater is present at the starting position of the field (means column 23 for last name and column 48 for first name), I have to overlay ( means shift the rest of the characters in the fields to left by removing that special character) and it should not disturb other fields in the record (means other than laat name and first name).
Last name = column 23 to column 47
First name = column 48 to column 62
2)Also if any special characters like `~!@#$%^&*()_-+=\|:";'{}[]?/>.<, present at the end or in between (means column 24 to column 47 for last name and column 49 to column 62 for first name) of the first name or last name that also i have to replace it with space X'40'. For this I used the following code, and it
was working fine.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Sagar,
I think this DFSORT job will do what you asked for. I added 7F40 to your ALTSEQ list to cover " (double quote). You can add whatever other characters you need to replace with blank to the ALTSEQ list. You can add whatever other characters you need to remove and shift left to the PREBLANK lists.
Joined: 07 Jun 2008 Posts: 34 Location: Harrisburg, Pennsylvania
Dick,
I have implemented part 2) in COBOL using INSPECT verb as follows
part 2) "Also if any special characters like `~!@#$%^&*()_-+=\|:";'{}[]?/>.<, present at the end or in between (means column 24 to column 47 for last name and column 49 to column 62 for first name) of the first name or last name that also i have to replace it with space X'40'. "
Code:
100-100-CHECK-RECORD.
INSPECT WS-CUST01-REC(23:62) CONVERTING "." TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "~" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "`" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "!" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "@" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "#" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "$" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "%" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "^" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "&" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "*" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "(" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING ")" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "_" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "-" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "+" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "," TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "/" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "?" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "'" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING ">" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING ":" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING ";" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "=" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "\" TO " "
INSPECT WS-CUST01-REC(23:62) CONVERTING "<" TO " ".
But , I'm still in doubt , to implement part 1) means removing any special charater from position 23 (starting position of LAST NAME)and position 48(starting position of FIRST NAME) and after removal, shift the rest of the text in that field towards left without disturbing the positions of other fields in records..
Can you please give me glimpse of code to implement the part 1) ?
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello Sagar,
To do what you want for part 1 (removing unwanted characters), i'd suggest defining a field to "receive" the corrected string and initialize it to spaces. Then positon yourself at the beginning of the input field and the receiving field. If the current character is "good", move it to the receiving field and increment the position in both fields. If the current character is not "good" only increment the input field positon.
To define the good charactgers, i'd use something like:
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
OK Frank, I think mine is 2005....if you look at the top-line of the snapshot (code posted) of error encountered ...
Sagar,
I was just responding to your statement that "I think 'JFY' function is not supported by the vrsion of DFSORT/ISPF, is that the case?". For the record, I wanted to make it clear that DFSORT has supported JFY for a long time. Since Dick pointed out previously that you are using Syncsort, not DFSORT, I didn't see the need to repeat that, but maybe I should have.