cancel
Showing results for 
Search instead for 
Did you mean: 

COND operator adds empty lines

sh4il3sh
Participant
0 Kudos

Hi,

I am simply adding new rows to a table of type string, code below:

et_aud = VALUE #(
    ( data = 'No of Successful Records: ' && |{ iv_suc }| )
    ( data = 'No of Failed Records    : ' && |{ iv_err }| )
    ( data = '' )
    ( data = COND #( WHEN it_suc IS NOT INITIAL THEN '***************************************************SUCCESS RECORDS****************************************************************' ) )
    ( data = COND #( WHEN it_suc IS NOT INITIAL THEN '' ) ) 
    ( LINES OF it_suc )
    ( data = COND #( WHEN it_suc IS NOT INITIAL THEN '' ) )

    ( data = COND #( WHEN it_err IS NOT INITIAL THEN '****************************************************ERROR RECORDS*****************************************************************' ) )
    ( data = COND #( WHEN it_suc IS NOT INITIAL THEN '' ) )
    ( LINES OF it_err )
                    ).

for cases when IT_SUC IS INITIAL, it adds empty rows(see image) and its not required.

I cannot use Delete ITAB where rows are empty because I would need empty lines which I have added myself.

Any suggestion would be helpful.

Regards,
Shailesh
View Entire Topic
Sandra_Rossi
Active Contributor

Combine LINES OF and COND or SWITCH to choose between 0 and any number of lines:

et_aud = VALUE #(
    ( data = 'No of Successful Records: ' && |{ iv_suc }| )
    ( data = 'No of Failed Records    : ' && |{ iv_err }| )
    ( data = '' )
    ( LINES OF COND #( WHEN it_suc IS NOT INITIAL THEN VALUE #(
        ( data = '***************************************************SUCCESS RECORDS****************************************************************' ) )
        ( data = '' ) ) ) )
    ( LINES OF it_suc )
    ...
sh4il3sh
Participant

It worked as expected!!

didn't know the 'LINES OF' statement does this.
Thank You Sandra, new learning for me.