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
 

 

Redefines usage

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

New User


Joined: 29 Nov 2005
Posts: 66
Location: Bangalore

PostPosted: Wed Mar 09, 2011 6:33 pm    Post subject: Redefines usage
Reply with quote

Hi Team,

I have a record structure like this

Code:
01 EMP-MASTER.
     02  EMP-DET.
           05  EMP-MARK1     PIC 9(3).         
           05  EMP-MARK2     PIC 9(3).
           05  EMP-MARK3     PIC 9(3).
     02  EMP-PERCENT.
           05  PERCENT        PIC 9(3)v9(2).
           05  GRADE-NUM    PIC 9(4).


Suppose i increase the field size of EMP-MARK1 from 9(3) to 9(6), how does the redefine EMP-PERCENT be modified?

Kindly advise

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

don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Wed Mar 09, 2011 6:39 pm    Post subject:
Reply with quote

Is this a trick question? EMP-PERCENT is not a redefine.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Mar 09, 2011 6:42 pm    Post subject:
Reply with quote

I don't see any connection between the two fields so what is the problem?
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 Mar 09, 2011 6:50 pm    Post subject:
Reply with quote

Nirmal - we see only what you show and in the code you postd there is no REDEFINE used. So your question and the example you show don't go with each other. I'd make a guees that you have field definitions as below:
Code:
01 EMP-MASTER.
     02  EMP-DET.
           05  EMP-MARK1     PIC 9(3).         
           05  EMP-MARK2     PIC 9(3).
           05  EMP-MARK3     PIC 9(3).
     02  EMP-PERCENT REDEFINES EMP-DET.
           05  PERCENT        PIC 9(3)v9(2).
           05  GRADE-NUM    PIC 9(4).
- is this correct?
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 Mar 09, 2011 8:46 pm    Post subject:
Reply with quote

Hello,

Quote:
how does the redefine EMP-PERCENT be modified
Accepting that the redefinition Anuj posted is what you meant to post, there is no way we can tell you how to change the redefinition. . . We know nothing about your original data or what/why the change. . .

Depending on what these fields have to do with each other (if anything) you may need to change some field length or add a FILLER somewhere. If they actually have nothing to do with each other, suggest you re-read Craig's reply.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Mar 10, 2011 2:45 am    Post subject:
Reply with quote

Generally, if you increase the lenght of the redefined area, you can get away with not changing anything in the redefinition area. The compiler may issue a warning for your redefines being shorter than the origin area, but if the 2 definition structures has no interaction, you can expect no difference in execution. It is however good practice to add or increase a filler in the redefinition to make lengths match.

But if the 2 definitions interact, like processing the same data in 2 different ways, you usually must modify both structures in order to maintain the same behavior in your program.

On the other hand, never let your redefined area be shorter than any of it's redefines, that will definitly cause trouble or inpredictable behavior of your program.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu Mar 10, 2011 3:59 am    Post subject:
Reply with quote

Quote:
On the other hand, never let your redefined area be shorter than any of it's redefines, that will definitly cause trouble or inpredictable behavior of your program.
Kjeld: the rules have changed a bit on this. From the manual on REDEFINES:
Quote:
If the redefined data item (data-name-2) is declared to be an external data record, the size of the redefining data item (data-name-1) must not be greater than the size of the redefined data item. If the redefined data item is not declared to be an external data record, there is no such constraint.

The following example shows that the redefining item, B, can occupy more storage than the redefined item, A. The size of storage for the REDEFINED clause is determined in number of bytes. Item A occupies 6 bytes of storage and item B, a data item of category national, occupies 8 bytes of storage.




05 A PICTURE X(6).
05 B REDEFINES A GLOBAL PICTURE N(4).

Back to top
View user's profile Send private message
nirmal.poikaikumaran

New User


Joined: 29 Nov 2005
Posts: 66
Location: Bangalore

PostPosted: Thu Mar 10, 2011 7:52 am    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

Quote:
how does the redefine EMP-PERCENT be modified
Accepting that the redefinition Anuj posted is what you meant to post, there is no way we can tell you how to change the redefinition. . . We know nothing about your original data or what/why the change. . .

Depending on what these fields have to do with each other (if anything) you may need to change some field length or add a FILLER somewhere. If they actually have nothing to do with each other, suggest you re-read Craig's reply.


Hi Dick/Anuj,

Yeah that was a typo, i missed out the connection part. Anuj's data structure is what I have.

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

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu Mar 10, 2011 7:59 am    Post subject:
Reply with quote

Since you have 3 3-byte variables and you're redefining them into a 5-byte and a 4-byte variable: increasing the first 3-byte variable from 3 to 6 bytes means the 5-byte and 4-byte variables now overlay the first two variables instead of all 3 variables. Is this wrong? Only analysis of the application will tell -- and since we don't work at your site, nor do we work on your application, we really cannot tell you anything about the impact. You may have to increase PERCENT from 5 to 8 bytes, you may have to add a filler, you may have to redesign the code entirely -- there's no way of knowing without looking into the code.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Mar 10, 2011 5:25 pm    Post subject:
Reply with quote

