View previous topic :: View next topic
|
Author |
Message |
sivatechdrive
Active User
Joined: 17 Oct 2004 Posts: 191 Location: hyderabad
|
|
|
|
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
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
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
New User
Joined: 20 Oct 2004 Posts: 59
|
|
|
|
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
Active User
Joined: 25 Jan 2004 Posts: 160 Location: Toronto, Canada
|
|
|
|
yes also you should give a PIc clause.. |
|
Back to top |
|
|
suryakanth HM
New User
Joined: 28 Jun 2005 Posts: 6 Location: Bangalore
|
|
|
|
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
New User
Joined: 19 Jul 2005 Posts: 7
|
|
|
|
1). C will occupy 2 bytes...
2). DO we the function like REM in cobol
Not sure..... |
|
Back to top |
|
|
maggiebms
New User
Joined: 23 May 2005 Posts: 16
|
|
|
|
REM gives the remainder value . It is the intrinsic function in COBOL.
Eg
COMPUTE A = FUNCTION REM(10,2.5) |
|
Back to top |
|
|
yaju4ever Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 19 Location: mumbai
|
|
|
|
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
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 19 Location: mumbai
|
|
|
|
in cobol 85 we cant do such an action |
|
Back to top |
|
|
mahesh.ajagtap
New User
Joined: 30 Sep 2006 Posts: 6
|
|
|
|
01 a pic 99.
B Redefines A.
C Redefines B
will generate a syntax error. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 19 Location: mumbai
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 Warnings : 1 New User
Joined: 26 Feb 2006 Posts: 38
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
prabeesh Currently Banned New User
Joined: 07 Dec 2006 Posts: 9 Location: chennai
|
|
|
|
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 |
|
|
|