IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Redefining AlphaNumeric to Numeric


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
karthikuma

New User


Joined: 29 Mar 2005
Posts: 62

PostPosted: Tue Jun 07, 2005 10:21 am
Reply with quote

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
View user's profile Send private message
rajakishore

New User


Joined: 04 Apr 2005
Posts: 10
Location: Hyderabad

PostPosted: Tue Jun 07, 2005 5:19 pm
Reply with quote

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
View user's profile Send private message
maverick05

New User


Joined: 14 Apr 2005
Posts: 54
Location: Earth

PostPosted: Fri Jun 17, 2005 5:05 pm
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Jun 17, 2005 5:35 pm
Reply with quote

Quote:
Move 'hai' to A.


I got HAI

Quote:
Move A to B


I got "HAI 0" after this.

Can any body solve mistry over 4th byte.

Regards,

Priyesh.
Back to top
View user's profile Send private message
mfsuresh

New User


Joined: 03 Nov 2004
Posts: 5

PostPosted: Fri Jun 17, 2005 6:25 pm
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Jun 17, 2005 6:36 pm
Reply with quote

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
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Fri Jun 17, 2005 10:34 pm
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Jun 17, 2005 10:41 pm
Reply with quote

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
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Fri Jun 17, 2005 11:11 pm
Reply with quote

Ok, the string 'HAI ' is stored in memory as Pic X in this format:
Code:
HAI 
CCC44
81900

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
View user's profile Send private message
jayesh_g

New User


Joined: 03 Mar 2004
Posts: 23

PostPosted: Sun Jun 19, 2005 3:17 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jun 20, 2005 9:05 am
Reply with quote

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
View user's profile Send private message
jayesh_g

New User


Joined: 03 Mar 2004
Posts: 23

PostPosted: Mon Jun 20, 2005 10:01 pm
Reply with quote

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
View user's profile Send private message
rajesh_sraman

New User


Joined: 06 Jun 2005
Posts: 1
Location: chennai

PostPosted: Wed Jun 22, 2005 3:07 pm
Reply with quote

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
View user's profile Send private message
ranga_subham

New User


Joined: 01 Jul 2005
Posts: 51

PostPosted: Fri Jul 01, 2005 3:10 pm
Reply with quote

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
View user's profile Send private message
ranga_subham

New User


Joined: 01 Jul 2005
Posts: 51

PostPosted: Fri Jul 01, 2005 3:12 pm
Reply with quote

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
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Fri Jul 01, 2005 5:32 pm
Reply with quote

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
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Fri Jul 01, 2005 5:33 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jul 04, 2005 10:48 pm
Reply with quote

Moving mixed data types gets a bit complicated. The link bekow explains elementary moves involving mixed data types. The compiler option NUMPROC also has an effect on the outcome.

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IGY3LR10/6.2.24.1
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jul 04, 2005 11:26 pm
Reply with quote

Hi Parikshit,

Interesting behavior. What's your environment - compiler vers, etc., CPU make, model, etc.?
Back to top
View user's profile Send private message
kotesh

New User


Joined: 11 May 2005
Posts: 20

PostPosted: Wed Jul 06, 2005 2:41 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top