on 09-27-2023 1:15 PM
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.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 )
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It worked as expected!!
didn't know the 'LINES OF' statement does this.
Thank You Sandra, new learning for me.
You can create header part as constant and add IF condition on each it_suc and it_err with logic to append entries only when the table is not initial. Something like:
et_aud = VALUE #(
( data = 'No of Successful Records: ' && |{ iv_suc }| )
( data = 'No of Failed Records : ' && |{ iv_err }| )
( data = '' ))
IF it_suc IS NOT INITIAL.
APPEND LINES OF VALUE #(
( data = '***************************************************SUCCESS RECORDS****************************************************************' )
( data = '' )
( LINES OF it_suc )
( '' ) ) TO et_aud.
ENDIF.
IF it_err IS NOT INITIAL.
APPEND LINES OF VALUE #(
( data = '***************************************************ERROR RECORDS****************************************************************' )
( data = '' )
( LINES OF it_err )
( '' ) ) TO et_aud.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.