Skip to Content

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

question about comparing 2 internal tables...

Hello experts,

I have 2 internal tables, it_ekpo and it_mseg2. now, what I want to do is delete records from itab it_ekpo that doesn't exist in itab it_mseg2. Bewlo is the code that I made. Please let me know if it's wrong or if it can be done in a better way. Thank you guys and take care!

LOOP AT it_ekpo.

READ TABLE it_mseg2 WITH KEY ebeln = it_ekpo-ebeln.

IF sy-subrc <> 0.

DELETE it_ekpo.

CLEAR it_ekpo.

ENDIF.

ENDLOOP.

Tags:
Former Member
Former Member replied

just make one more internal table it_ekpo1

of same type it_ekpo.

sort it_mseg2.

LOOP AT it_ekpo.

READ TABLE it_mseg2 binary search WITH KEY ebeln = it_ekpo-ebeln.

IF sy-subrc = 0.

it_ekpo1 = it_ekpo.

append it_ekpo1.

clear it_ekpo1.

ENDIF.

ENDLOOP.

0 View this answer in context

Helpful Answer

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