On Mon, 21 Feb 2000 06:58:16 -0600, "Mark L. Bartlett"
Quote:
>If you use the following compare:
> IF STATE-CODE(STATE-IDX) = instate
>the only time you will get an equal condition is when the instate field contains
>a 2-byte value equal to STATE-CODE(STATE-IDX).
That is not necessarily true. As the original poster stated, he was
worried about Netherlands being equal to NE (the code for Nebraska).
What you told him would fail in this case.
The poster didn't describe his input, but let's assume the input is
something larger than 2 characters. If it is a state code, then there
should be two characters followed by spaces. If it is a country or
state name, then obviously there would be more than two characters.
If we take your example and switch fields around, you can make a
compare just for state code. One could code:
IF INSTATE = STATE-CODE(STATE-IDX)
.
.
.
.
In this instance, the code generated for this compare will compare two
fields of the length of the first field applying padding. If INSTATE
is defined as PIC X(15), Then STATE-CODE(STATE-IDX) will be moved to
a temporary 15 byte area and padded on the right with 13 spaces. The
compare would then be made. If INSTATE only contains two characters
and it is a state code, the IF will be true, otherwise false.
This is not the way I would do it, but it would work.
Quote:
>> If I am validating a state code and a state name with a table created from
>> another dataset composed as follows:
>> 01 STATES-TABLE.
>> 05 STATES-ATT-TBL OCCURS 51 TIMES
>> ASCENDING KEY STATE-CODE
>> INDEXED BY STATE-IDX.
>> 10 STATES-CODE-TABLE.
>> 15 STATE-CODE PIC X(02).
>> 15 STATE-NAME PIC X(15).
>> 15 PIC
>> X(63).
>> The specs state that if the state codes are 2 characters, they should be
>> "legal" state codes and should be verified from the state codes dataset. If
>> the state code is not 2 characters, they should be verified against the
>> state name in the state code dataset. If the state code field cannot be
>> verified to be a "legal" value, it is either in error or represents an
>> international address.
>> Other validations which are linked to the state code check by being
>> international are:
>> If the zip code is US it should be numeric, if not US it should not be
>> edited.
>> If the telephone number is US it should be in one of two formats, if not US
>> is should not be edited.
>> My biggest question is: Is there a way to check that a particular field
>> does indeed have 2 characters? Given the fact that I have defined the state
>> code like it is above. Or should I make STATE-CODE a group item with two
>> elementary state code fields both consisting of PIC X(01). I have tried
>> this several ways and get decent output; however, if the international
>> address starts with the first two letters of a valid state code (i.e.
>> Netherlands - NE for Nebraska) I really don't get what I want. I have a
>> couple of go-bys from other peoples code that turned in their project but I
>> do not beleive that they considered this as their output does not really
>> catch this.
>> Finally can I make this work by defining my state code input using 88's with
>> the valid values of uppercase letters like 'A' THRU 'Z'?
>> Any helpful ideas would be appreciated.
>> Mark
////
(o o)
-oOO--(_)--OOo-
If Webster wrote the first dictionary, where did he find the words?
Remove nospam to email me.
Steve