How to Convert Sign Fields to Alpha Numeric in COBOL

Written by charles carswell
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Convert Sign Fields to Alpha Numeric in COBOL
Convert internal signed decimal fields in COBOL to readable alphanumeric numbers. (F64/Digital Vision/Getty Images)

COBOL is still one of the richest and most elegant computer languages on the market. Aside from the computing power and massive file handling capabilities, you have the flexibility of number conversions and reporting. Many times you may need to display specific numerical values on output reports, files or screen display fields like CICS. Undoubtedly, you will encounter numeric formats that will not display properly as stored and will need to be further converted to a more readable format. One of the most common is the packed decimal or COMP-3 numeric field.

Skill level:
Moderately Challenging

Other People Are Reading

Instructions

  1. 1

    Identify the field(s) you wish to convert in the COBOL code. For example, you may have a field that reads similar to: "05 pkd-field-01 pic s9(5v99) comp-3." This is a signed, packed decimal field used efficiently for computations but cannot be easily read in a display.

  2. 2

    Go to the "Working-Storage Section of the program and set up the intermediate fields you will need to make the desired numeric transition as follows: create two numeric fields "05 ws-numeric pic s9(5v99) value zero," and "05 ws-display-numeric pics x(8)."

  3. 3

    Insert code in the program to move the input field directly into the first intermediary field "ws-numeric." This will unpack the comp-3 number into a zoned numeric field. In turn, have the code now move the first intermediary field into the second one, ws-display-numeric. This last field can be used to display the number either on a printed form or on a computer screen.

  4. 4

    Compile the program with the saved changes and make sure there are no errors in the compile by checking the condition code.

  5. 5

    Run the compiled version and verify the results.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.