View previous topic :: View next topic
|
Author |
Message |
priyamnavada
New User
Joined: 24 Dec 2005 Posts: 52 Location: hyderabad
|
|
|
|
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 |
|
|
ParagChouguley
Active User
Joined: 03 Feb 2007 Posts: 175 Location: PUNE(INDIA)
|
|
|
|
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 |
|
|
saiprasadh
Active User
Joined: 20 Sep 2006 Posts: 154 Location: US
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
priyamnavada
New User
Joined: 24 Dec 2005 Posts: 52 Location: hyderabad
|
|
|
|
Thanks saiprasadh,
I tried your code. Its working now.
Thank U very much.. |
|
Back to top |
|
|
|