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

NUMVAL information required


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

New User


Joined: 03 Oct 2006
Posts: 40

PostPosted: Wed Jun 16, 2010 4:34 pm
Reply with quote

Hi all,

I am facing some issue with NUMVAL function. We are working on stored procedures which is passed pipe delimited string.

The input string for this stored procedure is, input0|input1|input2|input3|input4

Also input2 is optional that is, the value of input2 may or may not be available. So the input may also be like input0|input1||input3|input4

I am doing an unstring in my stored procedure and then using to calculate

COMPUTE INPUT2-NUM = FUNCTION NUMVAL (INPUT2)

This INPUT2-NUM is used in where clause in my sql query.

When I am putting any value for input2 in input string, it is working fine. When I am not providing anything for input2 (second format for input string), calling for my stored procedure is getting failed and we are having SQL -430 and sqlstate 38503.

Even I tried with having one spaces for input2, I was getting abends. In other words, I used this input string.

input0|input1| |input3|input4

I need your help in this regard. Please let me know if additional information is required.

-Sharad
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 Jun 16, 2010 5:31 pm
Reply with quote

I'm not very sure - what might have casused the probelm. Just for hit-n-trial - please try to use NUMVAL-C instead of NUMVAL.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Jun 16, 2010 5:33 pm
Reply with quote

FUNCTION NUMVAL causes an abend if the data is not numeric.
You have to validate the data before:
Code:
IF (input2 is valid) THEN
    COMPUTE INPUT2-NUM = FUNCTION NUMVAL (INPUT2)
ELSE
    MOVE 0 TO INPUT2-NUM
END-IF
Number validation will be different if you have a sign (+ or -) and if you have a decimal point.
Because there will certainly be some spaces in the field, if would recommend defining a CLASS.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Jun 16, 2010 5:39 pm
Reply with quote

After reading again.... maybe this will be enough:
Code:
IF INPUT2 = SPACES THEN
    MOVE 0 TO INPUT2-NUM
ELSE
    COMPUTE INPUT2-NUM = FUNCTION NUMVAL (INPUT2)
END-IF
Back to top
View user's profile Send private message
sharad_shanu

New User


Joined: 03 Oct 2006
Posts: 40

PostPosted: Wed Jun 16, 2010 6:28 pm
Reply with quote

Just one question, why it is affecting at the time of calling of stored procedure?
It should fail while processing the input data but why to fail in call itself.
Back to top
View user's profile Send private message
sharad_shanu

New User


Joined: 03 Oct 2006
Posts: 40

PostPosted: Wed Jun 16, 2010 7:44 pm
Reply with quote

I modified code as per your suggestion and it is working fine. icon_lol.gif
I thought if there is a space in input, NUMVAL should give 0 as output but I was wrong.

Anyways, Thanks to all for your help.

Regards,
Sharad
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 Capturing Job Execution Information All Other Mainframe Topics 3
No new posts Extract all the TWS scheduler informa... IBM Tools 1
No new posts Table Information - DB2 DB2 1
No new posts FUNCTION NUMVAL problem COBOL Programming 6
No new posts Remove additional information in SUPE... TSO/ISPF 10
Search our Forums:

Back to Top