Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Movement of alphanumeric data to numeric

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Wed Oct 24, 2007 4:12 pm    Post subject: Movement of alphanumeric data to numeric
Reply with quote

Hi Guys,

I checked out the previous posts of alpha numeric to numeric moves etc. I am getting a peculiar output for a small cobol pgm. Could someone help me out here.

My Code:

Code:


01  A PIC X(5).
01  B PIC 9(5).
01  C PIC 9(5) VALUE 10000.

PROCEDURE DIVISION.

MAIN-PARA.

     MOVE 'ABCDE' TO A.
     MOVE A TO B.
     ADD B TO C.
     DISPLAY 'A=' A
     DISPLAY 'B=' B.
     DISPLAY 'C=' C.

    STOP-RUN.


Could someone please tell me what the output of the code posted above would be?
Back to top
View user's profile Send private message

Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Oct 24, 2007 4:20 pm    Post subject: Reply to: doubt in movement of alpha to numeric
Reply with quote

sandy,

Quote:
Could someone please tell me what the output of the code posted above would be?


Why don't you post the output with the queries?
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Wed Oct 24, 2007 4:21 pm    Post subject:
Reply with quote

What is the output you are getting? Post the same here.
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Wed Oct 24, 2007 4:24 pm    Post subject:
Reply with quote

Hi aaru,

The output i got was this....

A = ABCDE
B = ABCD5
C = 22345

I dont understand how i got that. Should it not give a S0C7? Does a S0C7 occur during a 'MOVE' of alphanumeric to numeric or during Arithmetic operations on Numerics( that already contain Alphanumeric values )?? Could you please clear this doubt of mine...
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Oct 24, 2007 4:24 pm    Post subject: Reply to: doubt in movement of alpha to numeric
Reply with quote

sandy,

The MOVE will happen fine and there wont be any compilation error. But the alphabets would have been compared to integers as the destination field is numeric. A numeric data item cannot have alphanumeric data.

Please refer to the manuals as to why this is happening.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Oct 24, 2007 4:36 pm    Post subject: Reply to: doubt in movement of alpha to numeric
Reply with quote

Searched and found a similar topic discussed.

http://ibmmainframes.com/viewtopic.php?t=6130
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 24, 2007 7:49 pm    Post subject:
Reply with quote

Hello,

When moving pic x fields to some numeric field, it is a good idea to verify that the pic x fields contains valid numeric data.

What happens all tooo often is that some piece of code "works" during testing and later abends or gives unexpected/wrong results in a production execution.

For example, try using STUVW instead of ABCDE and notice what happens. . .
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Thu Oct 25, 2007 10:11 am    Post subject:
Reply with quote

Hi guys, Thanks a lot for explaining...I got it. It treats the values as a numeric and adds the values. 'A' was taken as C1 and so on. So i got the output of 22345. I got it now. Thanks a lot..
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Oct 25, 2007 12:01 pm    Post subject:
Reply with quote

sandy_venkat

Have this attacment reference table with you, this will help you.

dick
Can we have this attachment sticky, because this is the 2 and or 3rd time that i am attaching this. icon_exclaim.gif
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Thu Oct 25, 2007 12:32 pm    Post subject:
Reply with quote

thanks a lot krisprems. This is indeed very useful
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Oct 25, 2007 12:39 pm    Post subject:
Reply with quote

Enjaay! icon_kidra.gif
Back to top
View user's profile Send private message
Shanti

New User


Joined: 19 Jun 2007
Posts: 8
Location: hyderabad

PostPosted: Fri Oct 26, 2007 12:57 pm    Post subject:
Reply with quote

Hi Krisprems,

Could you please explain the chart that you posted. Its a bit confusing.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 26, 2007 8:06 pm    Post subject:
Reply with quote

Hello,

The chart posted shows whether a move from one format to another is valid.

Pick your sending and receiving field types on the chart (say source = "numeric integer" and destination = "alphabetic) and follow the lines for each in the diamond until they intersect. The Y or N tells whether the move is valid or not. In the example i used, the move is not valid, therefore the N at the intersection.

The chart is in the COBOL manual.

Quote:
For example, try using STUVW instead of ABCDE and notice what happens. . .
I still suggest you do this as well.
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
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us