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

Problem with the packed decimal


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 3156
Location: Tucson AZ

PostPosted: Wed Jul 18, 2007 2:34 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
Search our Forums:

Back to Top