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

Conversion from char to decimal and validation of Decimal no


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 691
Location: Earth

PostPosted: Tue Sep 18, 2007 2:03 pm
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
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
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
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: 691
Location: Earth

PostPosted: Thu Sep 20, 2007 8:50 am
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
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: 2146
Location: At my coffee table

PostPosted: Mon Sep 24, 2007 7:55 pm
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 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 SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
Search our Forums:

Back to Top