Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Redefining AlphaNumeric to Numeric

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Redefining AlphaNumeric to Numeric
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    Post subject:
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    Post subject: Re: Cobol- Redefines Clause - Query
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: 1452
Location: Chicago, IL

PostPosted: Fri Jun 17, 2005 5:35 pm    Post subject: Re: Cobol- Redefines Clause - Query
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    Post subject:
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: 1452
Location: Chicago, IL

PostPosted: Fri Jun 17, 2005 6:36 pm    Post subject: Re: Cobol- Redefines Clause - Query
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    Post subject:
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: 1452
Location: Chicago, IL

PostPosted: Fri Jun 17, 2005 10:41 pm    Post subject: Re: Cobol- Redefines Clause - Query
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    Post subject:
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: 24

PostPosted: Sun Jun 19, 2005 3:17 pm    Post subject: Re: Cobol- Redefines Clause - Query
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    Post subject:
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: 24

PostPosted: Mon Jun 20, 2005 10:01 pm    Post subject: Re: Cobol- Redefines Clause - Query
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    Post subject: Re: Redefining AlphaNumeric to Numeric
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    Post subject: Re: Redefining AlphaNumeric to Numeric
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    Post subject:
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    Post subject:
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    Post subject: Re: Redefining AlphaNumeric to Numeric
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    Post subject:
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.

http://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    Post subject:
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    Post subject: hi guys
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts alphanumeric sequence generation sivaprasad.gadhi COBOL Programming 6 Wed Mar 30, 2016 3:03 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us