View previous topic :: View next topic
|
Author |
Message |
karthikuma
New User
Joined: 29 Mar 2005 Posts: 62
|
|
|
|
Hi,
plz give me a solution
[code]
01 A pic x(5)
01 B redefine a pic 9(5)
procedure division.
Move 'hai' to A.
Move A to B.[/code]
WAT WILL HAPPEN TO THE ABOVE REDEFINE CLAUSE.ANY ONE GIVE ME THE SOLUTIONS FOR THIS QUESTIONS.
Reards,
kumar |
|
Back to top |
|
|
rajakishore
New User
Joined: 04 Apr 2005 Posts: 10 Location: Hyderabad
|
|
|
|
Hi Kumar,
I think nothing will happen when u declare like that.
As redefines clause will use the same location, u can even if u give more that x(5).
Regards,
Raj |
|
Back to top |
|
|
maverick05
New User
Joined: 14 Apr 2005 Posts: 54 Location: Earth
|
|
|
|
A and B contains 'HII 0 '.
But i dont the reason.If anyone knows about the 4th byte,plz let me know |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
I got HAI
I got "HAI 0" after this.
Can any body solve mistry over 4th byte.
Regards,
Priyesh. |
|
Back to top |
|
|
mfsuresh
New User
Joined: 03 Nov 2004 Posts: 5
|
|
|
|
hi,
ist thing is u cant redefine 01 level ,
i mean
When more than one level-01 entry is written subordinate to an FD entry, a condition known as implicit redefinition occurs. That is, the second level-01 entry implicitly redefines the storage allotted for the first entry. In such level-01 entries,the REDEFINES clause must not be specified. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi mfsuresh,
Quote: |
u cant redefine 01 level |
I got the same output (HAI 0) even REDEFINIG at FIRST Level & SECOND LEVEL too.
Regards,
Priyesh. |
|
Back to top |
|
|
MGIndaco
Active User
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
I think that the reason are the tso last blanks in 'HAI ' (when you move 3 char in a PIC X(5) the alignment is to left and after you have blanks)
Blank is in hexadecimal format '40' and when you put it from PIC X to PIC 9 the numeric value at the end is 0.
If you try to move at the begin the two blank you will see that
if you use 'I' that's x'C9' or 'i' that's x'89' in each case, in B variable
the result will be 9.
I hope in this help. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
If you try to move at the begin the two blank you will see that
if you use 'I' that's x'C9' or 'i' that's x'89' in each case, in B variable
the result will be 9. |
MGIndaco, Will you please more elaborate this one.
Regards,
Priyesh. |
|
Back to top |
|
|
MGIndaco
Active User
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
Ok, the string 'HAI ' is stored in memory as Pic X in this format:
So, you know that numeric fields has alignment to right and moving the field from memory into a numeric the last value kept is 0 that in numeric format is F0.
I'm looking thru my old documentation but it's very hard find the details of this process. I hope in someone else or... in my fortune... |
|
Back to top |
|
|
jayesh_g
New User
Joined: 03 Mar 2004 Posts: 23
|
|
|
|
F sign is moved into the first nibble of the last byte. This causes X'40' to change to X'F0' in the last byte.
-Jayesh. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Jayesh,
You're right to the extent that an "F" ends up in the hi-ord nybble of the lo-ord byte, but it's not MOVEd there. The compiler generates an "OI" (or immediate) assembler instruction that "changes" whatever's there to an "F".
It's a small distinction, but you can't "move" a 1/2 byte and it would be inefficient to have a tabel containing every variation possible for that lo-ord byte. You'd probably need a routine to do it. |
|
Back to top |
|
|
jayesh_g
New User
Joined: 03 Mar 2004 Posts: 23
|
|
|
|
Jack,
Agreed. I was not talking of "MOVE" either. Thanks for clearing the air, in case anyone was confused by my statement. I just did not want to bring in assembler instructions while discussing COBOL.
-Jayesh. |
|
Back to top |
|
|
rajesh_sraman
New User
Joined: 06 Jun 2005 Posts: 1 Location: chennai
|
|
|
|
i think no need for the move ato b stmt since we are using redefines bcos same memeory location is going to be shared but displaying b will show an error regarding data movement |
|
Back to top |
|
|
ranga_subham
New User
Joined: 01 Jul 2005 Posts: 51
|
|
|
|
Hi all, I don't about the redefining a thing.
Would you please answer my following question.
I have written a small cobol program:
WORKING-STORAGE SECTION.
01 WS-MOVE1 PIC X(09).
01 WS-MOVE2 PIC 9(09).
PROCEDURE DIVISION.
001-MAIN-PARA.
MOVE 'ABCDE' TO WS-MOVE1.
MOVE WS-MOVE1 TO WS-MOVE2.
DISPLAY WS-MOVE1.
DISPLAY WS-MOVE2.
I am getting the following output:
ABCDE
ABCD5
Please explain. |
|
Back to top |
|
|
ranga_subham
New User
Joined: 01 Jul 2005 Posts: 51
|
|
|
|
Sorry.
Please read the variables as follows.
WORKING-STORAGE SECTION.
01 WS-MOVE1 PIC X(05).
01 WS-MOVE2 PIC 9(05). |
|
Back to top |
|
|
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
Okay,
I have got another interesting observation.
I have written the following code and compiled link edited in MS cobol running on dos
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTPGM.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TEST1 PIC X(05).
01 WS-TEST2 PIC 9(05).
PROCEDURE DIVISION.
MOVE 'ABCDE' TO WS-TEST1.
MOVE WS-TEST1 TO WS-TEST2.
DISPLAY 'WS-TEST1==>' WS-TEST1.
DISPLAY 'WS-TEST2==>' WS-TEST2.
STOP RUN.
and the output is :
WS-TEST1==>ABCDE
WS-TEST2==>12345
Any ideas?
Thank you,
Parikshit |
|
Back to top |
|
|
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
Okay,
I have got another interesting observation.
I have written the following code and compiled link edited in MS cobol running on dos
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTPGM.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TEST1 PIC X(05).
01 WS-TEST2 PIC 9(05).
PROCEDURE DIVISION.
MOVE 'ABCDE' TO WS-TEST1.
MOVE WS-TEST1 TO WS-TEST2.
DISPLAY 'WS-TEST1==>' WS-TEST1.
DISPLAY 'WS-TEST2==>' WS-TEST2.
STOP RUN.
and the output is :
WS-TEST1==>ABCDE
WS-TEST2==>12345
Any ideas?
Thank you,
Parikshit |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Parikshit,
Interesting behavior. What's your environment - compiler vers, etc., CPU make, model, etc.? |
|
Back to top |
|
|
kotesh
New User
Joined: 11 May 2005 Posts: 20
|
|
|
|
Actuallly what happen naaaaaaaaa when you are using 5 length and but moving 3 bytes , here the out put is numeric so it places remaining .
ares as 0 ............
regards ..
kotesh IBM |
|
Back to top |
|
|
|