|
While you still have to do a bit of work the TESTN opcode in RPG does a pretty simple and straight forward test to see if an alpha field can be directly converted into a numeric field using a MOVE opcode
Im sure there are more complex ways of doing this and testing for decimals points and negative signs and the like, but for a 'quick' check TESTN may be old fashioned but works just fine.
----------
From: MacWheel99@aol.com[SMTP:MacWheel99@aol.com]
Reply To: MIDRANGE-L@midrange.com
Sent: Tuesday, June 13, 2000 1:36 PM
To: MIDRANGE-L@midrange.com
Subject: Numeric from Alpha
We have Alpha numeric fields in which our users sometimes insert pure numbers
then ask for some reports based on their numbers input ... excluding records
with valid alpha, whose numeric manipulations would cause a decimal data
error. There is no coding substructure that would tell me when some alpha
field is supposed to be purely numeric.
My current scenario is BPCS item master in which a string of numbers with
certain leading digits are being used for a particular purpose & the users
what to see where there are gaps in the numbers assigned so far.
I have a plan for how to tackle this & what I am looking for is if my idea is
good enough, or if there is a better or simpler algorithm in RPG/400 and/or
embedded SQL that won't do excessive machine cycles to identify data in an
alpha field that really is all numeric in certain portions of the field &
disregard the rest.
My plan is data structure overlay field with an array
test each element of the alpha field
Yes/No can I find it in a look up match vs. digits zero to nine array
any miss & that record is ignored
Al Macintyre ©¿©
http://www.cen-elec.com MIS Manager Programmer & Computer Janitor
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.