View previous topic :: View next topic
|
Author |
Message |
thala_ds
New User
Joined: 05 Jun 2012 Posts: 18 Location: India
|
|
|
|
Hi,
I need to check whether the given value is DECIMAL or not ?.
Is there a way to identify from the file like we do it for numeric validation (IS NUMERIC) ?
Your thoughts on this is much appreciated.
Thanks. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
If it is decimal it is numeric - I do not know of any decimal letters. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
What does "DECIMAL" mean to you? Numbers only, as Nic said, means it is NUMERIC. Numbers and a decimal point, or numbers with a sign, may require checking each byte, one by one, to validate they all have appropriate values. |
|
Back to top |
|
|
thala_ds
New User
Joined: 05 Jun 2012 Posts: 18 Location: India
|
|
|
|
Thanks Nic and Robert.
I agree decimal is also a number. I need to find out number with decimal values.
For example in file,
Code: |
Account ---- Amount----
ABS234 1588
ACD235 145.567 |
Here in the above file, i need to validate only the amount which has decimals ie., 145.567 and not 1588
If the amount has decimals , i need to take the account for further processing. How i can get the accounts which has decimals? Please advise.
Hope you can understand the above requirement. Sorry for previous post which was not clearly explained.
Thanks.
Code'd |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Sounds to be a very strange requirement to me atleast
or you are missing to share some key details |
|
Back to top |
|
|
thala_ds
New User
Joined: 05 Jun 2012 Posts: 18 Location: India
|
|
|
|
Hi Pandora-Box,
That's what my requirement is. I will receive an input file which has account number and amount field associated to it. I have to check for decimals in the amount field and i need to process further on those accounts.
Thanks. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Use INSPECT to count the decimal points in the data. The count will be 0 if the value is nothing but numeric digits, and 1 (or more) if not. Note that the count can ber zero when you have non-numeric data, as well. |
|
Back to top |
|
|
haimzeevi
New User
Joined: 01 Mar 2010 Posts: 27 Location: Israel
|
|
|
|
Hi Thala,
Very simple: suppose you issue a READ into an s9(8)v999 variable, copy it to an s9(8) variable and compare them: if there is something to th right of the decimal point, they are not equal, otherwise they are aqual.
Good Luck,
Haim Zeevi |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
What type of READ would that be?
On top of that, the data is shown in variable positions with an actual decimal place. |
|
Back to top |
|
|
haimzeevi
New User
Joined: 01 Mar 2010 Posts: 27 Location: Israel
|
|
|
|
Well Bill,
Like Pandora-Box pointed, we still miss some details...
How this READ is issued? (your point)
Into an PIC X(nn) Variable? then requires INSPECT, etc.
Haim Zeevi |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
haimzeevi, there has been nothing posted to date to indicate that the variable value is coming from a READ. If you have suggested a MOVE, then your comment could be constructive, but as it is you are merely introducing complexity (and potentially wrong results) into the process. The sample data posted includes a value with an actual decimal point, so your suggestion to do the MOVE could cause an S0C7 abend in the code. Furthermore, the TS has not indicated whether the data is fixed position or floating, nor how long the variable can be, so it is entirely possible that your suggestion could not be used at all - in which case some form of INSPECT or reference modification becomes the ONLY way to do what was requested. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
thala_ds -- your problem description is indeed confusing. As we are in COBOL part of the Forum - can the decimal be implied or the input is always follow the rules as you show? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Just curious . . .
What design criteria caused appearingly un-like data to be stored in the same field? |
|
Back to top |
|
|
haimzeevi
New User
Joined: 01 Mar 2010 Posts: 27 Location: Israel
|
|
|
|
Robert, you're right.
Anyway, using 'ÍF NUMERIC' followed by ÇOMPUTE var = FUNCTION NUMVAL(original value)' prevents 0C7 and may answer the question (if I understood it...)
Haim Zeevi |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You'd need IF NUMERIC on the stuff to the left of the "." and the stuff to the right.
For me, better just to redefine it and put the number back together with an implied decimal. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
if it was a banking application dealing only with integer amounts
it would be nice to stuff away the <cents> an siphon them to a Cayman Island numbered account |
|
Back to top |
|
|
|