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

Assign a value to a group


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

New User


Joined: 14 Sep 2007
Posts: 3
Location: india

PostPosted: Fri Sep 14, 2007 2:45 pm
Reply with quote

if i declared two group having some same data types name for example

01 GP1
02 X PIC 9(4).
02 Y PIC 9(4).
02 Z PIC 9(2).
01 GP2
02 X PIC 9(4).
02 Y PIC 9(4).

How can I assign some value of GP1 variable as the variables name of two groups are same
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Fri Sep 14, 2007 2:50 pm
Reply with quote

rohan,

Quote:
How can I assign some value of GP1 variable as the variables name of two groups are same

Your req is not clear. Post some more info.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Sep 14, 2007 2:54 pm
Reply with quote

Reading is a good skill to learn..... icon_rolleyes.gif
Qualification
Back to top
View user's profile Send private message
lancelot

New User


Joined: 21 Sep 2005
Posts: 1
Location: beijing china

PostPosted: Fri Sep 14, 2007 5:44 pm
Reply with quote

try corr with move statement.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Sep 14, 2007 5:51 pm
Reply with quote

You can use MOVE with CORRESPONDING

[url]
publib.boulder.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=/com.ibm.entcobol4.doc/tpbeg14.htm[/url]

Please post few more details.
Back to top
View user's profile Send private message
snehalpatel

New User


Joined: 13 Sep 2007
Posts: 37
Location: India

PostPosted: Fri Sep 14, 2007 6:04 pm
Reply with quote

rohan kumar panda wrote:
if i declared two group having some same data types name for example

01 GP1
02 X PIC 9(4).
02 Y PIC 9(4).
02 Z PIC 9(2).
01 GP2
02 X PIC 9(4).
02 Y PIC 9(4).

How can I assign some value of GP1 variable as the variables name of two groups are same


If you are trying to populate GP1 variable, then since variable names are same u can use GROUP qualifier .. eg
MOVE X OF GP2 TO X OF GP1
MOVE Y OF GP2 TO Y OF GP1...
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: Fri Sep 14, 2007 6:25 pm
Reply with quote

Hello rohan kumar panda and welcome to the forums,

It is usually not good to use the same elementary field names for fields within different groups. Many places will not permit this.

It makes coding more tedious and can cause problems for years. If the program is many thousand lines and there are one or 2 "moves" that refer to the wrong qualified field name, it may go undetected for a long time.

I'd suggest working to eliminate this rather than find ways to exploit it. It is another of the things you can do that should not be done.
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Fri Sep 14, 2007 9:42 pm
Reply with quote

If you cannot change the copybook, please do not use 'move corresponding'. It is dangerous if someone changes the copybook and does not change your code. If you do not change the elementary item names, I would suggest that you use:

move x of GP1 to x of GP2
move y of GP1 to y of GP2
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 Compare latest 2 rows of a table usin... DB2 1
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Splitting group records based on deta... DFSORT/ICETOOL 8
No new posts SORT HELP - SORT A COLUMN and GROUP B... DFSORT/ICETOOL 9
No new posts INCLUDE COND with WHEN=GROUP SYNCSORT 12
Search our Forums:

Back to Top