1

This may be a very basic question for COBOL experts. But I till date had nothing to do with COBOL. We are processing some files based on character position. The files are being sent to us from mainframe machines and we have a layout file for that that says somethings like this.


POSITION : LENGTH : TYPE : DESCRIPTION
----------:--------:------:-------------------------------

61-70 : 10 : P5 : FIELD-1 9(13)V(05)

71-80 : 10 : P5 : Field-2 9(13)V(05)

81-81 : 1 : A/N : FLAG

82-84 : 3 : N : NUMBER OF DAYS 9(3)

I understand that the type A/N means it is alpha-numeric. N means numeric and P means Packed data type. What i dont understand is what P5 means. What is the significance of 5 that comes next to P?

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47

3 Answers3

1

What is the significance of 5 that comes next to P?

I'm not sure. Five 16 bit words, maybe.

Your packed fields are 10 bytes and holding 19 characters (18 digits plus the sign). The decimal point is implied.

If the sign byte (the rightmost byte) is anything other than hexadecimal F, update your question.

If you could update your question with five hexadecimal strings representing five of the numbers, that would be great.

Right now, I'm guessing that it's an ordinary packed decimal field.

Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
1
  • P - packed decimal (i.e. Cobol Comp-3) a 18 digit packed decimal would occupy 10 bytes which agrees with the lengths give

  • 5 - number of digits after the decimal point (at a guess).

Field definition in cobol is probably

   03 FIELD-1  pic s9(13)V(05) comp-3.

in packed decimal, the sign is held in the last nyble (4 bits) and each nyble (4 bits) holds one decimal digit.

i.e.

   121 is represented as x'121c'

while

  -121 is represented as x'121d'

If you are using java and can get the cobol copybook, there are packages that can read the file using the cobol copybook.

Bruce Martin
  • 10,358
  • 1
  • 27
  • 38
1

I would bet it means 5 decimal places.

mswanberg
  • 1,285
  • 8
  • 20