When coding in RPG400, the result of a calculation can be larger than the size of the result field, like this:
D Fld1 s 2 0 Inz(20)
D Fld2 s 2 0 Inz(10)
D Fld3 s 2 0 Inz
C Fld1 mult Fld2 Fld3
Fld3 will contain a value of 0 after the code is executed.
However, when coding in ILERPG:
D Fld1 s 2 0 Inz(20)
D Fld2 s 2 0 Inz(10)
D Fld3 s 2 0 Inz
C Eval Fld3 = Fld1 * Fld2
This line of code will not execute since the result of the calculation is larger than the size of the result field.
Other than increasing the size of the result field (which is not always doable), DOes anybody know if there is a way around the problem? I've had to change several programs written in free format back to RPG/400
Software/Hardware used:
ASKED:
February 27, 2009 5:34 PM
UPDATED:
March 3, 2009 5:38 PM
Actually, if I were producing an invoice, I would make sure that the result field was the proper size. My reports are receiving data pulled from a j-bus connection in commercial tractor-trailer rigs and making calculations. There are times when the data coming across are way out of whack. A zero value would indicate that there was a problem with the data coming in from the j-bus, and the rig could be pulled in for maintenance.
I would never, ever recommend going back to RPG/400 (III) just because of something like this. This is not a difference between RPG III and IV; it’s a difference in how the MOVE operation truncates data, while the EVAL operation does not. The MOVE is more forgiving, but that’s not necessarily a good thing. RPG IV still supports MOVE in the fixed format, so you could still use that operation as long as the truncation won’t cause a problem for your application. Otherwise, as Phil suggested the MONITOR operation code is quite handy.