Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6201559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:34:36+00:00 2026-05-24T04:34:36+00:00

I will read a sequential file which include some string such as 79.85, 1000,

  • 0

I will read a sequential file which include some string such as “79.85”, “1000”, “212.34”.

I want to convert the alphanumeric into number in this format 00000.00 ?

I will need to add up these numbers and move it to a field in the format 0000000.00 .

I tried:

01 WS_AMOUNT_TXT                                PIC X(8).
01 WS_AMOUNT                                    PIC 9(5).9(2).

MOVE WS_AMOUNT_TXT(1:8) TO WS_AMOUNT(1:8).

What I got is unexpected, the string is just as same. It is left align and no leading zero display.

How can I made it right align and have leading zero?

EDIT: I tried the suggestion by NealB, and it sadly failed:

01 WS_AMOUNT_NUM                                PIC 9(5)V9(2).
01 WS_AMOUNT_DISPLAY                            PIC 9(5).9(2).
01 WS_AMOUNT_TXT                                PIC X(8).


        DISPLAY WS_AMOUNT_TXT

        COMPUTE WS_AMOUNT_NUM = FUNCTION NUMVAL (WS_AMOUNT_TXT)
        MOVE WS_AMOUNT_NUM TO WS_AMOUNT_DISPLAY

79.85 << this is what was displayed when I called DISPLAY WS_AMOUNT_TXT
AND THEN IT CRASHED.

%COB-F-NUMVALARGINV, NUMVAL or NUMVAL-C argument invalid
%TRACE-F-TRACEBACK, symbolic stack dump follows
image module routine line rel PC abs PC
DEC$COBRTL 0 000000000001F2B8 000000007C2F72B8
DEC$COBRTL 0 0000000000014764 000000007C2EC764
DEC$COBRTL 0 0000000000014C44 000000007C2ECC44
DAILY_SPLIT_REFUND_ADJ DAILY_SPLIT_REFUND_ADJ DAILY_SPLIT_REFUND_ADJ
121 00000000000003C4 00000000000303C4
DAILY_SPLIT_REFUND_ADJ 0 00000000000313A0 00000000000313A0
0 FFFFFFFF80271EF4 FFFFFFFF80271EF4

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:34:36+00:00Added an answer on May 24, 2026 at 4:34 am

    Try using the intrinsic function NUMVAL
    to do the conversion. Something like…

        01 WS-AMOUNT-TEXT     PIC X(8).  
        01 WS-AMOUNT-NUM      PIC 9(5)V9(2).  
        01 WS-AMOUNT-DISPLAY  PIC 9(5).9(2).  
    
        COMPUTE WS-AMOUNT-NUM = FUNCTION NUMVAL (WS-AMOUNT-TEXT)  
        MOVE WS-AMOUNT-NUM TO WS-AMOUNT-DISPLAY  
    

    NUMVAL converts the text representation of a number into a numeric type. Use the numeric data type: PIC 9(5)V9(2) in your calculations. Then use MOVE
    to convert the numeric result into a displayable amount with explicit decimal point.

    Note: If you have a lot of calculations to perform, it might be best to use a PACKED-DECIMAL data type to improve efficiency.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a program that will read some number in string format
I'm trying to write a stored procedure that will read an Excel file into
I would like to write a function which will read values from a text
I want to write a program in C/C++ that will dynamically read a web
I am doing a google map which will read a set of coordinates and
I want to make a Servlet filter that will read the contents of the
In C++, I want to sequentially read word from a text file, and store
I want to make a CListView that will read his rows from e remote
I am developing a photo gallery which will read/write EXIF tags. I will put
I have quickly read (and will read with more care soon) the article of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.