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
 
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 Having a problem FTP'ng to the MF pahiker All Other Mainframe Topics 2 Fri Nov 10, 2017 8:20 pm
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Problem commiting to DB2 from IMS MPP Ole Soerensen IMS DB/DC 2 Wed Jul 26, 2017 5:19 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm

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