View previous topic :: View next topic
|
Author |
Message |
geekhead83
New User
Joined: 14 May 2007 Posts: 10 Location: india
|
|
|
|
Hi,
I searched around a bit, and didnt find much on this topic, hence posting this as my first post.
I need a way for my program to create an already present variable on the fly and store its value to the database. i.e. :
-> read a value which is the partial variable name from the database
-> append a common qualifier to this variable and create a variable which is already present and has a value in it
-> store the value of this dynamically formed (but already) present variable in the databse.
If it sounds confusing, here's an example :
WS-101-ABC is the source variable having the value 1234.
The program:
1) reads ABC from the database
2) appends WS-101- to ABC forming WS-101-ABC (say using a group variable)
3) Stores the value of WS-101-ABC i.e. 1234 to the database.
Now how to get the program to do point # 2 and 3? because the program treats WS-101-ABC as a string and not a variable?
Hope I'm clear about this.
Thanks. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
Suggest you consider replacing this "dynamic variable" with an array to accomplish what you want to do.
If an array will not handle what you want, then you may need to create a table that has the rules of what may be dynamically built.
It may be that i do not completely understand what you want to do. It may help if you post more situations and what should happen in the code when these sutiations occur. |
|
Back to top |
|
|
geekhead83
New User
Joined: 14 May 2007 Posts: 10 Location: india
|
|
|
|
hi,
thanks for your response.
I basically want my program to read in a text value and treat it as a variable.
taking my original example again:
the program would read ABC from the database, and it should understand that WS-ABC is the variable name whose value is to be stored back in the database.
One way is to create a copybook which would explicitly define what variable corresponds to what text, as in
Code: |
IF DB-VALUE = 'ABC'
MOVE WS-ABC to DB
|
But was looking for a simpler solution without having to go into arrays.
Thanks again for responding. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you make one or several copybooks, anything dynamic will not be an option. The code would be compiled at whatever "level" the copybook was was and would only need changes as the underlying table(s) were modified.
This would have the advantage of being quite a bit easier to understand/maintain. . . FWIW. |
|
Back to top |
|
|
geekhead83
New User
Joined: 14 May 2007 Posts: 10 Location: india
|
|
|
|
thats an amazing response time youve got!
Discussed it further and would be going ahead with a copybook, since it would be easier to maintain as well.
Thanks for responding! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome
I'm not usually that quick - just happened to refresh and there you were
Good luck.
d |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
taking my original example again:
the program would read ABC from the database, and it should understand that WS-ABC is the variable name whose value is to be stored back in the database. |
You are confusing compile-time (which is when program variable are defined and set in stone) with run-time (which is when the program executes and can read databases). You need to understand why reading data from a database precludes you from using that data as source to your program. |
|
Back to top |
|
|
geekhead83
New User
Joined: 14 May 2007 Posts: 10 Location: india
|
|
|
|
yeah. but since that was a requirement, was searching for alternate solutions. anyways, thanks! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Other than creating a program that writes another program for output, I don't think you can do what you want. I've done similar things in SAS but it always has to be a two-step process: one step to create the program, one step to run the created program. |
|
Back to top |
|
|
|