All numeric field types are basically handled the same way.
Your F spec should define the file as E (externally) defined.
The field can be used by field name, say QtyOnHnd (of course that field should never be negative)
in rpg – rpgle
If QtyOnHnd < *zero
eval errQty = *on
eval errQty = *off
To put a negative value in the field
Eval QtyOnHnd = -1
Wilson, you’re absolutely right.
There is 0% chance of getting the record structure wrong when using the external description but there are times when other strategies do apply. In this case, it didn’t appear that the question required an answer quite so complex.
– – – – – – – – –
In the RPG languages, you don’t even need to think about it. That’s why we have a compiler!
The opcodes ADD, SUB, Z-ADD, Z-SUB, EVAL – all the arithmetic, in fact, just ‘does it’
You may wish to look at edit codes for final output, though, in order to represent the negative value in human readable form, either with a negative sign, or brackets.
IF you’re really interested, the sign is stored in the high order half byte of the rightmost byte of the field. You may interrogate this, and used to have access with opcodes MVHLZ (sic) and its friends. Or you could just check the bits.
Binary negative fields?? – another question.