MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

data conversion

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
radham
Beginner


Joined: 04 Nov 2005
Posts: 7
Topics: 4

PostPosted: Fri Nov 04, 2005 7:48 am    Post subject: data conversion Reply with quote

hi can u plzz tel me how to convert alphanumeric datatype to numeric and vice versa in COBOL.i also need the syntax
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Nov 04, 2005 8:06 am    Post subject: Reply with quote

Radham,

Code:

1. Please search before posting.
2. Please do not post the same question more than once.



Check these links which discusses moving alphanumeric to numeric items(assuming the language is cobol)

http://mvsforums.com/helpboards/viewtopic.php?t=3540&highlight=alphanumeric

http://mvsforums.com/helpboards/viewtopic.php?t=3568&highlight=alphanumeric

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
radham
Beginner


Joined: 04 Nov 2005
Posts: 7
Topics: 4

PostPosted: Sun Nov 06, 2005 11:23 pm    Post subject: Reply with quote

thanks kolusu

i want to know----if we can know the length of the numeric data stored in the alphanumeric field.

for example.....if a variable declared as x(10) has a value '5000'......can we know its length.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Nov 07, 2005 4:20 am    Post subject: Reply with quote

Radham,

Quote:

----if we can know the length of the numeric data stored in the alphanumeric field


Well, alphanumeric field does not distinguish data by any class - Pure numeric, Alpha, Special characters. It just stores the data in the same format as you pass to it.

whatever be the data, the Alphanumeric field stores the bytes from Left (Left aligned). So you will have 6 spaces after 5000 (like this: "5000______". You can find the length in many ways.

1. Using INSPECT - TALLYING
Code:

Example:
       WORKING-STORAGE SECTION.
       01  WS-ALPHA       PIC  X(10)  VALUE '5000'.
       01  WS-CNT          PIC  S9(04) COMP.
       
       PROCEDURE DIVISION.
       MAIN-LINE.
            INSPECT
                 WS-ALPHA
            TALLYING
                 WS-CNT
            FOR LEADING SPACE.
           
            COMPUTE WS-CNT = WS-CNT - 1.
            DISPLAY 'LENGTH OF VARIABLE: ' WS-CNT


The above code, scans the alphanumeric field - byte by byte for "Leading" blank character and stores the offset into WS-CNT. You will get the length of your field when you subtract 1 from this offset.

2. Use the LENGTH function available in Language Environment. This question is already been discussed so many time. check the following links.

http://www.mvsforums.com/helpboards/viewtopic.php?t=1282&highlight=length
http://www.mvsforums.com/helpboards/viewtopic.php?t=525&highlight=length

Hope this helps,

Thanks,
Phantom
Back to top
View user's profile Send private message
radham
Beginner


Joined: 04 Nov 2005
Posts: 7
Topics: 4

PostPosted: Mon Nov 07, 2005 7:58 pm    Post subject: Reply with quote

thanks a lot....it was helpful
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group