tags:

views:

619

answers:

1

Hello,

I have a fixed width text file, which has been unpacked from Comp-3 data into fixed width strings.

I need to know how to interpret the following fields:

FIELD-NAME-1 PIC S9(15)V9(3) COMP-3.
FIELD-NAME-2 PIC S9(3)V9(8) COMP-3.
FIELD-NAME-3 PIC S9(3)V9(6) COMP-3.

These appear in my flat file as:

FIELD-NAME-1 0123456789123456780
FIELD-NAME-2 01234567890
FIELD-NAME-3 012345670

I need to know what numbers the above would represent.

Is this correct:

FIELD-NAME-1 123456789123456.780  --> The first 0 means +ve?
FIELD-NAME-2 012.34567890
FIELD-NAME-3 012.345670

Thanks for the help. Ham

A: 

The S9(15)V9(3) requires 19 nybbles (20 in reality since it must make an even number of nybbles) to store:

  • one for the sign.
  • 15 for the integer bit.
  • 3 for the non-integer bit (V is an implied decimal, not a real one).

The sign usually appears at the end as a C or a D nybble so the answer to this question depends entirely on what did the unpacking.

Your first example actually has the right number of digits without the sign so I'd be concerned with your statement that one of them represented the sign. Either that, or you've left off the "9". The other two examples have enough digits for both the sign and numeric part.

Best bet, see if you can get a negative number (and other test data like 1) into there to see what it generates.

paxdiablo
Hi Pax,Thanks for the help. As a further issue, the case you answered makes sense, as there are 19 charachters for that field. However, for Field Name 2 and 3 respectively, there are only 11 and 9 charachters. Does this mean there is no charachter for the sign?Thanks again,Ham.
No idea, sorry, Ham. As I said, it depends on what did the unpacking. I've written code before to handle comp-3 in raw form which is why I'm familiar with the format. If you could find even *one* value that didn't start or end with 0, that would give you a high probability as to how it works. Where did the files come from? Maybe the source can help you out with the format.
paxdiablo
Can you post a few actual lines of the flat file? Make sure spaces are preserved, including any at the start and end of a line.
paxdiablo
Hello. Sorry for being dense, but I don't understand how for example 3, it contains enough information:FIELD-NAME-3 012345670Is this: 123.45670 or 012.345670? Or something else?Thanks again.
Ok, thanks Pax. You're right, I need more information from the file providors before I can proceed with certainty. I will take a look through the raw files and see if I can find a non-0.Thanks for your time.
Ham, what I was saying was that "012345670" (9 digits) can hold the 9(3)V9(6) but not the S. That's assuming it's a straight conversion from the nybbles. It may be that negative numbers have the initial (or final) digit modified somehow. But in that case, the first example has more digits than is required. Hence more info required. I'll keep an eye on the comments here, let me know if you find some more info and I'll be happy to help further.
paxdiablo