gpt4 book ai didi

abap - 如何在 IF 条件下使用 ABAP bool 值?

转载 作者:行者123 更新时间:2023-12-04 03:04:32 27 4
gpt4 key购买 nike

我知道 abap 没有真正的 bool 类型。而是使用“X”和“”。到目前为止,我总是这样使用 if 语句:

IF myObj->is_sth( ) = abap_true.

ENDIF.

现在我做了这样的事情:

IF myObj->is_sth( ).

ENDIF.

我想知道这似乎行得通。返回类型是 bool 值。我在 Netweaver 7.4 上。我可以毫无问题地使用它吗?这就像我可爱的 ​​C# 写作 :p。

最佳答案

这叫做 predicative method call :

A predicative method call is a relational expression whose only operand is a functional method call meth( ... ). The result of the relational expression is true if the result of the functional method call is not initial and false if the result of the functional method call is initial. The result of the functional method call (the return value of the called function method) can have any data type. A check is made on the type-friendly initial value.

A predicative method call, like any relational expression, can be a full logical expression or part of a logical expression. This means it can be specified as a condition in control statements and other statements, as an argument in Boolean functions or conditional expressions, or in joins with Boolean operators.

这是 introduced in 7.40 SP08 .请注意,这仅在初始值为 false 且 false 为初始值时才可靠地工作。例如,IS-H 使用一个字符字段,其中 0 为 false,1 为 true - 但由于字符字段的初始值是一个空格,所以这既不是 true 也不是false,因此使用返回此值的任何方法将始终分支,就好像该方法已返回 true...

关于abap - 如何在 IF 条件下使用 ABAP bool 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45812905/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com