Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Conversion from char to decimal and validation of Decimal no

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sudhee_rb

New User


Joined: 29 Mar 2006
Posts: 34

PostPosted: Tue Sep 18, 2007 1:21 pm    Post subject: Conversion from char to decimal and validation of Decimal no
Reply with quote

In my program one of variable definition I need to from 3 byte char to 3 byte decimal.

I changed x(3) to 9(3)v.

Is this is correct, how can I validate this decimal no.

If num_office is numeric

-------------
else

do something.
----

Sudheer
Back to top
View user's profile Send private message

kgumraj2

New User


Joined: 01 Aug 2007
Posts: 42
Location: Hyderabad

PostPosted: Tue Sep 18, 2007 1:58 pm    Post subject:
Reply with quote

Hi,

you are partially correct, but what you what to check do in ----- ?
is it only nuemric check or any other things related, do let us know, thanks
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Tue Sep 18, 2007 2:03 pm    Post subject:
Reply with quote

Quote:
i changed x(3) to 9(3)v.

why 9(03)v here?
If there is a possiibility of getting non numeric char in your x(03) var, then simple move may give you incorrect results.
Try using function NUMVAL.
Back to top
View user's profile Send private message
sudhee_rb

New User


Joined: 29 Mar 2006
Posts: 34

PostPosted: Wed Sep 19, 2007 4:58 pm    Post subject:
Reply with quote

Hi kiran/Abhijit,

Thanks for clarification.

Actually wt happened is, I want to get that value from DB2Table,it is defined as DECIMAL(3,0)(earlier it was CHAR 3) .According to this i need to change in my DB2-COBOL program.

It was validated using this

If num_office is numeric

-------------
else

do something.
----

Shall i use same for validation.

Abhijit-
All values are numbers only(length also 3 digits only).
can u please explain more detail about the function NUMVAL .

Thanks in Advance.
Sudheer
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Sep 19, 2007 5:47 pm    Post subject:
Reply with quote

Code:
DECIMAL(3,0) IS EQUIVALENT TO PIC S9(3)V USAGE COMP-3.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Sep 19, 2007 5:53 pm    Post subject:
Reply with quote

Quote:
Actually wt happened is, I want to get that value from DB2Table,it is defined as DECIMAL(3,0)(earlier it was CHAR 3) .According to this i need to change in my DB2-COBOL program.


DECIMAL(X,Y) datatype columns not allowed any other values other than numeric. So i think no need to check for whether the value contains numeric or not, as you are going to retrieve the value from DB2 table for the DECIMAL(X,Y) datatype column which always contains the numeric values.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Thu Sep 20, 2007 8:50 am    Post subject:
Reply with quote

Quote:
Abhijit-
All values are numbers only(length also 3 digits only).
can u please explain more detail about the function NUMVAL .


Function numval details
Back to top
View user's profile Send private message
saptagiri kintali

New User


Joined: 21 Sep 2007
Posts: 20
Location: chennai

PostPosted: Mon Sep 24, 2007 6:34 pm    Post subject: Reply to: Conversion from char to decimal and validation of
Reply with quote

another thing when it is of 9(3) means , u cant check with IS NUMERIC ,it will lead to an error.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon Sep 24, 2007 7:55 pm    Post subject: Re: Reply to: Conversion from char to decimal and validation
Reply with quote

saptagiri kintali wrote:
another thing when it is of 9(3) means , u cant check with IS NUMERIC ,it will lead to an error.
Maybe in the olden days, but the Fine Manual now states that the dataname can/must be "DISPLAY, NATIONAL, COMPUTATIONAL-3, or PACKED-DECIMAL when NUMERIC is specified"....
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 Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us