Page 1 of 1

Incrementing an alphanumberic variable in cobol

PostPosted: Sun Oct 17, 2010 11:30 am
by prasadrocks
Hi,

I want to write a new logic for incrementing the working storage variable once it reaches the value Z99. Currently the value is X(3) and it increments from 000 to 999... then from A00 to A99... till Z00 to Z99. I want to write a new logic to increment this variable from AA0 once it reaches Z99.

AA0
AA1
.
.
AA9

AB0
AB1
.
.
AB9

.
.
.
AZ9

Once it reaches AZ9, the increments should be done for all the digits till it reaches ZZ9.

Can anyone know how to write a code for performing this logic in cobol???

Thanks in advance.

Re: Incrementing an alphanumberic variable in cobol

PostPosted: Sun Oct 17, 2010 11:46 am
by dick scherrer
Hello and welcome to the forum,

Is this a homework assignment or some business requirement? If this is a business requirement, how will this incremented value be used?

You do realize that on the mainframe numbers are higher in the collating sequence than alphabetics?

You may not realize this yet, but there is more to your goal than the very limited sample "output" posted.

Re: Incrementing an alphanumberic variable in cobol

PostPosted: Sun Oct 17, 2010 12:01 pm
by prasadrocks
Hi Dick,

This is a business requirement, whenever a new provider adds under a hospital, this value needs to be incremented in the order which i have posted. Now the maximum limit of Z99 has been reached and the job is running into the loop. So i need to write a new logic for incrementing this further.

hope this information helps. How to proceed with a new logic for this business requirement??

Thank you.


Regards,
Prasad.

Re: Incrementing an alphanumberic variable in cobol

PostPosted: Sun Oct 17, 2010 12:13 pm
by dick scherrer
Hello,

In order to do just what you want, the complete "answer" needs to be known. You may know what the complete answer is, but this has not yet been posted. I believe that you want to do will have issues because the generated values will not follow a managable sequence (i.e. which values will be higher or lower than others.

What about the values that already exist? What you say you want to do will cause existing entries to be "out of sequence".

Suggest you consider either increasing the size of the field or keep this size and make the field a packed-decimal or binary field.

Re: Incrementing an alphanumberic variable in cobol

PostPosted: Sun Oct 17, 2010 12:28 pm
by enrico-sorichetti
all You have to do is to think in base 36 ( 26 alphabets + 10 numbers )
the back and forth conversion is easy if You remember the math?
You will only be troubled by the ebcdic collating sequence!

Re: Incrementing an alphanumberic variable in cobol

PostPosted: Sun Oct 17, 2010 9:31 pm
by dick scherrer
Hi Enrico,

Yup, i believe generating the numbers will be much easier than actually using them in an application. . . ;)

d

Re: Incrementing an alphanumberic variable in cobol

PostPosted: Tue Oct 19, 2010 11:38 pm
by Ferrari2010
Hi Prasad,

What is the existing logic to increment? how it's incremented from 999 to A00 and forth?
Why can't you use the same logic?

Thanks.