Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Compare two internal tables and list / show the differences

Dear forum members,

I might need some help: I`m filling two internal tables from database tables. I have to see whether there are differences in the two tables or not. To make it clear: I need to know if the entries for the field VKONT of the table DFKKOP are also existing in the table FKKVKP.

Now it`s not a problem to bring the entries into a internal table, but I don`t know how to compare my two tables and list the differences. Here`s the code:

DATA: wa_vkont TYPE dfkkop-VKONT,

wa_vkfkkvkp TYPE fkkvkp-vkont,

n_vorhfkkvkp TYPE string.

TYPES: wa_vkont2 TYPE dfkkop-VKONT.

DATA: lt_dfkkop TYPE TABLE OF wa_vkont2,

  • lt_dfkkop TYPE TABLE OF dfkkop,

lt_fkkvkp TYPE TABLE OF wa_vkont2,

  • lt_fkkvkp TYPE TABLE OF fkkvkp,

wa_dfkkop like LINE OF lt_dfkkop,

wa_fkkckp LIKE LINE OF lt_fkkvkp.

SELECT-OPTIONS: s_vkont FOR wa_vkont,

f_vkont FOR wa_vkfkkvkp.

select vkont from dfkkop INTO TABLE lt_dfkkop

WHERE vkont IN s_vkont.

SORT lt_dfkkop ASCENDING.

Delete ADJACENT DUPLICATES FROM lt_dfkkop.

select vkont from fkkvkp INTO TABLE lt_fkkvkp

WHERE vkont IN f_vkont.

SORT lt_fkkvkp ASCENDING.

Delete ADJACENT DUPLICATES FROM lt_fkkvkp.

Former Member
Not what you were looking for? View more on this topic or Ask a question