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

Dynamic Variable during execution


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

New User


Joined: 14 May 2007
Posts: 10
Location: india

PostPosted: Mon Nov 03, 2008 11:31 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Nov 03, 2008 12:01 pm
Reply with quote

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
View user's profile Send private message
geekhead83

New User


Joined: 14 May 2007
Posts: 10
Location: india

PostPosted: Tue Nov 04, 2008 3:25 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Nov 04, 2008 4:12 am
Reply with quote

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
View user's profile Send private message
geekhead83

New User


Joined: 14 May 2007
Posts: 10
Location: india

PostPosted: Tue Nov 04, 2008 4:22 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Nov 04, 2008 5:25 am
Reply with quote

You're welcome icon_smile.gif

I'm not usually that quick - just happened to refresh and there you were icon_wink.gif

Good luck.

d
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: Tue Nov 04, 2008 5:49 am
Reply with quote

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
View user's profile Send private message
geekhead83

New User


Joined: 14 May 2007
Posts: 10
Location: india

PostPosted: Wed Nov 05, 2008 8:39 pm
Reply with quote

yeah. but since that was a requirement, was searching for alternate solutions. anyways, thanks!
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 Nov 05, 2008 8:54 pm
Reply with quote

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
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Capturing Job Execution Information All Other Mainframe Topics 3
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts JCL Dynamic System Symbols JCL & VSAM 3
Search our Forums:

Back to Top