Radinator
Radinator

Reputation: 1088

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.

Upvotes: 1

Views: 826

Answers (2)

Adrian Bannister
Adrian Bannister

Reputation: 523

You have 3 options:

      /free
       timeField = *loval;
       clear timeField;
       reset timeField;
      /end-free

You can do it in fixed format as well, but seeing that you're referring to RPGLE I would recommend you start moving away from fixed format.

Edit

The OP uses fixed format so here is the reference to the opt-code documentation: CLEAR

So just put the time variable in the result field and you'll be fine.

Upvotes: 2

Rob Schember
Rob Schember

Reputation: 226

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')

Upvotes: 5

Related Questions