‎2016 May 12 1:18 PM
Hi all,
we got a strange syntax error while using the function line_exists() inside the COND-operator. Here is the generalized coding therefore (rf_result is of type ABAP_BOOL):
rf_result = COND #( WHEN iv_id IS INITIAL THEN abap_false ELSE line_exists( mt_data[ id = iv_id ] ) ).
The syntax check says: line_exists is not a field
I expected that the statement uses the boolean result of the function line_exists and returns it.
We currently use as workaround the function xsdbool() surrounding the function line_exists().
Is this an error or do I something miss? Has someone an explanation about the behavior or an idea?
Regards,
Armin
PS: system status = NW 7.4 SP08
‎2016 May 12 2:16 PM
Hello Armin,
line_exists( ... ) is a predicate in the same sense as IS INITIAL (one is a predicate function, the other a predicate expression).
You wouldn't write ELSE IS INITIAL either.
Unfortunately, ABAP does not support a real Boolean type (the old discussion) and you can use logical expressions and especially predicate expressions or predicate functions only in positions for logical expressions (e.g. behind IF or WHEN). But we don't have fields of that type.
Yes, xsdbool is one of the workarounds to convert the result of a logical expression into a type that can be used for a field.
Best
Horst
‎2016 May 12 2:16 PM
Hello Armin,
line_exists( ... ) is a predicate in the same sense as IS INITIAL (one is a predicate function, the other a predicate expression).
You wouldn't write ELSE IS INITIAL either.
Unfortunately, ABAP does not support a real Boolean type (the old discussion) and you can use logical expressions and especially predicate expressions or predicate functions only in positions for logical expressions (e.g. behind IF or WHEN). But we don't have fields of that type.
Yes, xsdbool is one of the workarounds to convert the result of a logical expression into a type that can be used for a field.
Best
Horst
‎2016 May 12 2:48 PM
Hi Horst,
ahh, I got it. Thank you very much for the explanation.
Regards,
Armin
‎2016 May 12 4:34 PM
PS: xsdbool is the correct wrapper to produce a pseudo boolean of type c length 1, as ABAP_BOOL. boolc returns a string that is OK for assignments as you do it here, but can make problems in comparisons.
‎2016 May 13 7:51 AM
Good hint. We already decided to use only xsdbool() to avoid a mixture.