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

Usage of redefines clause


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

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Tue Oct 27, 2009 11:57 am
Reply with quote

How do we use REDEFINE for a group variable which is having arrays in it?

01 A PIC X(100)
01 B REDEFINES A.
05 TEMP-1 OCCURS 0 TO 10 TIMES DEPENDING ON X.
05 TEMP-2 OCCURS 1 TO 100 TIMES DEPENDING ON Y.
How to use it in file section?. Also kindly let me know if we can redefine a 01 level variable.
Back to top
View user's profile Send private message
k.junaid83

New User


Joined: 19 Apr 2006
Posts: 22
Location: bangalore

PostPosted: Tue Oct 27, 2009 1:58 pm
Reply with quote

Yes we can redefine a variable which is having an OCCURS clause, however Neither data item can contain an OCCURS DEPENDING ON clause.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Oct 27, 2009 3:01 pm
Reply with quote

Hi Abdul,

Adding on to Junaid's post...

A note from the REDEFINES topic available in the Manuals
Code:
The data description entry for the redefined item cannot contain an OCCURS clause. However, the redefined item can be subordinate to an item whose data description entry contains an OCCURS clause. In this case, the reference to the redefined item in the REDEFINES clause must not be subscripted. Neither the redefined item nor the redefining item, or any items subordinate to them, can contain an OCCURS DEPENDING ON clause.


Quote:
How to use it in file section?. Also kindly let me know if we can redefine a 01 level variable.

In case of files... its not necessary to give REDEFINES. Just Define two 01 levels under the file and it should be fine.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Wed Oct 28, 2009 10:37 am
Reply with quote

Hi Binop,

So as per your statement "the redefining item or the redefined item must not contain depending on clause", the code which I have given seems to be incorrect as it has a depending clause.

The below code is incorrect.
01 A PIC X(100)
01 B REDEFINES A.
05 TEMP-1 OCCURS 0 TO 10 TIMES DEPENDING ON X.
05 TEMP-2 OCCURS 1 TO 100 TIMES DEPENDING ON Y.

The below code is correct.
01 A PIC X(100)
01 B REDEFINES A.
05 TEMP-1 OCCURS 0 TO 10 TIMES.
05 TEMP-2 OCCURS 1 TO 100 TIMES.


I think usage of Indexed wont have any problem like the one mentioned below,
01 A PIC X(100)
01 B REDEFINES A.
05 TEMP-1 OCCURS 0 TO 10 TIMES INDEXED BY X.
05 TEMP-2 OCCURS 1 TO 100 TIMES INDEXED BY Y.


Please let me know if my understanding is correct and if anyting is wrong correct me?.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Wed Oct 28, 2009 10:44 am
Reply with quote

Hi Abdul,

Quote:
So as per your statement "the redefining item or the redefined item must not contain depending on clause", the code which I have given seems to be incorrect as it has a depending clause.

I dare say this as my statement... icon_rolleyes.gif as mentioned its a line picked out from the manuals...

Quote:
Please let me know if my understanding is correct and if anyting is wrong correct me?.
With all due respect.. suggest you to have a look into the manuals... That should be the first task... If you are still unclear... please post here again.. and surely someone will be able to help you...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Oct 28, 2009 5:07 pm
Reply with quote

Quote:
The below code is incorrect.
01 A PIC X(100)
01 B REDEFINES A.
05 TEMP-1 OCCURS 0 TO 10 TIMES DEPENDING ON X.
05 TEMP-2 OCCURS 1 TO 100 TIMES DEPENDING ON Y.

The below code is correct.
01 A PIC X(100)
01 B REDEFINES A.
05 TEMP-1 OCCURS 0 TO 10 TIMES.
05 TEMP-2 OCCURS 1 TO 100 TIMES.


I think usage of Indexed wont have any problem like the one mentioned below,
01 A PIC X(100)
01 B REDEFINES A.
05 TEMP-1 OCCURS 0 TO 10 TIMES INDEXED BY X.
05 TEMP-2 OCCURS 1 TO 100 TIMES INDEXED BY Y.


Please let me know if my understanding is correct and if anyting is wrong correct me?.
None of these will compile since your TEMP-1 and TEMP-2 variables have no picture clauses associated with them, nor do you have a period after the X(100) for A -- syntax errors.

Even after fixing the syntax errors, you will find that none of these examples will compile:
Code:
            01  A2                          PIC X(100).
            01  B2                          REDEFINES A2.

                05  TEMP-12                 OCCURS 0 TO 10 TIMES

IGYDS1262-E A minimum occurrence integer was specified for table "TEMP-12" witho
            the "DEPENDING ON" phrase.  The minimum occurrence integer was disca

                                            INDEXED BY X2
                                            PIC X(01).
                05  TEMP-22                 OCCURS 1 TO 100 TIMES
IBM Enterprise COBOL for z/OS  3.4.1               MF0103    Date 10/28/2009  Ti
 SL  ----+-*A-1-B--+----2----+----3----+----4----+----5----+----6----+----7-|--+

IGYDS1262-E A minimum occurrence integer was specified for table "TEMP-22" witho
            the "DEPENDING ON" phrase.  The minimum occurrence integer was disca

                                            INDEXED BY Y2
                                            PIC X(01).
The correct statement to make is that a REDEFINES that has an OCCURS clause must only have the number of occurrences (which can total less than the size of the redefined variable), period. It explicitly cannot be an OCCURS DEPENDING ON nor can it implicitly be an OCCURS DEPENDING ON by having a range of occurrences.
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: Wed Oct 28, 2009 8:14 pm
Reply with quote

Hello,

Quote:
How do we use REDEFINE for a group variable which is having arrays in it?
If you post some of the actual data it may help.

It may also help if you explain how this data was created. . .
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 To search DB2 table based on Conditio... DB2 1
No new posts STEM usage in REXX CLIST & REXX 14
No new posts z/OS Modules Usage report using SMF 42 DFSORT/ICETOOL 2
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts JCL and TAPE drives: how to maximize ... JCL & VSAM 9
Search our Forums:

Back to Top