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 SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm


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