Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Dealing with Packed Numbers

Posted on 2003-03-06
Medium Priority
Last Modified: 2010-04-17
I have a file that was extracted from IBM mainframe using COBOL program. The file contains Packed Numbers.

The packed numbers are numbers stored by COBOL in a kind of compressed format to save space. For an example if we have the below row format in COBOL:

01 row01.
     03 std-name           X(10).
     03 std-age            9(8) COMP-3.

This means that, if we have a record with std-name = “Robert Lee” and std-age=6 the row will appear in the extracted file as

Robert Lee0006

Instead of

Robert Lee00000006

My problem is that, I need to read this file using VB code and convert all the numbers into normal numbers so I can store them in SQL server.

Thanks in advance

M. Fraij
Question by:mfraij

Accepted Solution

billious earned 200 total points
ID: 8083855
COMP-3 format is each digit is represented as a nybble, hence hex'37' represents 37.

Take each byte in turn, and the value represented is

10*(byte div 16) + (byte modulo 16)

EXCEPT that IF THE COMP-3 is a SIGNED field.

In this case, the last nybble may be C,D or F (byte modulo 16 = 12, 13 or 15.)

Here, C or F means POSITIVE, and D means NEGATIVE.




Expert Comment

ID: 9447309
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Starting up a Project

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question