|
To validate the 15 character field, to check the 1st 4 character for
numeric, you could do this:
01 MISC-AREA.
05 VNCOMPANY PIC X(15).
05 VNCOMPAY-NAME.
10 VNCOMPANY-ALPHA PIC X(04).
10 VNCOMPANY-BLANK PIC X(11).
MOVE VNCOMPANY(1:4) TO VNCOMPANY-ALPHA.
MOVE VNCOMPAY(5:11) TO VNCOMPANY-BLANK
IF VNCOMPANY-ALPHA IS NUMERIC AND VNCOMPANY-BLANK = SPACES
(THEN THE 1ST 4 CHARACTERS ARE NUMERIC AND BYTES 5 - 15
ARE. THIS IS A VALID COMPANY)
-------------------------------------------------------------
OR THE CODE BELOW WILL WORK
IF VNCOMPANY(1:4) IS NUMERIC AND VNCOMPANY(5:11) = SPACES
(THEN THE 1ST 4 CHARACTERS ARE NUMERIC AND BYTES 5 - 15
ARE. THIS IS A VALID COMPANY)
----------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
----------------------------------------------------------------------------------------
|---------+--------------------------->
| | cobol400-l-reque|
| | st |
| | @midrange.com |
| | Sent by: |
| | cobol400-l-bounc|
| | es |
| | |
| | |
| | 06/10/2003 12:00|
| | PM |
| | Please respond |
| | to cobol400-l |
| | |
|---------+--------------------------->
>---------------------------------------------------------------------------------------------------------------|
|
|
| To: cobol400-l@xxxxxxxxxxxx
|
| cc:
|
| Subject: COBOL400-L Digest, Vol 1, Issue 233
|
>---------------------------------------------------------------------------------------------------------------|
Send COBOL400-L mailing list submissions to
cobol400-l@xxxxxxxxxxxx
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.midrange.com/mailman/listinfo/cobol400-l
or, via email, send a message with subject or body 'help' to
cobol400-l-request@xxxxxxxxxxxx
You can reach the person managing the list at
cobol400-l-owner@xxxxxxxxxxxx
When replying, please edit your Subject line so it is more specific
than "Re: Contents of COBOL400-L digest..."
Today's Topics:
1. Testing for valid numeric in an alpha field (Dan)
2. R: Testing for valid numeric in an alpha field (Finucci Domenico)
3. RE: Testing for valid numeric in an alpha field (Jerry Thomas)
4. RE: Testing for valid numeric in an alpha field (Cousino, Alexis)
5. RE: Testing for valid numeric in an alpha field (Cousino, Alexis)
----------------------------------------------------------------------
message: 1
date: Tue, 10 Jun 2003 07:29:30 -0700 (PDT)
from: Dan <dbcerpg@xxxxxxxxx>
subject: Testing for valid numeric in an alpha field
I know how to do this in RPG but not Cobol:
I've got a 15-character alpha that is supposed to contain a 4-digit number
left-justified. In my
Cobol program, VNCOMPANY is a 15-character alpha field and WS-VND-COMPANY
is a 4-digit numeric.
When I do this:
MOVE VNCOMPANY TO WS-VND-COMPANY.
and VNCOMPANY contains '40 ', I get a decimal data error.
In RPG, I'd use a MOVEL and a TESTN. Off the top of my head, the only way
I can see doing this in
Cobol is to check the first four bytes of the field individually to be in
the range of '0' through
'9'. (Bytes 5-15 would have to be blank for our validation purposes.)
Any suggestions?
TIA, Dan
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
------------------------------
message: 2
date: Tue, 10 Jun 2003 16:58:10 +0200
from: Finucci Domenico <Domenico.Finucci@xxxxxxxxxxxx>
subject: R: Testing for valid numeric in an alpha field
if YourField NUMERIC
Sincerely
Domenico Finucci
Fiditalia , Milano, 02- 4301-2494
-----Messaggio originale-----
Da: Dan [mailto:dbcerpg@xxxxxxxxx]
Inviato: martedì 10 giugno 2003 16.30
A: cobol400-l@xxxxxxxxxxxx
Oggetto: Testing for valid numeric in an alpha field
I know how to do this in RPG but not Cobol:
I've got a 15-character alpha that is supposed to contain a 4-digit number
left-justified. In my
Cobol program, VNCOMPANY is a 15-character alpha field and WS-VND-COMPANY
is
a 4-digit numeric.
When I do this:
MOVE VNCOMPANY TO WS-VND-COMPANY.
and VNCOMPANY contains '40 ', I get a decimal data error.
In RPG, I'd use a MOVEL and a TESTN. Off the top of my head, the only way
I
can see doing this in
Cobol is to check the first four bytes of the field individually to be in
the range of '0' through
'9'. (Bytes 5-15 would have to be blank for our validation purposes.)
Any suggestions?
TIA, Dan
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
_______________________________________________
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing
list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/cobol400-l.
------------------------------
message: 3
date: Tue, 10 Jun 2003 10:28:06 -0500
from: "Jerry Thomas" <jerryt@xxxxxxxxxxx>
subject: RE: Testing for valid numeric in an alpha field
If you are sure you have numeric data in VNCOMPANY then the below statement
will do what you want.
COMPUTE WS-VND-COMPANY = FUNCTION NUMVAL(VNCOMPANY)
Jerry
-----Original Message-----
From: cobol400-l-bounces@xxxxxxxxxxxx
[mailto:cobol400-l-bounces@xxxxxxxxxxxx]On Behalf Of Dan
Sent: Tuesday, June 10, 2003 9:30 AM
To: cobol400-l@xxxxxxxxxxxx
Subject: Testing for valid numeric in an alpha field
I know how to do this in RPG but not Cobol:
I've got a 15-character alpha that is supposed to contain a 4-digit number
left-justified. In my
Cobol program, VNCOMPANY is a 15-character alpha field and WS-VND-COMPANY
is
a 4-digit numeric.
When I do this:
MOVE VNCOMPANY TO WS-VND-COMPANY.
and VNCOMPANY contains '40 ', I get a decimal data error.
In RPG, I'd use a MOVEL and a TESTN. Off the top of my head, the only way
I
can see doing this in
Cobol is to check the first four bytes of the field individually to be in
the range of '0' through
'9'. (Bytes 5-15 would have to be blank for our validation purposes.)
Any suggestions?
TIA, Dan
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
_______________________________________________
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing
list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/cobol400-l.
------------------------------
message: 4
date: Tue, 10 Jun 2003 11:51:16 -0400
from: "Cousino, Alexis" <acousino@xxxxxxxx>
subject: RE: Testing for valid numeric in an alpha field
Dan,
To prevent a decimal data error when the field does not contain numerics,
redefine the receiving field and test for numerics before performing any
calculations.
05 ws-vnd-company pic 9(04).
05 ws-vnd-company-x refefines ws-vnd-company pic x(04).
MOVE VNCOMPANY TO WS-VND-COMPANY.
if ws-vnd-company-x not numeric
move zeros to ws-vnd-company.
Alexis Cousino
Detroit Newspapers
acousino@xxxxxxxx
-----Original Message-----
From: Dan [mailto:dbcerpg@xxxxxxxxx]
Sent: Tuesday, June 10, 2003 10:30 AM
To: cobol400-l@xxxxxxxxxxxx
Subject: Testing for valid numeric in an alpha field
I know how to do this in RPG but not Cobol:
I've got a 15-character alpha that is supposed to contain a 4-digit number
left-justified. In my
Cobol program, VNCOMPANY is a 15-character alpha field and WS-VND-COMPANY
is a 4-digit numeric.
When I do this:
MOVE VNCOMPANY TO WS-VND-COMPANY.
and VNCOMPANY contains '40 ', I get a decimal data error.
In RPG, I'd use a MOVEL and a TESTN. Off the top of my head, the only way
I can see doing this in
Cobol is to check the first four bytes of the field individually to be in
the range of '0' through
'9'. (Bytes 5-15 would have to be blank for our validation purposes.)
Any suggestions?
TIA, Dan
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
_______________________________________________
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing
list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/cobol400-l.
------------------------------
message: 5
date: Tue, 10 Jun 2003 11:59:14 -0400
from: "Cousino, Alexis" <acousino@xxxxxxxx>
subject: RE: Testing for valid numeric in an alpha field
Dan,
Oops...
I should have said move vndcompany to ws-vnd-company-x. This will
accomplish the same result as a MOVEL.
To prevent a decimal data error when the field does not contain numerics,
redefine the receiving field and test for numerics before performing any
calculations.
05 ws-vnd-company pic 9(04).
05 ws-vnd-company-x refefines ws-vnd-company pic x(04).
MOVE VNCOMPANY TO WS-VND-COMPANY.
if ws-vnd-company-x not numeric
move zeros to ws-vnd-company.
Alexis Cousino
Detroit Newspapers
acousino@xxxxxxxx
-----Original Message-----
From: Dan [mailto:dbcerpg@xxxxxxxxx]
Sent: Tuesday, June 10, 2003 10:30 AM
To: cobol400-l@xxxxxxxxxxxx
Subject: Testing for valid numeric in an alpha field
I know how to do this in RPG but not Cobol:
I've got a 15-character alpha that is supposed to contain a 4-digit number
left-justified. In my
Cobol program, VNCOMPANY is a 15-character alpha field and WS-VND-COMPANY
is a 4-digit numeric.
When I do this:
MOVE VNCOMPANY TO WS-VND-COMPANY.
and VNCOMPANY contains '40 ', I get a decimal data error.
In RPG, I'd use a MOVEL and a TESTN. Off the top of my head, the only way
I can see doing this in
Cobol is to check the first four bytes of the field individually to be in
the range of '0' through
'9'. (Bytes 5-15 would have to be blank for our validation purposes.)
Any suggestions?
TIA, Dan
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
_______________________________________________
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing
list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/cobol400-l.
------------------------------
_______________________________________________
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) digest list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/cobol400-l.
End of COBOL400-L Digest, Vol 1, Issue 233
******************************************
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.