简体   繁体   English

IBM ILE RPG-清除时间字段

[英]IBM ILE RPG - Clear time fields

How can I clear (reset) a field defined as type TIME ? 如何清除(重置)定义为TIME类型的字段?

I have already tried to MOVEL *BLANKS or Z-ADD *ZEROS , but I always get an error. 我已经尝试过MOVEL *BLANKSZ-ADD *ZEROS ,但是我总是遇到错误。 When using *ZEROS the compiler tells me that the field is not numeric. 使用*ZEROS ,编译器会告诉我该字段不是数字。 While using MOVEL *BLANKS I get an error that factor 2 is invalid for this operation. 使用MOVEL *BLANKS ,出现错误,指出因子2对此操作无效。

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. 我个人只是使​​用CLEAR操作数,或者您可以将EVAL与%TIME BIF一起使用。 Either of the 2 statements below would accomplish this task. 下面的2条语句中的任何一条都可以完成此任务。

 D  TIME           S               T

 C                   CLEAR                   TIME

 C                   EVAL      TIME = %TIME('00000000')

You have 3 options: 您有3种选择:

      /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. 您也可以采用固定格式,但是看到您指的是RPGLE,我建议您开始远离固定格式。

Edit 编辑

The OP uses fixed format so here is the reference to the opt-code documentation: CLEAR OP使用固定格式,因此此处是对选择代码文档的引用: CLEAR

So just put the time variable in the result field and you'll be fine. 因此,只需将时间变量放在结果字段中 ,就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM