MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Changing data-names dynamically in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
KOUSIK
Beginner


Joined: 04 Jan 2005
Posts: 26
Topics: 13

PostPosted: Tue Aug 14, 2007 8:24 pm    Post subject: Changing data-names dynamically in COBOL Reply with quote

Hi all,

I tried searching through the forum and in many other forums too on how to dynamically change a data-name in COBOL.

I have a set of instructions to be executed in COBOL and the only difference is change in data-names. A sample is below. I want to change the name IP**-TABLE-LINKAGE dynamically so that I can avoid all the redundant instructions below and make them into a single statement. Or in other words, I have to replace the 3 and 4th character of the IP**-TABLE-LINKAGE variable somehow dynamically.

IF MODULE-NM = PATAP08
MOVE IP08-TABLE-LINKAGE TO TABLE-LINKAGE
END-IF

IF MODULE-NM = PATAP10
MOVE IP10-TABLE-LINKAGE TO TABLE-LINKAGE
END-IF

IF MODULE-NM = PATAP11
MOVE IP11-TABLE-LINKAGE TO TABLE-LINKAGE
END-IF

Any suggestion on this would be greatly appreciated. Thank you very much. I learn a lot through this forum.

Kousik
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Aug 14, 2007 10:52 pm    Post subject: Reply with quote

You can't change a reference name dynamically.

using table and pointer techniques you can simplify your code. Give us an idea of what IPxx-TABLE-LINKAGE and TABLE-LINKAGE consist: i.e. PIC clause; the context of how and why they are being used. Also, a count of the number of module names involved.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
KOUSIK
Beginner


Joined: 04 Jan 2005
Posts: 26
Topics: 13

PostPosted: Tue Aug 14, 2007 11:16 pm    Post subject: Reply with quote

Thank you so much for your response and advise Dick!

Here is a more detailed explanation on what I am trying to do. I am attaching a piece of the code for a better picture. IPXX-TABLE-LINKAGE is a group item and it represents a DB2 table. All the elementary items under this group would a column in the table. TABLE-LINKAGE is just X(700). We populate the IPxx-TABLE-LINKAGE and then move this IPXX-TABLE-LINKAGE to TABLE-LINKAGE, Call the table I/O module as

MOVE 'PATAP08' TO AB06-MODULE-NM ( PATAP08 represents a DB2 table )
MOVE 'R' TO AB06-ACTION-IND ( 'R' refers to read the table )
MOVE IP08-TABLE-LINKAGE TO TABLE-LINKAGE

CALL AB06-MODULE-NM
USING TABLE-LINKAGE

IF RETURN-SQLCODE = +0

MOVE TABLE-LINKAGE TO IP08-TABLE-LINKAGE

END-IF

So, now the module would have read the row I wanted from the table and returned it back to me and I can go use the table data in a program.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Aug 15, 2007 12:06 am    Post subject: Reply with quote

each IPXX-TABLE-LINKAGE group is defined the same way?
Are you using dynamic sql?
give me an idea of what IP06-TABLE-LINKAGE and IP08-TABLE-LINKAGE looks like.
you have a unique db2 module for each db2 table?

at this point I have to make too many assumptions about what you are doing.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Wed Aug 15, 2007 8:46 am    Post subject: Reply with quote

I'm just wondering why you need the moves to/from TABLE-LINKAGE in the first place. Why not just call the module referencing the data area? Instead of

MOVE IP08-TABLE-LINKAGE TO TABLE-LINKAGE
CALL AB06-MODULE-NM USING TABLE-LINKAGE
MOVE TABLE-LINKAGE TO IP08-TABLE-LINKAGE

why not

CALL AB06-MODULE-NM USING IP08-TABLE-LINKAGE ?
Back to top
View user's profile Send private message
KOUSIK
Beginner


Joined: 04 Jan 2005
Posts: 26
Topics: 13

PostPosted: Sun Aug 19, 2007 12:09 am    Post subject: Reply with quote

Sharon,

This is the standard we follow normally. It could be done as you said but as of now it is considered a bad practice. We have to follow the standards. This logic is kind of universal, people don't accept changes suddenly.

Dick,

Thanks a lot and appreciate your response. I coded the logic a little bit different but structured though I couldn't do what I initially thought.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group