cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How is the patch algorithm for CL_ABAP_DIFF?

Ruediger_Plantiko
Active Contributor
756

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?

Accepted Solutions (0)

Answers (0)