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
 
CORRECT usage of REDEFINES in Cobol

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

New User


Joined: 22 Jan 2008
Posts: 7
Location: India

PostPosted: Wed May 07, 2008 12:53 pm    Post subject: CORRECT usage of REDEFINES in Cobol
Reply with quote

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
View user's profile Send private message

msgpk

New User


Joined: 22 Jan 2008
Posts: 7
Location: India

PostPosted: Wed May 07, 2008 2:06 pm    Post subject:
Reply with quote

Hi,


Can we use occurs in Redefines clause?
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 May 07, 2008 2:23 pm    Post subject:
Reply with quote

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
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 215
Location: India

PostPosted: Wed May 07, 2008 2:46 pm    Post subject: Reply to: Redefines clause
Reply with quote

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
View user's profile Send private message
rpuhlman

New User


Joined: 11 Jun 2007
Posts: 80
Location: Columbus, Ohio

PostPosted: Wed May 07, 2008 3:23 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Thu May 08, 2008 3:53 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri May 09, 2008 3:41 am    Post subject:
Reply with quote

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 icon_wink.gif

If someone asks how some code might be corrected, we can suggest how to change it (like you did).
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Fri May 09, 2008 12:15 pm    Post subject:
Reply with quote

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 icon_wink.gif

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
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm

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