Incrementing an alphanumberic variable in cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Incrementing an alphanumberic variable in cobol

Postby prasadrocks » Sun Oct 17, 2010 11:30 am

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.
prasadrocks
 
Posts: 2
Joined: Sun Oct 17, 2010 10:50 am
Has thanked: 0 time
Been thanked: 0 time

Re: Incrementing an alphanumberic variable in cobol

 

Re: Incrementing an alphanumberic variable in cobol

Postby dick scherrer » Sun Oct 17, 2010 11:46 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Incrementing an alphanumberic variable in cobol

Postby prasadrocks » Sun Oct 17, 2010 12:01 pm

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.
prasadrocks
 
Posts: 2
Joined: Sun Oct 17, 2010 10:50 am
Has thanked: 0 time
Been thanked: 0 time

Re: Incrementing an alphanumberic variable in cobol

Postby dick scherrer » Sun Oct 17, 2010 12:13 pm

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Incrementing an alphanumberic variable in cobol

Postby enrico-sorichetti » Sun Oct 17, 2010 12:28 pm

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!
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Incrementing an alphanumberic variable in cobol

Postby dick scherrer » Sun Oct 17, 2010 9:31 pm

Hi Enrico,

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

d
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Incrementing an alphanumberic variable in cobol

Postby Ferrari2010 » Tue Oct 19, 2010 11:38 pm

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.
Ferrari2010
 
Posts: 6
Joined: Fri Oct 08, 2010 8:31 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post