Skip to Content
-1

New COND statement; how to not change value?

Apr 18, 2017 at 07:09 AM

75

avatar image

Hi,

I have an itab with a color-field, and I use several cond-statements to fill it. However, It gets reset each time the cond statement is false. Is it possible to come around this?

" Menge

<gs_data>-cc = COND #( WHEN l_menge_i <> l_menge_p THEN VALUE #( BASE <gs_data>-cc( fname = 'MENGE' color-col = '3' color-int = '1' ) ) ).

" Wmnge

<gs_data>-cc = COND #( WHEN l_wmnge_i <> l_wmnge_p THEN VALUE #( BASE <gs_data>-cc( fname = 'WMNGE' color-col = '3' color-int = '1' ) )

In my exampe table CC is filled in first statement, but when statement is false for WMNGE, the table is cleared.

I've added a second base-statement, and that seems to work, but it appends a blank line to the table.

(...)
WHEN l_wmnge_i = l_wmnge_p THEN VALUE #( BASE <gs_data>-cc ( ) ) ).

Is there anyway that the CC-table remains untouched when the COND-statement is false?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Armin Beil
Apr 18, 2017 at 07:33 AM
0

Hello Per,

since it's an value assignment I think you need the else part

<gs_data>-cc = COND #( WHEN ... THEN ... ELSE <gs_data>-cc ).

But personally I'd prefer the straight forward IF in this case due to readability.

IF l_menge_i <> l_menge_p.
  <gs_data>-cc = VALUE #( BASE ... ).
ENDIF.

Best regards,
Armin

Share
10 |10000 characters needed characters left characters exceeded
Horst Keller
Apr 18, 2017 at 08:57 AM
0
Share
10 |10000 characters needed characters left characters exceeded