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

How to use NUMVAL in COBOL


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

New User


Joined: 28 Jul 2005
Posts: 7
Location: india

PostPosted: Tue Aug 09, 2005 4:37 pm
Reply with quote

Hi,

I have faced the below problem. Below is the description. If You have a solution pls reply asap.

Prob:
I have a PS containing the data as
Rec1: abc,-125.69,cde
rec2: pqr,123.45,mnb etc...

I used unstring function to get the data for different fields.
So,For the 1st rec, my fld2 value is -125.69.
I want to perform numeric operations on that. Is it possible??
If so how??
Back to top
View user's profile Send private message
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Tue Aug 09, 2005 4:45 pm
Reply with quote

Move your 2nd filed to new numeric WS varaible using 'FUNCTION NUMVAL'

New WS var = FUNCTION NUMVAL (OLD alpha numVAR)
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Aug 09, 2005 4:45 pm
Reply with quote

Hi sghosh_sl,

Quote:
I want to perform numeric operations on that. Is it possible??


I think it is ....If the fields are defined as NUMERIC....

What problem you are facing exactly....

Regards,

Priyesh.
Back to top
View user's profile Send private message
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Tue Aug 09, 2005 4:48 pm
Reply with quote

I have assumed that the field -125.69 is an Alpha numeric variable... based on that i gave suggestion.

But please answer Priyesh's Qs. so that we could be clear.
Back to top
View user's profile Send private message
Hari Kumar

New User


Joined: 28 Jul 2005
Posts: 19

PostPosted: Tue Aug 09, 2005 5:50 pm
Reply with quote

Hi,

first move Editing Pic Value to Numeric Value then Perform Numeric Operations

For ur Case

Code:
Move EF2 TO NF2



EF2 is [-125.69] Editing Pic Value. Corresponding Pic Class is PIC -9(3).9(2).
NF2 is Normal Pic Value. Corresponding Pic Class S9(3)V9(2).

Correct Me If I Am Wrong
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Aug 10, 2005 7:26 am
Reply with quote

Hi Suman,

I think Shiva was close. Try:

COMPUTE WS-NUM-VAR = FUNCTION NUMVAL (WS-OLD-ALPHA-NUM-VAR)

You might also experiment w/this:

Assuming WS-OLD-ALPHA-NUM-VAR is your "string to" var.

05 WS-OLD-ALPHA-NUM-VAR PIC X(???).
05 WS-NUM-VAR REDEFINES
WS-OLD-ALPHA-NUM-VAR PIC S9(???).

Then do the COMPUTE. I know the fields overlap, but the compiler may use a temp field to do its magic. In that case you wind up converting the field "in place".

Worth a shot.
Back to top
View user's profile Send private message
sghosh_sl

New User


Joined: 28 Jul 2005
Posts: 7
Location: india

PostPosted: Sat Feb 25, 2006 3:00 pm
Reply with quote

Can any bode let me know the reason ?
Below is the problem.
---------------------------
I have a cobol submodule and it is called from A PL1 program. The inter program communication is done thru Linkage section variables.
The main PL1 module sends data to Cobol program and the cobol program returns back data to the PL1 program. In the cobol program, a table is queried. If inkage section variables are used as the host variables, SQLcode 100 is returned. But SQL 0 is returned if working storage section variables are used.

I used Xpediter to check the values of working storage variables and linkage section variables. I didnot find any diffrence form the Xpediter display.

I dont know why the same query returns to different SQL codes ?
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top