The TOHEX() built-in function returns 2 hexadecimal characters the represent each single character of parameter 1.
The ISHEX() passes the first parameter to the cvthc MI instruction. That instruction "unfolds" the characters; creating 2 hexadecimal bytes for each single byte of parameter 1. For example, the string '38' is translated to 'F3F8'.
SELECT SUBSTR(data,21,5) INTO &AMTDUE
FROM CUSTMAST
WHERE CUSTNO = 12;
eval &CustData = toHex(&amtDue);
if (&custData = '4040404040');
#msg This customer has a decimal data error (blanks) in the Amount Due column
else;
// continue normally
endif;
The legacy file CUSTMAST has some "program described" data. We extract positions 21 to 26 which should have the amount due as a packed field. If it is all banks (x40) a message is sent and the request ends. Otherwise it continues normally.