IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Check whether the given value is DECIMAL or not


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Fri Oct 05, 2012 4:50 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Oct 05, 2012 4:56 pm
Reply with quote

If it is decimal it is numeric - I do not know of any decimal letters.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Oct 05, 2012 5:18 pm
Reply with quote

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
View user's profile Send private message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Fri Oct 05, 2012 5:43 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Oct 05, 2012 5:49 pm
Reply with quote

Sounds to be a very strange requirement to me atleast icon_eek.gif

or you are missing to share some key details
Back to top
View user's profile Send private message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Fri Oct 05, 2012 5:52 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Oct 05, 2012 5:53 pm
Reply with quote

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
View user's profile Send private message
haimzeevi

New User


Joined: 01 Mar 2010
Posts: 27
Location: Israel

PostPosted: Mon Oct 15, 2012 5:06 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Oct 15, 2012 5:34 pm
Reply with quote

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
View user's profile Send private message
haimzeevi

New User


Joined: 01 Mar 2010
Posts: 27
Location: Israel

PostPosted: Mon Oct 15, 2012 5:58 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Oct 15, 2012 6:26 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Oct 17, 2012 7:12 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Oct 17, 2012 9:28 pm
Reply with quote

Hello,

Just curious . . .

What design criteria caused appearingly un-like data to be stored in the same field?
Back to top
View user's profile Send private message
haimzeevi

New User


Joined: 01 Mar 2010
Posts: 27
Location: Israel

PostPosted: Wed Oct 17, 2012 10:38 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Oct 17, 2012 10:46 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 17, 2012 11:10 pm
Reply with quote

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 icon_cool.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts How to check whether who renamed the ... JCL & VSAM 3
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
Search our Forums:

Back to Top