IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Alphanumeric sequence number


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pravinjanawork

New User


Joined: 30 Sep 2008
Posts: 2
Location: Chennai

PostPosted: Tue Feb 26, 2013 9:13 pm
Reply with quote

i have the same scenario which needs to done through the cobol program.

For example: A99999 reached Program need to switch to B00001.
Numeric part I have handled through DB2 Sequence object. Only thing is when the sequence reset to 00001 I need a function or logic which will change the A to B.

I;e I know when to change A to B, but only thing is how can I code to change A to B.

If there is any way to do this please suggest. If no way then I need to hard code the values in WS variables and once sequence reaches the limit then I will change to B.

Thanks
Pravin
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Feb 26, 2013 9:26 pm
Reply with quote

Please don't tailgate an old topic, but post a new one. If you feel it helps, include a link to the topic which you feel is helpful.

Why does A99999 go to B00001? What happened to B00000?

Why are you using DB2?

There are many ways to do what you want. Can you not think of anything? How about a table with 26 entries containing the letters of the alphabet. You start with the first entry. When you get to 99999 you "roll" to 00000 (or 00001) and use the "next" entry from the table. Continue ad not-quite-infinitum-but-until-you've-done-it-all.
Back to top
View user's profile Send private message
pravinjanawork

New User


Joined: 30 Sep 2008
Posts: 2
Location: Chennai

PostPosted: Wed Feb 27, 2013 12:10 am
Reply with quote

Bill - Thanks for your suggestion. I would take care in future and will not tail gate in old topic. I posted my query to this topic since the topic was almost related to my problem.

I have not yet concluded language to write the code for this requirement. Based on the available functionality I may write either in COBOL store procedure or through Native SQL store procedure.

So i was thinking about the Sequence object. Yes, I thought different ways but all of them require some hard coding inside the program.

For example if we have 26 alphabets in a table after reaching A99999 then I need to correctly start with B, for this I need to hard code.

So i was looking for any Built in function in COBOL which can increment A to B based on our call.

Thanks for your suggestion
Pravin
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 27, 2013 4:10 pm
Reply with quote

I don't think you understood the example I gave.

ABCDEFGHIJKLMNOPQRSTUVWXYZ

The first letter in the table is the one you use first.

Once you've finished with a letter and it is the last in the table, you have a problem, deal with it.

Once you've finished with a letter, you use the letter after that one.

Yes, you have to "hard code" the alphabet, but now you can just paste from here (checking I've got it right, of course). Makes it "easy code".

Cobol is not a language replete with "functions". They are all listed in the language reference.

Why you'd expect a function to exist for such a simple task, I don't know.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Feb 27, 2013 5:26 pm
Reply with quote

Quote:
So i was looking for any Built in function in COBOL which can increment A to B based on our call.
You can stop looking because such a function does not exist. YOU will have to do some work to implement a solution to your issue.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Feb 27, 2013 8:11 pm
Reply with quote

Hello and welcome to the forum,

What has been done for many years is to create a callable subroutine that performs this "function".
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top