Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

B Redefines A, C Redefines B

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

Active User


Joined: 17 Oct 2004
Posts: 190
Location: hyderabad

PostPosted: Wed Dec 08, 2004 9:54 am    Post subject: B Redefines A, C Redefines B
Reply with quote

hi all

1>

01 A PIC 99.
01 B REDEFINES A
01 C REDEFINES B

can we give like this,what is length of C



2> DO we the function like REM in cobol
Back to top
View user's profile Send private message

ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Wed Dec 08, 2004 5:21 pm    Post subject: Ya Its possible...
Reply with quote

1 ans: This is possible U can REDEFINE an already REDEFINED data item. C also will occupy the same location referred by A,B. all A,B,C have the same length that is 2.

2 ans: REM in the sense REMARK or COMMENT. Ya I think you know already that we have * for that. put * in 7th column so that the entire line becomes comment.
Back to top
View user's profile Send private message
sunnyk

New User


Joined: 20 Oct 2004
Posts: 59

PostPosted: Wed Dec 08, 2004 7:11 pm    Post subject:
Reply with quote

No u can`t redefine like this.
it shud be:
01 a pic 99.
01 b redefines a.
01 c redefines a.
Back to top
View user's profile Send private message
jz1b0c

Active User


Joined: 25 Jan 2004
Posts: 160
Location: Toronto, Canada

PostPosted: Wed Dec 08, 2004 10:54 pm    Post subject:
Reply with quote

yes also you should give a PIc clause..
Back to top
View user's profile Send private message
suryakanth HM

New User


Joined: 28 Jun 2005
Posts: 6
Location: Bangalore

PostPosted: Tue Jun 28, 2005 5:24 pm    Post subject: Re: Redefines..
Reply with quote

Ya, its possible to redefine a dataname which redefines another dataname.Thats what your case is...
I think you may have to use pic class in it..
check it....
Back to top
View user's profile Send private message
nnaveenreddy

New User


Joined: 19 Jul 2005
Posts: 7

PostPosted: Thu Jul 21, 2005 12:57 pm    Post subject: Re: Redefines..
Reply with quote

1). C will occupy 2 bytes...

2). DO we the function like REM in cobol

Not sure.....
Back to top
View user's profile Send private message
maggiebms

New User


Joined: 23 May 2005
Posts: 16

PostPosted: Fri Jul 22, 2005 11:51 am    Post subject: Re: B Redefines A, C Redefines B
Reply with quote

REM gives the remainder value . It is the intrinsic function in COBOL.

Eg
COMPUTE A = FUNCTION REM(10,2.5)
Back to top
View user's profile Send private message
yaju4ever
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 19
Location: mumbai

PostPosted: Mon Dec 11, 2006 5:59 pm    Post subject:
Reply with quote

as per my knowledge we cant redifned a data item which is redefining another data item....in the above code u r trying to re define B which is redifining A its is not correct....u can only redefine an original data item ....now it doesnot matter how many times its being redefined.....correct me if i am wrong.....
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 6:18 pm    Post subject: Re: B Redefines A, C Redefines B
Reply with quote

sivatechdrive wrote:
01 A PIC 99.
01 B REDEFINES A
01 C REDEFINES B

can we give like this,what is length of C


To all the nay-sayers, compilers change and compilers have various syntax rules and extensions; To say that something "can't" be done might not be true.

Your "B Redefines A, C Redefines B" will probably generate a syntax error.

If it allowed it anyway, C would have the same beginning storage address as both A and B.

The length of C is not known.
Back to top
View user's profile Send private message
yaju4ever
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 19
Location: mumbai

PostPosted: Mon Dec 11, 2006 7:05 pm    Post subject: Re: B Redefines A, C Redefines B
Reply with quote

in cobol 85 we cant do such an action
Back to top
View user's profile Send private message
mahesh.ajagtap

New User


Joined: 30 Sep 2006
Posts: 6

PostPosted: Wed Dec 13, 2006 12:26 am    Post subject:
Reply with quote

01 a pic 99.
B Redefines A.
C Redefines B
will generate a syntax error.
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: Wed Dec 13, 2006 3:44 am    Post subject:
Reply with quote

This code
01 REDEFTST1 PIC X(15) VALUE SPACES.
01 REDEFTST1A REDEFINES REDEFTST1 PIC X(15).
01 REDEFTST1B REDEFINES REDEFTST1A PIC X(15).

MOVE 'QWERTYUIOPASDFG' TO REDEFTST1A.
DISPLAY '1 ' REDEFTST1
DISPLAY '1A ' REDEFTST1A
DISPLAY '1B ' REDEFTST1B

compiles correctly and
produces this result
1 QWERTYUIOPASDFG
1A QWERTYUIOPASDFG
1B QWERTYUIOPASDFG


This code
01 REDEFTST2 PIC X(15) VALUE SPACES.
01 REDEFTST2A REDEFINES REDEFTST2.
01 REDEFTST2B REDEFINES REDEFTST2A.
gets errors - "IGYDS1159-E A "PICTURE" CLAUSE WAS NOT FOUND FOR ELEMENTARY ITEM. . . ."

The TST1 style has worked on different platforms (pc, unix, mainframes) and various COBOL versions. The TST2 style has not worked on any platform that i'm familiar with. There is a RENAMES feature . . . .

It is possible that i do not understand the original problem. Please advise.
Back to top
View user's profile Send private message
yaju4ever
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 19
Location: mumbai

PostPosted: Wed Dec 13, 2006 11:38 am    Post subject: i couldnt understand wht u want to ask
Reply with quote

in ur code u r giving another name to REDEFTST1 as REDEFTST1A and REDEFTST1B it will work fine but in ur secind style u are trying to give a name to a data name which is redefining another data.....so it is not supported by cobol ....and conceptually it dosnt work.......i think i have explained up to my knowledge....
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2275
Location: @my desk

PostPosted: Wed Dec 13, 2006 12:36 pm    Post subject:
Reply with quote

Hi Yaju4ever

The REDEFINES clause allows different data description entries to describe the same storage area.Why should one go for REDEFINE without giving a PIC clause for the redefining data-item.

So the first one should work anyway.In the second example he is not giving any redefining data description.

I tried the same example of redefining a redefined data-item and it is working fine for me.May be yours is a different version of cobol.

Code:
 
          WORKING-STORAGE SECTION.
          01   RED1 PIC X(5) VALUE SPACES.   
          01   RED2 REDEFINES RED1 PIC 9(5).
          01            REDEFINES RED2.         
                05  RED3 PIC 9 OCCURS 5 TIMES.

          PROCEDURE DIVISION.
           
          MOVE '12345' TO RED1   
          DISPLAY  RED1   
          DISPLAY  RED2   
          DISPLAY  RED3(1)
          DISPLAY  RED3(2)
          DISPLAY  RED3(3)
          DISPLAY  RED3(4)
          DISPLAY  RED3(5)
          STOP RUN.


Thanks
Arun
Back to top
View user's profile Send private message
SSR
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 38

PostPosted: Wed Dec 13, 2006 1:37 pm    Post subject: Re: B Redefines A, C Redefines B
Reply with quote

Hi,


[quote="sivatechdrive"]hi all

1>

01 A PIC 99.
01 B REDEFINES A
01 C REDEFINES B

can we give like this,what is length of C

You can redefine an item which is already redefined, but in your case you have to specify your data item PIC clause has to be provided.

Let me know in case you need any further details.

Regards
SSR
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Wed Dec 13, 2006 2:49 pm    Post subject:
Reply with quote

If the REM question stands for REMainder, then the classic DIVIDE sentence can also be used:
Code:
DIVIDE WS-DIVIDENT BY WS-DIVISOR GIVING WS-QUOTIENT
    REMAINDER WS-REMAIN
Back to top
View user's profile Send private message
prabeesh
Currently Banned

New User


Joined: 07 Dec 2006
Posts: 9
Location: chennai

PostPosted: Wed Dec 13, 2006 3:26 pm    Post subject: Re: B Redefines A, C Redefines B
Reply with quote

I given like this it is working

01 REDEFTST1.
05 NAME PIC X(9).
01 REDEFTST2A REDEFINES REDEFTST1.
05 FN PIC X(9).

if i am giving like this

01 REDEFTST1.
05 NAME PIC X(9).
01 REDEFTST2A REDEFINES REDEFTST1.

error is showing like this "A "PICTURE" clause was not found for elementary item "REDEFTST2A".
"PICTURE X(1)" was assumed. "
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 Another redefines in COBOL RahulG31 COBOL Programming 1 Fri Mar 20, 2015 4:09 am
No new posts Redefines clause in symbolic map MPC ... eprasad629 CICS 1 Sun Jan 15, 2012 12:18 am
No new posts Redefines usage nirmal.poikaikumaran COBOL Programming 15 Wed Mar 09, 2011 6:33 pm
No new posts Rename & Redefines srk.neeraj COBOL Programming 5 Mon Feb 14, 2011 6:06 pm
No new posts Defining REDEFINES cobol field in EZT rgupta71 CA Products 4 Mon Jan 31, 2011 9:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us