Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamic Variable during execution

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Dynamic Variable during execution
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

Site Director


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

PostPosted: Mon Nov 03, 2008 12:01 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Nov 04, 2008 4:12 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Nov 04, 2008 5:25 am    Post subject: Reply to: Dynamic Variable during execution
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: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Tue Nov 04, 2008 5:49 am    Post subject:
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    Post subject:
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: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Wed Nov 05, 2008 8:54 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us