Return to the RPG Tips
Preventing Decimal Data Errors
Dan, if HDRSWP is a zoned value, you can get a DDE exception on the MOVEL to WORK##. Also, you should use MOVE, not MOVEL, to get the sign byte positioned correctly.
It would be easier to use RPG IV for this:
D zonedBytes s 30a based(pZonedBytes) C MOVEL *ZEROS WORK## C EVAL pZonedBytes = %ADDR(HDRSWP) C EVAL %SUBST(WORK## : %size(WORK##) - %size(HDRSWP) + 1) C = %SUBST(zonedBytes : 1 : %size(HDRSWP) C TESTN WORK## Or better, write a subprocedure: D testZoned pr 1n D pZoned * value D len 10i 0 value C eval *in91 = testZoned(%addr(HDRSWP) : %size(HDRSWP)) C eval *in91 = testZoned(%addr(HDRDTM) : %size(HDRDTM)) ... P testZoned b D testZoned pi 1n D pZoned * value D len 10i 0 value D WORK## s 30a inz(*zeros) D zonedBytes s 30a based(pZoned) D saveInd s 1n D retInd s 1n C EVAL saveInd = *IN91 C EVAL %SUBST(WORK## : 30 - len + 1) C = %SUBST(zonedBytes : 1 : len) C TESTN WORK## 91 C EVAL retInd = *IN91 C EVAL *IN91 = saveInd C RETURN retInd P testZoned eDan, I remember being surprised myself that TESTN wasn't for numeric fields, and also that when applied to character fields, TESTN couldn't test for valid packed data. It looks to me like TESTN was designed for a very specific purpose that isn't particularly relevant any more.
Barbara Morris
[report a broken link by clicking here]