IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

B Redefines A, C Redefines B

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC
Goto page 1, 2  Next
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> Mainframe COBOL
View previous topic :: View next topic  
Author Message
sivatechdrive



Joined: 17 Oct 2004
Posts: 168
Location: hyderabad

Posted: Wed Dec 08, 2004 9:54 am    Post subject: B Redefines A, C Redefines B  

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  
ovreddy



Joined: 06 Dec 2004
Posts: 200
Location: Keane India Ltd., Hyderabad

Posted: Wed Dec 08, 2004 5:21 pm    Post subject: Ya Its possible...  

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  
sunnyk



Joined: 20 Oct 2004
Posts: 59

Posted: Wed Dec 08, 2004 7:11 pm    Post subject:  

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  
jz1b0c



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

Posted: Wed Dec 08, 2004 10:54 pm    Post subject:  

yes also you should give a PIc clause..
Back to top  
suryakanth HM



Joined: 28 Jun 2005
Posts: 6
Location: Bangalore

Posted: Tue Jun 28, 2005 5:24 pm    Post subject: Re: Redefines..  

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  
nnaveenreddy



Joined: 19 Jul 2005
Posts: 7

Posted: Thu Jul 21, 2005 12:57 pm    Post subject: Re: Redefines..  

1). C will occupy 2 bytes...

2). DO we the function like REM in cobol

Not sure.....
Back to top  
maggiebms



Joined: 23 May 2005
Posts: 12

Posted: Fri Jul 22, 2005 11:51 am    Post subject: Re: B Redefines A, C Redefines B  

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

Eg
COMPUTE A = FUNCTION REM(10,2.5)
Back to top  
yaju4ever



Joined: 30 Sep 2006
Posts: 20
Location: mumbai

Posted: Mon Dec 11, 2006 5:59 pm    Post subject:  

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  
William Thompson



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

Posted: Mon Dec 11, 2006 6:18 pm    Post subject: Re: B Redefines A, C Redefines B  

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  
yaju4ever



Joined: 30 Sep 2006
Posts: 20
Location: mumbai

Posted: Mon Dec 11, 2006 7:05 pm    Post subject: Re: B Redefines A, C Redefines B  

in cobol 85 we cant do such an action
Back to top  
mahesh.ajagtap



Joined: 30 Sep 2006
Posts: 6

Posted: Wed Dec 13, 2006 12:26 am    Post subject:  

01 a pic 99.
B Redefines A.
C Redefines B
will generate a syntax error.
Back to top  
dick scherrer



Joined: 23 Nov 2006
Posts: 8766
Location: 221 B Baker St

Posted: Wed Dec 13, 2006 3:44 am    Post subject:  

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  
yaju4ever



Joined: 30 Sep 2006
Posts: 20
Location: mumbai

Posted: Wed Dec 13, 2006 11:38 am    Post subject: i couldnt understand wht u want to ask  

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  
arcvns



Joined: 17 Oct 2006
Posts: 797
Location: Chennai, India

Posted: Wed Dec 13, 2006 12:36 pm    Post subject:  

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  
SSR



Joined: 26 Feb 2006
Posts: 38

Posted: Wed Dec 13, 2006 1:37 pm    Post subject: Re: B Redefines A, C Redefines B  

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  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> Mainframe COBOL Goto page 1, 2  Next
Page 1 of 2
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM