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

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


IBM Mainframe Forums -> Java & MQSeries
Post new topic   Reply to topic
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
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: 8700
Location: Dubuque, Iowa, USA

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

Google found me 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
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Tue Aug 09, 2016 11:33 pm
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
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: 1787
Location: Bloomington, IL

PostPosted: Wed Aug 10, 2016 1:06 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Java & MQSeries

 


Similar Topics
Topic Forum Replies
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts Format Binary file to EBCDIC JCL & VSAM 4
No new posts Mainframe Dataset Binary or ASCII Mainframe Interview Questions 4
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
Search our Forums:

Back to Top