View previous topic :: View next topic
|
Author |
Message |
pravinjanawork
New User
Joined: 30 Sep 2008 Posts: 2 Location: Chennai
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
pravinjanawork
New User
Joined: 30 Sep 2008 Posts: 2 Location: Chennai
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|