Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to Redefines a Varible to Edited Class

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ajithkumarsl

New User


Joined: 23 Oct 2006
Posts: 19
Location: Chennai

PostPosted: Wed Jun 11, 2008 3:28 pm    Post subject: How to Redefines a Varible to Edited Class
Reply with quote

Hello,

In cobol can we use the following variable declaration?

03 VAR-1 PIC 9(4).
03 VAR-2 REDEFINES VAR-1 PIC ZZZ9.


Thanks
Back to top
View user's profile Send private message

Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 11, 2008 3:49 pm    Post subject:
Reply with quote

You can redefine 9(4) into ZZZ9.

But you got the syntax wrong. It has to be like this

03 VAR-1 PIC 9(4).
03 VAR-2 REDEFINES VAR-1.
05 VAR-3 PIC ZZZ9.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Wed Jun 11, 2008 4:32 pm    Post subject:
Reply with quote

Manu, the OP's syntax is correct.

Ajith,

I hope you don't think you can move something to var1 and then expect to move an edited var2. though you could move var1 (0099) to var2 and then var2 would contain ' 99'.
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 11, 2008 4:47 pm    Post subject:
Reply with quote

Yes his syntax is right. My bad. I had a different error while trying to test it and thought it had to do with the syntax.
Back to top
View user's profile Send private message
ajithkumarsl

New User


Joined: 23 Oct 2006
Posts: 19
Location: Chennai

PostPosted: Wed Jun 11, 2008 4:50 pm    Post subject:
Reply with quote

Thanks Manu and Dick for your replay.

Dick,

What I felt is - why to take more space for an edited variable.
IF we declare Var1 and Var2 as two variables it will take twice the memory space.

Do any syntax is there that we can refer the same space?

Please correct me if I am wrong.

Thanks
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Jun 11, 2008 5:32 pm    Post subject:
Reply with quote

Hi,
ajithkumarsl wrote:
What I felt is - why to take more space for an edited variable. IF we declare Var1 and Var2 as two variables it will take twice the memory space.

Check this link, little different from the current thread but does talk about REDEFINES..

http://www.ibmmainframes.com/viewtopic.php?t=17836&postdays=0&postorder=asc&start=0
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Jun 11, 2008 5:49 pm    Post subject:
Reply with quote

Hi Ajith,

The danger in doing that is knowing at any point in the code what VAR1/2 contains, e.g.:

line 100 move 99 to VAR2
line 1250 add 1 to VAR1 (this will cause an abend).
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: Wed Jun 11, 2008 6:25 pm    Post subject:
Reply with quote

Hello,

Quote:
In cobol can we use the following variable declaration?

03 VAR-1 PIC 9(4).
03 VAR-2 REDEFINES VAR-1 PIC ZZZ9.
While this can be done,it should not be done. . . .

To quote an old IBM phrase - "The results may be unpredictable". If those fields are used multiple places in the code, it will be difficult to always know when the numeric definition contains a valid number.
Back to top
View user's profile Send private message
ajithkumarsl

New User


Joined: 23 Oct 2006
Posts: 19
Location: Chennai

PostPosted: Thu Jun 12, 2008 9:16 am    Post subject:
Reply with quote

Thanks Dick and Anuj.

Dick, I am using the Var1 for populating the page number.

So I am sure that it will always have a valid number.
The only need is to suppress the preceding zeros.
Hope this makes the requirement more clear.

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: Thu Jun 12, 2008 9:46 am    Post subject: Reply to: How to Redefines a Varible to Edited Class
Reply with quote

Hello Ajith,

Quote:
Thanks
You're welcome icon_smile.gif

Thanks for the update.

d
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Jun 12, 2008 11:22 am    Post subject:
Reply with quote

Hi,
ajithkumarsl wrote:
The only need is to suppress the preceding zeros.
Problem is resolved or still there are some problems?
Back to top
View user's profile Send private message
ajithkumarsl

New User


Joined: 23 Oct 2006
Posts: 19
Location: Chennai

PostPosted: Thu Jun 12, 2008 11:58 am    Post subject:
Reply with quote

Hi Anuj,

I have declared two variables(Var1 and Var2 Separately) and done that.
But I couldn't redefine and do.

I am asking this because if next time a same case happen I have to be in a position to handle that.
Now the need came for only one Variable of length 4 but if it is more, I feel, it will be more critical to find a solution.

So temporarily the problem is solved.

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: Thu Jun 12, 2008 12:41 pm    Post subject:
Reply with quote

Hello,

Quote:
Now the need came for only one Variable of length 4 but if it is more, I feel, it will be more critical to find a solution.
I suspect it will never be critical. It is doubtful that you could write enough of these redefines to ever make a difference in the execution of some program.

Your time will be much better invested in making sure the code always works, that the code is maintainable, and the code does not waste cpu time and/or i/o.
Back to top
View user's profile Send private message
ajithkumarsl

New User


Joined: 23 Oct 2006
Posts: 19
Location: Chennai

PostPosted: Mon Jun 16, 2008 3:06 pm    Post subject:
Reply with quote

Thanks for your help..
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 Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm
No new posts question about dfsms management clas... Hervey Martinez IBM Tools 0 Tue Oct 10, 2017 6:19 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts XFACILIT class setting for Fault Anal... egrove IBM Tools 2 Thu Aug 11, 2016 8:02 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us