Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Check whether the given value is DECIMAL or not

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Check whether the given value is DECIMAL or not
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: 1715
Location: UK

PostPosted: Fri Oct 05, 2012 4:56 pm    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Fri Oct 05, 2012 5:18 pm    Post subject:
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    Post subject: Reply to: To validate decimal values in COBOL
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

Moderator


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

PostPosted: Fri Oct 05, 2012 5:49 pm    Post subject:
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    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Fri Oct 05, 2012 5:53 pm    Post subject:
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    Post subject: Reply to: To validate decimal values in COBOL
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Mon Oct 15, 2012 5:34 pm    Post subject: Reply to: To validate decimal values in COBOL
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    Post subject: Reply to: To validate decimal values in COBOL
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: 7913
Location: Bellevue, IA

PostPosted: Mon Oct 15, 2012 6:26 pm    Post subject:
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

Senior Member


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

PostPosted: Wed Oct 17, 2012 7:12 pm    Post subject:
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

Site Director


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

PostPosted: Wed Oct 17, 2012 9:28 pm    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Wed Oct 17, 2012 10:46 pm    Post subject: Reply to: To validate decimal values in COBOL
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Oct 17, 2012 11:10 pm    Post subject: Reply to: To validate decimal values in COBOL
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us