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
 
Error in Rand function

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

New User


Joined: 22 Apr 2008
Posts: 5
Location: Chennai

PostPosted: Tue Mar 03, 2009 2:54 pm    Post subject: Error in Rand function
Reply with quote

Hi,

I am using the following piece of code in my program.I am getting undefined or unusable host variable.Can someone tell me what is the error in the code.

03 W070-RANDOM-NUMBER1 PIC 9(1)V VALUE ZEROES

EXEC SQL
SELECT DECIMAL(RAND() * 10)
INTO :W070-RANDOM-NUMBER1
FROM SYSIBM.SYSDUMMY1
END-EXEC

DSNH312I E DSNHSMUD LINE 1314 COL 20 UNDEFINED OR UNUSABLE HOST VARIABLE
"W070-RANDOM-NUMBER1"

Thanks
Jeba David
Back to top
View user's profile Send private message

ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Mar 03, 2009 3:26 pm    Post subject:
Reply with quote

The result of the RAND function is a double precision floating-point number... ... try changing the PIC clause to accomodate floating point
Back to top
View user's profile Send private message
dsarlie
Currently Banned

New User


Joined: 22 Apr 2008
Posts: 5
Location: Chennai

PostPosted: Tue Mar 03, 2009 3:55 pm    Post subject: Reply to: Error in Rand function
Reply with quote

I checked with the picture clause matching.It is not getting matched.I hope this error may be because of attribute mistach.I dont know the exact length of the output for this query.
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Tue Mar 03, 2009 4:35 pm    Post subject: Reply to: Error in Rand function
Reply with quote

Quote:
03 W070-RANDOM-NUMBER1 PIC 9(1)V VALUE ZEROES
...not sure if it will work..Try defining the variable as USAGE COMP-2.
WTF
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Tue Mar 03, 2009 4:55 pm    Post subject: Reply to: Error in Rand function
Reply with quote

Sorry ..missed out on the DECIMAL part of the query ...
PIC S9(9)V9(2) USAGE COMP-3. should work.
Hope this helps.
WTF
Back to top
View user's profile Send private message
dsarlie
Currently Banned

New User


Joined: 22 Apr 2008
Posts: 5
Location: Chennai

PostPosted: Wed Mar 04, 2009 10:24 am    Post subject: Re: Reply to: Error in Rand function
Reply with quote

Hi,

Thanks.Comp-2 works now.Comp-3 gives the same error.While I am getting the data from the table it is Floating point precision.

For eg:

(blank.20000000000000000E 01 ) this is the output I get from the table.I need only the number 2.

03 ws-num1 usage comp-2
03 ws-num2 redefines ws-num1
05 filler pic x(02)
05 ws-num3 pic 9(1)
05 filler pic 9(17).

This is how I have declared the variables.

in my ouput ws-num3 has blank space and it is not displaying anything.Is there any error over here.How should I get the value 2.
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed Mar 04, 2009 12:46 pm    Post subject: Reply to: Error in Rand function
Reply with quote

Jeba,
Lets work on your original request.
I tried the following code ...and it worked for me.
Code:
WORKING STORAGE.
 01 RAN PIC S9(1) USAGE COMP-3.       
 01 RAN-DISP  PIC S9(1) VALUE ZEROES. 
PROCEDURE DIVISION.
 EXEC SQL                           
 SELECT DECIMAL(RAND() * 10)         
 INTO :RAN                           
 FROM SYSIBM.SYSDUMMY1               
 END-EXEC
                           
 MOVE RAN TO RAN-DISP                 
 DISPLAY 'OUTPUT:'RAN                 
 DISPLAY 'OUTPUT DISPLAY :'RAN-DISP
 

Spool Output
OUTPUT:7
OUTPUT DISPLAY :G
I believe this should work for you as well, do let us know otherwise.
WTF
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts FUSE - IBM MQ - CICS integration error Kevin Vaz CICS 1 Mon Sep 18, 2017 4:31 pm
No new posts Reply MQ open error Vignesh Sid COBOL Programming 6 Thu Sep 07, 2017 6:02 pm

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