View previous topic :: View next topic
|
Author |
Message |
srkumar422
New User
Joined: 27 Mar 2006 Posts: 16
|
|
|
|
I have below code.
Code: |
ID DIVISION.
PROGRAM-ID. RENAMPGM.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 GRP.
02 A.
03 X PIC 999.
03 X1 REDEFINES X PIC X.
03 B.
04 Y PIC X VALUE 'B'.
04 Y1 PIC X(10) VALUE ALL 'B1'.
04 Y2 PIC X(10) VALUE ALL 'B2'.
03 C VALUE 'A SDFL 4087'.
04 Z PIC X.
04 Z1 PIC X(5).
04 Z2 PIC X(5).
66 RNM3 RENAMES X1 THRU Z1.
PROCEDURE DIVISION.
MAIN-PARA.
MOVE 11 TO X.
DISPLAY RNM3.
STOP RUN. |
Per my knowledge the answer (RNM3 value) should be
1BB1B1B1B1B1B2B2B2B2B2A SDFL, But system gave answer like
11BB1B1B1B1B1B2B2B2B2B2A SDFL
Could you please explain the reason |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
just watching the first value... 'for me' none of them is right.
if x = 11 (011) the value of x1 is 0. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Ravi kumar Siluveru ,
not being in the habit of exploiting enteprise cobol's abilitiy to make illogical redefines,
don't know how it will map.
but, suggest you look at the map to determine how address assignment was done.
Ravi,
why don't you supply us with the map of these data definitions,
then we will all know without having to burn-up our machines to determine the answer. |
|
Back to top |
|
|
srkumar422
New User
Joined: 27 Mar 2006 Posts: 16
|
|
|
|
Ohh sorry!!!
picture cluase of X is 99 not 999. |
|
Back to top |
|
|
srkumar422
New User
Joined: 27 Mar 2006 Posts: 16
|
|
|
|
Dick,
Sorry, I am not getting 'Map of the data definitions'. My intention is to know if we rename the redefined item, will rename work or not?
will it take the original item (here X) instead of redefined item (X1)? |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
address of X1 = Address of X
Code: |
offset
00 01 GRP.
00 02 A.
00 03 X PIC 99.
00 03 X1 REDEFINES X PIC X.
02 03 B.
02 04 Y PIC X VALUE 'B'.
03 04 Y1 PIC X(10) VALUE ALL 'B1'.
13 04 Y2 PIC X(10) VALUE ALL 'B2'.
23 03 C VALUE 'A SDFL 4087'.
23 04 Z PIC X.
24 04 Z1 PIC X(5).
29 04 Z2 PIC X(5).
0 66 RNM3 RENAMES X1 THRU Z1. |
thus rnm3 goes from offset 0 to 28 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
The storage map can be very useful and it's easy to add the compile option to get it. The map for your code is:
Code: |
Source Hierarchy and Base Hex-Displacement Asmblr Data Data Def
LineID Data Name Locator Blk Structure Definition Data Type Attributes
2 PROGRAM-ID MF0154------------------------------------------------------------------------------------------------------*
15 1 GRP . . . . . . . . . . . . . . . . . . . . . BLW=00000 000 DS 0CL35 Group
16 2 A . . . . . . . . . . . . . . . . . . . . . BLW=00000 000 0 000 000 DS 0CL35 Group
17 3 X . . . . . . . . . . . . . . . . . . . . BLW=00000 000 0 000 000 DS 3C Disp-Num
18 3 X1. . . . . . . . . . . . . . . . . . . . BLW=00000 000 0 000 000 DS 1C Display R
19 3 B . . . . . . . . . . . . . . . . . . . . BLW=00000 003 0 000 003 DS 0CL21 Group
20 4 Y . . . . . . . . . . . . . . . . . . . BLW=00000 003 0 000 003 DS 1C Display
21 4 Y1. . . . . . . . . . . . . . . . . . . BLW=00000 004 0 000 004 DS 10C Display
22 4 Y2. . . . . . . . . . . . . . . . . . . BLW=00000 00E 0 000 00E DS 10C Display
23 3 C . . . . . . . . . . . . . . . . . . . . BLW=00000 018 0 000 018 DS 0CL11 Group
24 4 Z . . . . . . . . . . . . . . . . . . . BLW=00000 018 0 000 018 DS 1C Display
25 4 Z1. . . . . . . . . . . . . . . . . . . BLW=00000 019 0 000 019 DS 5C Display
26 4 Z2. . . . . . . . . . . . . . . . . . . BLW=00000 01E 0 000 01E DS 5C Display
27 66 RNM3. . . . . . . . . . . . . . . . . . . . . BLW=00000 000 0 000 000 DS 0CL30 Group
|
If you study it, you will learn everything you need to know about why you got the results you got. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
srkumar422 wrote: |
Ohh sorry!!!
picture cluase of X is 99 not 999. |
well that is your answer.
X1 redefines X means starting address of both is the same, regardless of length.
the earlier 999 had me confused, (actually I want to call you a liar)
but as 99, then it makes sense.
as guyc showed in his post. |
|
Back to top |
|
|
|