On 16-Jun-2015 23:44 -0600, Gad Miron wrote:
We have a six digits numerator that approaches 899999.
Since it happens to be a CHAR field I would like to start using the
letters A-Z in lexical order when incrementing this field so that
incrementing 899999 will result in
9AAAAA , 9AAAAB , ......., 9AAAAZ, 9AAAA0, 9AAAA1 etc.
(This way the numerator will sort the EBCDIC natural way)
Of course /natural/ sort-order implies Sort Sequence (SRTSEQ) of
*HEX. Thus the data will not hold that collation if ever using a
/language/ or the natural ASCII ordering; these collate digits before
alpha. Something to consider if for example, the data might ever be
used in an alternate environment where /sorting/ is required, but that
environment defaults to something other than SRTSEQ(*HEX).
Do you know an *elegant* way of doing it ?
(EBCDIC table having "holes" of unprintable chars does not expedite
matters)
Not sure about /elegant/, but seems very straightforward; no
consideration for handling overflow for '999999':
d dd1 DS
d ca 1A dim(x0)
d ia 3U00 dim(x0) overlay(dd1:1)
d x0 C 6
d x5 C 2
for i=6 to 2 by -1 ;
if expchr(i)='9' ; // overflows to next exp
expchr(i)+='A' ;
else ;
select; // handle EBCDIC "holes" or just increment
when expchr(i)='Z' ;
expchr(i)='0';
when expchr(i)='R' ;
expchr(i)='S';
when expchr(i)='I' ;
expchr(i)='J' ;
otherwise ;
expint(i)+=1 ; // next char is consecutive
endsl ;
leave ; // done with increment by one char
endif ;
endfor ;
p.s. The above for-construct was not functional for me on v5r3
[though using the figurative constants x0 and x5], yet I presume is
coded correctly.? What I actually tested was a while-construct (DOW).
As an Amazon Associate we earn from qualifying purchases.
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.