Skip to Content
0
Jun 16, 2021 at 08:43 AM

New Syntax - update internal table column based on comparision of two columns of same itab

327 Views

I have an internal table itab with 4 coulmns col1, col2, col3, col4.

I want to update col3 value in all records by comparing col1 and col2. i.e. if col1 <> col2 then col3 = 'X' else col3 = ' '.

I want to update col4 value in call records with difference of col1 and col2. i.e. col4 = col1 - col2.

Traditionally, it can be achieved with this code:

loop at itab assigning <fs>.
if <fs>-col1 NE <fs>-col2.
<fs>-col3 = 'X'.
endif.
<fs>-col4 = <fs>-col1 - <fs>-col2.
endloop

. Is there a way in new abap syntax to do it without loop and without using second internal table ?