Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Casting a Binary Number to Numeric in Natural/ADABAS, or...

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Java & MQSeries
View previous topic :: :: View next topic  
Author Message
Bob Steinkraus

New User


Joined: 09 Aug 2016
Posts: 3
Location: USA

PostPosted: Tue Aug 09, 2016 5:58 pm    Post subject: Casting a Binary Number to Numeric in Natural/ADABAS, or...
Reply with quote

Good morning (where I am) -

I am a Natural/ADABAS developer. My task is to generate a 4-digit random number to use in a superdescriptor (along with other fields). So -

  • First off, is there any way to generate a random number in Natural? I don't have access to the SYSEXP library, and I looked at the SAG website and didn't find anything.
  • So I decided to try to generate my own random number. My thought was to use the *TIMESTMP system variable, and try to get the random number from there.

The *TIMESTMP is a binary 8 field. I have puzzled and puzzled, using edit masks and redefines and Heaven only knows what else. I can get the *TIMESTMP to display as Hex by Redefining the B8 as N8 and using (EM=HHHHHHHH) but that doesn't get me any further. I tried using VAL to get the numeric value, but that didn't work either.

Does anyone know of a clever and/or elegant way to convert the B8 to an N8 (or probably, a larger field) so I can pick out the most random part? I am not allowed to write any COBOL or Assembler user exits or anything like that.

Any advice gratefully accepted.

Regards,
Bob Steinkraus
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8119
Location: East Dubuque, Illinois, USA

PostPosted: Tue Aug 09, 2016 6:06 pm    Post subject:
Reply with quote

Google found me http://tech.forums.softwareag.com/techjforum/posts/list/7312.page which looks like it'll help you.
Back to top
View user's profile Send private message
Bob Steinkraus

New User


Joined: 09 Aug 2016
Posts: 3
Location: USA

PostPosted: Tue Aug 09, 2016 6:59 pm    Post subject:
Reply with quote

Thanks, I will look at the code samples.

I am running on the mainframe, if that matters.

Regards,
Bob Steinkraus
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1737
Location: NY,USA

PostPosted: Tue Aug 09, 2016 11:33 pm    Post subject:
Reply with quote

Does ADABAS have any function to get RANDOM value generated like DB2? or you can see if the sequence number can be generated that is also unique instead of writing algorithm freshly.
Back to top
View user's profile Send private message
Bob Steinkraus

New User


Joined: 09 Aug 2016
Posts: 3
Location: USA

PostPosted: Wed Aug 10, 2016 12:52 am    Post subject: Reply to: Casting a Binary Number to Numeric in Natural/ADABAS, or...
Reply with quote

In theory, there is a RAND function, but I can't find how to work it on the mainframe.

Regards,
Bob Steinkraus
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1771
Location: Bloomington, IL

PostPosted: Wed Aug 10, 2016 1:06 am    Post subject:
Reply with quote

If Ralph zbrog drops by, it might be worth calling his attention to this thread.
Back to top
View user's profile Send private message
Ralph Zbrog

New User


Joined: 21 Nov 2009
Posts: 58
Location: California

PostPosted: Thu Aug 11, 2016 1:59 am    Post subject: Reply to: Casting a Binary Number to Numeric in Natural/ADABAS, or...
Reply with quote

Quote:
is there any way to generate a random number in Natural
There is no built-in function, but sample Natural code has been posted/discussed on the SAG-L listserv, so do some research there. Years ago Jim Wisdom had an excellent routine on his Natural Conference website, but that's gone now, and I couldn't find other sites that used to have it cross-posted.

The RAND function is not part of Natural, but is available from SAG's Code Samples site: techcommunity.softwareag.com/ecosystem/communities/public/adanat/products/natural/codesamples.
Quote:
get the *TIMESTMP to display as Hex
DISPLAY, WRITE, and PRINT all format *TIMESTMP as hex because it is defined as Binary. There is no need for you to REDEFINE, etc.
Quote:
I don't have access to the SYSEXP library
All developers should have access to SYSEXT in a Development environment, but some Natural administrators fear that could result in the end of the world. icon_wink.gif Once you have experience with the functions there, you can make a case for having a specific module made available in UAT & Production.

If your NatAdmin is stubborn, get a copy of Natural Community Edition and install it on Windows. Many of the API modules (i.e. SYSEXT) are common to mainframe. It's a great way to learn the API with no negative impact on the mainframe environment.
Quote:
Does anyone know of a clever and/or elegant way to convert the B8 to an N8
There are several modules in SYSEXT which deal with converstion from/to the various time formats, including *TIMESTMP.
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 -> Java & MQSeries All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Reg:Displaying the particular month o... bhavana yalavarthi All Other Mainframe Topics 4 Sat Jul 08, 2017 8:13 pm
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts Edit large number of datasets (QSAM) zh_lad TSO/ISPF 3 Tue Apr 04, 2017 6:08 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us