Packed Decimal Field - Can we turn off Sign Bit?


May I know whether is it possible to turn off the sign bit for Packed Decimal field say a field declared as #sal (p8.2)?

I tried using SG=off, but gives NAT1125 error.


SG doesn’t turn off the half byte for the sign. It only turns off the printing of the sign.


define data local
1 #sal (P8.2) init <1>
write #sal (SG=OFF)
add 1 to #sal
write #sal (SG=OFF)

Hi Matthias,

  1. #sal (p8.2)

input #sal

Output - It allows user to enter 12 digits

  1. #sal (n5)
    input # sal

Output - It allows user to enter 6 digits

  1. #sal (n5)
    input #sal (sg=off)

Output - It allows user to enter only 5 digits (i.e as per it’s length)

  1. #sal(p8.2)
    input #sal(sg=off)

Output - It still allows user to enter 12 digits,where as I wanted to restrict user to 11 digits. Is this possible?

Does this mean

On my system (Solaris), this input statement allows 11 digits (to have enough space for the decimal point). So everything is Ok, isn’t it? :?:

Hi Matthias,

Oh is it. I am using Software AG Natural Studio Version 6.3.4 on windows and I get NAT1125 error as soon as I enter the 11th digit.


Education, Education, Education.

P8.2 means a variable with eight digits before and two digits after a decimal point.

I am running 6.3.5 (do not have .4 on machine anymore.

You should not be getting a Nat 1125 when entering an 11th digit. For example, I can enter 12345678.123 Natural will ignore the 3 at the end.

HOWEVER, you cannot enter 123456789.1 This gets you the 1125, which is proper. Natural feels it cannot eliminate anything before the decimal point.

Similarly, Natural will not allow you to MOVE a P9.2 variable to a P8.2 variable if the P9.2 variable has a value such as 123456789.12. Natural will allow such a MOVE (NAT 1305).

All of which makes perfect sense.


The only thing which doesn’t make perfect sense to me: SG=OFF doesn’t cause an error, if the value is negative. You can even enter a negative value without getting an error. But OK, it’s documented in the natural parameter reference.

Yes. For both Input and Output, SG only refers to the extra space; it never refers to whether a negative value is valid or not.

I always thought the documentation should have more of a warning than it does with regard to this parameter.

With SG=OFF, a negative number will be written without a sign ; and, as observed, on INPUT with SG=OFF, you can still enter a negative number.

I have seen code where negative values were to be treated as invalid. The programmer used SG=OFF, and did not have a validation test such as


A maintenance programmer had spent 3 days trying to find a bug that resulted from having a negative value in #INPUT. Probably went to the same class as the original programmer :frowning:

And that’s different to the logic of NL.

Try this:

define data local
01 #sal (P8.2)
input #sal (SG=OFF NL=3.1)
write #sal

-123 is OK
1234 causes NAT1125

You get the same error message with SG=ON NL=3.1 when you try to enter 1234.

This is correct. NL=3.1 checks to make sure there are not greater than three digits before the decimal point. The NAT1125 has nothing to do with SG.


Hi Steve!

As always thanks for your help.

I always thought NAT1125 is related to SG, hence this question.Thanks for the clarification though.

But I would like to address an issue. The query I posted is under “Natural Baiscs on Mainframes”, there is nothing harm in learning something new and clarifying doubts right?. Hence would appreciate if you can be little easy/placid with your words/replies. I am an expert on Cobol-DB2, and learning Natural and being new with the technology such queries are bound to arise. And again I post queries when I dont get some quick answers from my peers,reference documents and self-trial. These may sound silly to people/you but may not necessarily be silly for a beginner.

Good Day.

I think Steve