Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Syntax error using line_exists() inside COND-operator

Former Member
3,491

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

1 ACCEPTED SOLUTION
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
2,499

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

4 REPLIES 4
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
2,500

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

Read only

0 Likes
2,499

Hi Horst,

ahh, I got it. Thank you very much for the explanation.

Regards,

Armin

Read only

2,499

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.

Read only

0 Likes
2,499

Good hint. We already decided to use only xsdbool() to avoid a mixture.