Skip to Content
-1

New COND statement; how to not change value?

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Apr 18, 2017 at 07:33 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 18, 2017 at 08:57 AM
    Add comment
    10|10000 characters needed characters exceeded