|
|
| Author |
Message |
msgpk
New User
Joined: 22 Jan 2008 Posts: 7 Location: India
|
|
|
|
Hi Guys,
Please let me know the answer for the below one:
Which one of the following statements is CORRECT usage of REDEFINE in Cobol ?
1) 01 WS-GROUP.
03 WS-VARIABLE1 OCCURS 5 TIMES PIC X(1) VALUE 'A'.
03 WS-VARIABLE2 REDEFINES WS-VARIABLE1 PIC X(5).
2) 01 WS-GROUP.
03 WS-VARIABLE1 PIC X(5) VALUE 'AAAAA'.
03 WS-VARIABLE2 REDEFINES FILLER-X OCCURS 5 TIMES PIC X(1).
please suggest me....
Thanks, |
|
| Back to top |
|
 |
References
|
Posted: Wed May 07, 2008 12:53 pm Post subject: Re: CORRECT usage of REDEFINES in Cobol |
 |
|
|
 |
msgpk
New User
Joined: 22 Jan 2008 Posts: 7 Location: India
|
|
|
|
Hi,
Can we use occurs in Redefines clause? |
|
| Back to top |
|
 |
Anuj D.
Senior Member
Joined: 22 Apr 2006 Posts: 1309 Location: Mumbai, India
|
|
|
|
| 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. |
|
| Back to top |
|
 |
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 138 Location: At my Desk
|
|
|
|
As an example you can declare this.
01 WS-PCT-ALPHA PIC X(07) VALUE 'ABCDEFG'.
01 WS-PCT-ALPHA-R REDEFINES WS-PCT-ALPHA.
10 WS-A PIC X(1) OCCURS 7 TIMES INDEXED BY I. |
|
| Back to top |
|
 |
rpuhlman
New User
Joined: 11 Jun 2007 Posts: 48 Location: Columbus, Ohio
|
|
|
|
Actually, both examples are in error. In example 2, FILLER-X is being redefined, but is not itself defined.
| Quote: |
2) 01 WS-GROUP.
03 WS-VARIABLE1 PIC X(5) VALUE 'AAAAA'.
03 WS-VARIABLE2 REDEFINES FILLER-X OCCURS 5 TIMES PIC X(1).
|
|
|
| Back to top |
|
 |
Manuneedhi K
Active User
Joined: 07 May 2008 Posts: 115 Location: Chennai
|
|
|
|
The 2nd example works and the 1st one doesn't. (I am assuming that FILLER-X was placed incorrectly and should have been WS-VARIABLE1)
01 WS-GROUP.
03 WS-VARIABLE1 PIC X(5) VALUE 'AAAAA'.
03 WS-VARIABLE2 REDEFINES WS-VARIABLE1 OCCURS 5 TIMES PIC X(1). |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 6883 Location: 221 B Baker St
|
|
|
|
Hello Manuneedhi K and welcome to the forums,
| Quote: |
| The 2nd example works and the 1st one doesn't. |
Anything/everything works when the code is changed to somethng that is correct. . . We have to reply to what was actually posted
If someone asks how some code might be corrected, we can suggest how to change it (like you did). |
|
| Back to top |
|
 |
Manuneedhi K
Active User
Joined: 07 May 2008 Posts: 115 Location: Chennai
|
|
|
|
| dick scherrer wrote: |
| Hello Manuneedhi K and welcome to the forums |
Thanks dick scherrer
| dick scherrer wrote: |
Anything/everything works when the code is changed to somethng that is correct. . . We have to reply to what was actually posted
If someone asks how some code might be corrected, we can suggest how to change it (like you did). |
Will keep that in mind. |
|
| Back to top |
|
 |
|
|