× 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.



This change will be the one with the smallest impact:

If FLIf FLDX = 99 then
//  If subst(FLDX:1:1) = A
NewCTRLNum = %xlate('9ABC...': 'ABCD...': subst(FLDX:1:1)) + '01'
//    NewCTRLNum = CHAR(subst(FLDX:1:1)+1) + '01'
//  Endif;
Endif;


In the "xlate" you need the whole alphabeth, you can even skip letters if you want (O looks very much like 0) Also, remeber to exit when you reach X99, unless you want to use lowercase and special characters.

Brian Piotrowski wrote:

Hi Marco,

This problem stems from some legacy code we have at our facilities.  The
original programmers did not leave enough room for an acceptable amount
of characters in the field.

The field is defined as 3A.  This field is part of a control number that
is used in a multitude of programs (that will eventually need to be
rewritten at a future date).  Unfortunately, we have occasions where the
control number exceeds 999.  When this occurs, the system has been
written to flip the first digit to an alpha character.  Thus when the
999 threshold is exceeded, the new control number becomes A01.  Further
to that, when A99 is the last control number and a new record is
created, the next control number becomes B01.
And so on...C01, D01, ad nauseum.

So what we're looking at is something that will detect when x99 is
reached and flip to the next alpha character in sequence.

So based on this, we'd be looking for some code similar to this:

If FLDX = 99 then
 If subst(FLDX:1:1) = A
   NewCTRLNum = CHAR(subst(FLDX:1:1)+1) + '01'
 Endif;
Endif;

The question is - is there an equivalent to CHAR() in RPG?  Essentially
we'd need to find the hex or decimal value of the next available
character.  For example, if A = char(1) and B = char(2), when we did a
Char(1+1), we'd get B as the next character.

I hope this response hasn't confused or made the process sound more
complicated than it is.

Brian.


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.