How to do data validation on special characters!
Hey, you've got yourself a quit complex task here.
Try to write down all the rules for acceptable data before coding your
program.
Something like:
1. Letters A-Z, a-z and Space are valid
2. Quote is valid after a letter
3. '&' is valid after a letter and perhaps a space
4. Dots are valid after a letter
5. etc. etc.etc.
If you really look at it, you must admit that it can be a hell of a task for
someone new to cobol. Are you shure that you got it right? Doesn't the input
have any structure you could benefit from?
To me et looks as if you have taken a customer file into an editor, and that
the structure could be
01 Cust-rec.
05 Cust-id pic 9(5) comp.
05 Cust-name pic X(20).
05 Credit-limit pic X(10).
:-)))
This is probably not the case, but what I am trying to tell you is: "Study
the input before creating the program logic".
Let us see what you find out to do.
Regards
Ib
Quote:
>Hi,there:
>I am new to Cobol and I'm now doing data validation on an employee
>record file. One of the data fields 'Employee Address' should only
>contain letters and numbers, not special characters.
>But how can I make my program identify those addresses with special
>The only way I can think of is to
>1,list all the special characters in the value clause in the working-
>storage section.
>2.Then use INSPECT to tally special character(s)
>3.If the result of tally >0, Then move the data to err-list.
>Program excerpt:
>WORKING-STORAGE SECTION.
>...
>01 SPECIAL-CHARACTERS.
>PROCEDURE DIVISION.
>...
> INSPECT IN-ADDRESS TALLYING SPE-CHA FOR ALL CHARACTERS
> IF SPE-CHA > 0
> MOVE IN-ADDRESS TO ERR-LIST
> PERFORM 300-ERR-RTN
> END IF.
>But it didn't work. Is the syntex wrong or is my logic wrong? Is there
>other way(better way) to do this?
>Thanks in advance!
>Sent via Deja.com http://www.deja.com/
>Before you buy.