View previous topic :: View next topic
|
Author |
Message |
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
|
k.junaid83
New User
Joined: 19 Apr 2006 Posts: 22 Location: bangalore
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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 |
|
|
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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... 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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|