How to do data validation on special characters! 
Author Message
 How to do data validation on special characters!

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.*-*-*.com/
Before you buy.



Fri, 08 Nov 2002 03:00:00 GMT  
 How to do data validation on special characters!

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


        [snip]
Use a class test. I don't have my COBOL manual right here, but I think you
can simply do something like:

IF VARIABLE-NAME IS NOT ALPHABETIC THEN
  ... error code ..
END-IF

Hope this gets you on the right course.

John



Fri, 08 Nov 2002 03:00:00 GMT  
 How to do data validation on special characters!
The reason that your 88 did not work is that you have it defined wrong.  You
do not want an X(24) field, you want 24 X(1) fields.
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.



Fri, 08 Nov 2002 03:00:00 GMT  
 How to do data validation on special characters!

Quote:
> 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?

two things -- your level 88 needs to be 24 one byte fields -- but you
can byte check your field (one at a time) checking for ranges of ok
values such as.  It seems there are always at least 3 correct ways to
solve any problem

evaluate byte
 when 0 through 9
   ok (check next byte)
 when a through Z
   ok (check next byte)
 when spaces
   ok (check next byte)
 when other
   bad information
end-evaluate

        Susan A



Fri, 08 Nov 2002 03:00:00 GMT  
 How to do data validation on special characters!
I agree with John. Set up a class in Special names then check your
field against it:

ie

if data-field not alphanumeric-x.

Alphanumeric-x is the class you define in special names.

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.



Fri, 08 Nov 2002 03:00:00 GMT  
 How to do data validation on special characters!
First off, those are not valid addresses.
They may be valid EMail addresses.
Redefine the field as a PIC X occurs n times.
Loop thru checking each position for
IF ws-name-char(WS-SUB) not numeric
  and not alphabetic
    move SPACE to ws-name-char(WS-SUB)
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.



Fri, 08 Nov 2002 03:00:00 GMT  
 How to do data validation on special characters!
Wouldn't it be safer to split:
    when a through Z
       ok (check next byte)
into two pieces:
   when a through z
      ok (check next byte)
   when A through Z
      ok (check next byte)
since there could possibly be invalid characters between z and A which
should be rejected.
Quote:
> two things -- your level 88 needs to be 24 one byte fields -- but you
> can byte check your field (one at a time) checking for ranges of ok
> values such as.  It seems there are always at least 3 correct ways to
> solve any problem

> evaluate byte
>  when 0 through 9
>    ok (check next byte)
>  when a through Z
>    ok (check next byte)
>  when spaces
>    ok (check next byte)
>  when other
>    bad information
> end-evaluate

> Susan A



Fri, 08 Nov 2002 03:00:00 GMT  
 How to do data validation on special characters!
On Mon, 22 May 2000 19:52:11 -0400, William C. Bub
]>Wouldn't it be safer to split:
]>    when a through Z
]>       ok (check next byte)
]>into two pieces:
]>   when a through z
]>      ok (check next byte)
]>   when A through Z
]>      ok (check next byte)
]>since there could possibly be invalid characters between z and A which
]>should be rejected.
]>

One major problem with that. In EBCDIC (OS/390 character set), the alphabetic
characters are grouped (a..i) (j..r) (s..z) (A..I) (J..R) (S..Z) with other
non-alphabetics between the groups!



Fri, 08 Nov 2002 03:00:00 GMT  
 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.



Sat, 09 Nov 2002 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Record Locking while doing data validation

2. data validation and data format

3. data validation and data format

4. Text widget validation for hex characters

5. Converting INTEGER to CHARACTER - can it be done?

6. Need suggestion on doing character-graphic testing

7. Converting INTEGER to CHARACTER - can it be done?

8. Converting INTEGER to CHARACTER - can it be done?

9. Protecting special awk characters

10. Searching/Replacing with special characters.

11. HELP! special characters

12. Special characters in titles?

 

 
Powered by phpBB® Forum Software