× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks John - this concept worked great and was simple to understand and read. Very nice and much appreciated!


Here it is in COBOL - seems to work well:


WORKING-STORAGE SECTION.
77 i pic S99.
77 B4 VALUE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' PIC X(36).
77 AF VALUE '1234567890BCDEFGHIJKLMNOPQRSTUVWXYZ0' PIC X(36).


Find-next-alpha-value.
* start at the rightmost digit and proceed towards the left

perform varying i from 4 by -1 until i < 1

* step single character to next value in array, for example
* change "X" to "Y", or change "3" to "4"
INSPECT P-ID (i) CONVERTING B4 TO AF

* if an overflow condition occurred (ie 1239 overflowed to 123A)
* then loop around and do same process one char to left
if P-ID (i) = 'A'
continue
else
* done, exit program
move 0 to i
end-if

end-perform .



-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of John Yeung
Sent: Friday, December 04, 2015 5:23 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: How to find next number for an alphanum field? Any good and simple tricks?

On Fri, Dec 4, 2015 at 5:38 PM, Stone, Joel <Joel.Stone@xxxxxxxxxx> wrote:
I have a length 4 alphanum field which I need to find the next value (incremented by one value).

To be precise, you need to say what all the possible values are for a
given byte. (For example, maybe you can use any of the 256 binary
values. Or maybe you can use anything printable. Or maybe just upper-
and lowercase characters, plus digits.) Your examples suggest that you
are working with uppercase letters and the ten decimal digits, for a
total of 36 possible values.

And my shop would like it done in COBOL, but any algorithm will suffice.

Maybe use a base 36 table???

You certainly could. Your problem is essentially the same as one
raised in this mailing list in June 2015 by Gad Miron. The thread
starts here:

http://archive.midrange.com/midrange-l/201506/msg00533.html

You could also search for "The case of outnumbered numerator". Gad
eventually wound up adapting the code provided by Sam L later in that
thread:

http://archive.midrange.com/midrange-l/201506/msg00584.html

John Y.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.