Robert Sample wrote:
Quote:
On the other hand, never let your redefined area be shorter than any of it's redefines, that will definitly cause trouble or inpredictable behavior of your program.
Kjeld: the rules have changed a bit on this. From the manual on REDEFINES:
Quote:
If the redefined data item (data-name-2) is declared to be an external data record, the size of the redefining data item (data-name-1) must not be greater than the size of the redefined data item. If the redefined data item is not declared to be an external data record, there is no such constraint.

The following example shows that the redefining item, B, can occupy more storage than the redefined item, A. The size of storage for the REDEFINED clause is determined in number of bytes. Item A occupies 6 bytes of storage and item B, a data item of category national, occupies 8 bytes of storage.




05 A PICTURE X(6).
05 B REDEFINES A GLOBAL PICTURE N(4).


Just because it is allowed, it might not be considered good practice.

In the example above, if you update B, what storage beyond A is actually updated? Does the compiler actually reserve 8 bytes of storage fra the start of A (an implicit filler)?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu Mar 10, 2011 5:47 pm    Post subject:
Reply with quote

Yes, the compiler does reserve the extra two bytes.
Code:
       01  WS-VARS.
           03  A                           PIC X(06).
           03  B                           REDEFINES A
                                           PIC N(4).
           03  C                           PIC X(03) VALUE 'END'.
storage map:
Code:
WS-VARS . . . . . . . . . . . . . . . . . . . BLW=00000  000               DS 0C
  A . . . . . . . . . . . . . . . . . . . . . BLW=00000  000   0 000 000   DS 6C
  B . . . . . . . . . . . . . . . . . . . . . BLW=00000  000   0 000 000   DS 8C
  C . . . . . . . . . . . . . . . . . . . . . BLW=00000  008   0 000 008   DS 3C
It certainly is not good practice, but if someone is relying upon the compiler to generate an error for this, it doesn't -- just a warning:
Code:
 ==000016==> IGYDS1154-W "B" redefined a smaller item.  The program was accepted as written.
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 Mar 10, 2011 6:15 pm    Post subject:
Reply with quote

I've seen them using compile option FLAG(E) sometimes - result? -- even this warning message won't show up. And then they complian, Application Programmer is not competent enough! Sigh!
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Thu Mar 10, 2011 6:51 pm    Post subject:
Reply with quote

Kjeld wrote:
Just because it is allowed, it might not be considered good practice.

In the example above, if you update B, what storage beyond A is actually updated? Does the compiler actually reserve 8 bytes of storage fra the start of A (an implicit filler)?
I totally agree that it's a poor practice. We used to rely on getting a compiler error to tell us that we've used up all the space in a redefined area. Now, if you don't notice the Warning message, then the impact can be serious; especially if the redefined area is used for IO operations.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Mar 10, 2011 6:55 pm    Post subject:
Reply with quote

Before this change you would get the same warning, but, referencing the example above, modifying the 8 bytes of B would imply modifying the 6 bytes of A and 2 first bytes of C. And the structure length of WS-VARS has increased with 2 bytes.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Thu Mar 10, 2011 6:57 pm    Post subject:
Reply with quote

Robert Sample wrote:
Yes, the compiler does reserve the extra two bytes.
Code:
       01  WS-VARS.
           03  A                           PIC X(06).
           03  B                           REDEFINES A
                                           PIC N(4).
           03  C                           PIC X(03) VALUE 'END'.
storage map:
Code:
WS-VARS . . . . . . . . . . . . . . . . . . . BLW=00000  000               DS 0C
  A . . . . . . . . . . . . . . . . . . . . . BLW=00000  000   0 000 000   DS 6C
  B . . . . . . . . . . . . . . . . . . . . . BLW=00000  000   0 000 000   DS 8C
  C . . . . . . . . . . . . . . . . . . . . . BLW=00000  008   0 000 008   DS 3C
It certainly is not good practice, but if someone is relying upon the compiler to generate an error for this, it doesn't -- just a warning:
Code:
 ==000016==> IGYDS1154-W "B" redefined a smaller item.  The program was accepted as written.

Alas, I'm afraid that the compiler only reserves the "extra two bytes" for WORKING STORAGE items, not for LINKAGE SECTION items.
Programs containing mismatched REDEFINES in a LINKAGE SECTION may still end up in deep doodoo.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Thu Mar 10, 2011 7:07 pm    Post subject:
Reply with quote

FYI, IGYDS1154 was demoted from a severe error to a warning by the Enterprise Cobol 3.4 compiler.

Here is a link to a SHARE presentation from 2007:

http://www-01.ibm.com/support/docview.wss?uid=swg27006657&aid=1
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 How can amount of the Storage Usage b... esduman61 CICS 6 Wed Mar 09, 2016 1:19 pm
No new posts Controlling usage of resources by tasks raja1128 CICS 3 Fri Nov 06, 2015 9:53 am
No new posts TDQ & its usage as ATI akodakka CICS 3 Sat Oct 17, 2015 6:04 pm
No new posts XPED - When command usage anand1204 Compuware & Other Tools 3 Tue Sep 15, 2015 12:50 am
No new posts Usage of NETRC for FTP step in JCL Vineetha_123 JCL & VSAM 3 Fri Jul 17, 2015 3:24 pm


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