Search code examples
ibm-midrangerpgle

IBM ILE RPG - Clear time fields


How can I clear (reset) a field defined as type TIME?

I have already tried to MOVEL *BLANKS or Z-ADD *ZEROS, but I always get an error. When using *ZEROS the compiler tells me that the field is not numeric. While using MOVEL *BLANKS I get an error that factor 2 is invalid for this operation.


Solution

  • You can't move blanks or zeros to a time field -- you have to move a time. I personally would just use the CLEAR operand, or you could use EVAL along with the %TIME BIF. Either of the 2 statements below would accomplish this task.

     D  TIME           S               T
    
     C                   CLEAR                   TIME
    
     C                   EVAL      TIME = %TIME('00000000')