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
 

 

Problem with the packed decimal

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

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Wed Jul 18, 2007 1:24 pm    Post subject: Problem with the packed decimal
Reply with quote

Is there any way to convert alphanumeric to packed decimal in a COBOL program. It can be solved through sort but i want it in a COBOL program.

For Ex: I have an alphanumeric variable of length X(06). it should be moved to packed decimal of variable S9(05) COMP-3 and the output should be well displayed.

Is this possible through COBOL program?
Back to top
View user's profile Send private message

ParagChouguley

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Wed Jul 18, 2007 1:41 pm    Post subject:
Reply with quote

Hi,
I am wondering if you could really do that. As far as I know, COMP-3 can hold signed numerics only.

--Parag
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Wed Jul 18, 2007 1:43 pm    Post subject:
Reply with quote

Hi Priya,

Try the below code

Code:
WORKING-STORAGE SECTION.                                     
01 WS-DEC-TEXT  PIC X(10).                                   
01 WS-WHOLE     PIC S9(3)V9(2) COMP-3.                       
PROCEDURE DIVISION.                                         
       MOVE '10.00'  TO WS-DEC-TEXT.                         
       DISPLAY 'WS-DEC-TEXT  :'WS-DEC-TEXT.                 
       COMPUTE WS-WHOLE = FUNCTION NUMVAL(WS-DEC-TEXT).     
       DISPLAY 'WS-WHOLE  :'WS-WHOLE.                       
      EXIT.                                                 
      STOP RUN.     


Thanks
Sai
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Jul 18, 2007 2:34 pm    Post subject: Re: Problem with the packed decimal
Reply with quote

priyamnavada wrote:
Is there any way to convert alphanumeric to packed decimal in a COBOL program. It can be solved through sort but i want it in a COBOL program.
MOVE alphanumeric-data TO packed-decimal-data.
You are responsible for the sending data being numeric.
When the sending item is alphanumeric, the data is moved as if the sending item were described as an unsigned integer.
Doesn't anybody read manuals?
Back to top
View user's profile Send private message
priyamnavada

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Wed Jul 18, 2007 4:00 pm    Post subject:
Reply with quote

Thanks saiprasadh,

I tried your code. Its working now.

Thank U very much..
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 READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm


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