2024 Jun 25 11:12 AM - edited 2024 Jun 25 11:14 AM
I was exploring the new system class CL_ABAP_DIFF which detects differences between internal tables. According to the documentation, its return value is a diff table, to be understood as a sequence of instructions that have to be applied to the source table in order to get the target table.
Unfortunately, my naïve approach to write a `patch` algorithm for applying the diff data to the source table doesn't work.
loop at lt_diff assigning field-symbol(<ls_diff>).
case <ls_diff>-operation.
when cl_abap_diff=>s_operation-delete.
delete lt_source index <ls_diff>-source_line_number.
when cl_abap_diff=>s_operation-insert.
insert lt_target[ <ls_diff>-target_line_number ]
into lt_source index <ls_diff>-source_line_number.
when cl_abap_diff=>s_operation-update.
modify lt_source
from lt_target[ <ls_diff>-target_line_number ]
index <ls_diff>-source_line_number.
endcase.
endloop.
Any suggestions how to fix this patch algorithm so that after the loop we have lt_source = lt_target?
Request clarification before answering.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.