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: 7995
Location: Bellevue, IA

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: 7995
Location: Bellevue, IA

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 Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


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