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

Can i use redefine clause in occurs


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

New User


Joined: 15 Oct 2005
Posts: 25

PostPosted: Mon Feb 20, 2006 11:34 am
Reply with quote

can i use redefine clause in occurs? if yes please explain with example?
Back to top
View user's profile Send private message
smiley
Warnings : 1

New User


Joined: 08 Feb 2006
Posts: 27

PostPosted: Mon Feb 20, 2006 11:54 am
Reply with quote

Quote:
can i use redefine clause in occurs? if yes please explain with example?



Yes,we can..

eg:-

Quote:
01 DATA-REC.
05 STRING-1 PIC X(04) VALUE ?TEST?.
05 TEST-REC REDEFINES STRING-1 OCCURS 12 TIMES PICXXX.
Back to top
View user's profile Send private message
smiley
Warnings : 1

New User


Joined: 08 Feb 2006
Posts: 27

PostPosted: Mon Feb 20, 2006 11:57 am
Reply with quote

sorry..it is like this..

Quote:
01 DATA-REC.
05 STRING-1 PIC X(100).
05 STRING-2 REDEFINES STRING-1 OCCURS 10 TIMES PIC X(10).

Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Tue Feb 21, 2006 11:45 am
Reply with quote

Quote:
Hi smiley,

You gave a example of REDEFINE with occurs clause. Where as Tarun asked example of REDEFINE within OCCURS clause.



We can use REDEFINE within OCCURS clause, as shown below:

Code:
01 A.                   
  05 B1 OCCURS 10 TIMES.
    10 C1      PIC X(1).
    10 C2      PIC X(5).
    10 C3 REDEFINES C2. 
       15 D1   PIC X(2).
       15 D2   PIC X(2).
    10 C4      PIC X(5).
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Tue Feb 21, 2006 11:54 am
Reply with quote

Hi,

Code:

01 A.                   
  05 B1 OCCURS 10 TIMES.
    10 C1      PIC X(1).
    10 C2      PIC X(5).
    10 C3 REDEFINES C2. 
       15 D1   PIC X(2).
       15 D2   PIC X(2).
    10 C4      PIC X(5).


works fine but some thing like

Code:
01 A.                   
  05 B1 OCCURS 10 TIMES.
    10 C1      PIC X(1).
    10 C2      PIC X(5).
    10 C3 REDEFINES C2. 
       15 D1   PIC X(2).
       15 D2   PIC X(2).
    10 C4      PIC X(5).
  05 B2 REDEFINES B1
 

will give error.

We cant redefine a table.
Back to top
View user's profile Send private message
small_world

New User


Joined: 22 Jul 2005
Posts: 24
Location: pune

PostPosted: Tue Feb 21, 2006 12:22 pm
Reply with quote

05 TIBECAAP-WORK-REC.
10 FILLER PIC X(22) VALUE 'AC AC '.
10 FILLER PIC X(22) VALUE 'AT AT '.
10 FILLER PIC X(22) VALUE 'MR PS '.
10 FILLER PIC X(22) VALUE 'PS PS '.

05 TIBECAAP-TAB-R REDEFINES TIBECAAP-WORK-REC.
10 TIBECAAP-ENT OCCURS 22 TIMES.
15 TIBECAAP-SRV PIC X(04).
15 TIBECAAP-SUB-SRV PIC X(04).
15 TIBECAAP-DFLT-IDC PIC X(01).


icon_wink.gif
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Tue Feb 21, 2006 12:27 pm
Reply with quote

Yes you are right fixdoubts.

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

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Tue Feb 21, 2006 1:58 pm
Reply with quote

small_world wrote:
05 TIBECAAP-WORK-REC.
10 FILLER PIC X(22) VALUE 'AC AC '.
10 FILLER PIC X(22) VALUE 'AT AT '.
10 FILLER PIC X(22) VALUE 'MR PS '.
10 FILLER PIC X(22) VALUE 'PS PS '.

05 TIBECAAP-TAB-R REDEFINES TIBECAAP-WORK-REC.
10 TIBECAAP-ENT OCCURS 22 TIMES.
15 TIBECAAP-SRV PIC X(04).
15 TIBECAAP-SUB-SRV PIC X(04).
15 TIBECAAP-DFLT-IDC PIC X(01).


icon_wink.gif


Boss this will give a compilation error.
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 Updating a 1 byte thats in occurs mul... DFSORT/ICETOOL 6
No new posts NOT IN clause in COBOL pgm COBOL Programming 8
No new posts SUSBSCRIPT WITH SIGN IN PIC CLAUSE COBOL Programming 3
No new posts usage of CASE in WHERE clause DB2 10
Search our Forums:

Back to Top