Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete a specific entry in an internal table?

walkerist
Participant
415

I have an internal tables named it_vbap and it_lips.

I want to to delete the vbeln in the it-vbap if the it_vbap-orqty is equal to it_lips-lfimg.

4 REPLIES 4

FredericGirod
Active Contributor
330

what is your current code ?

adityaIngale
Active Participant
0 Kudos
330

Hi walkerist,

Follow Below Steps

1. Loop at your it_vbap table

2. Inside loop, use read table on it_lips

3. Then write your Required Conditoin in if Statement.

4. Inside If-else block, use delete statment on it_vbap using index sy-tabix.

former_member184158
Active Contributor
0 Kudos
330

Hi,

you can do it by using this code

LOOP AT it_lips INTO DATA(ls_lips) .
Read table it_vbap with key VBELN = ls_lips-VBELN POSNR = ls_lips-posnr orqty = ls_lips-lfimg transporting no fields.
IF SY-Subrc = 0.
DELETE it_vbap WHERE vbeln = ls_lips-vbeln and posnr = ls_lips-posnr .
ENDIF.
ENDLOOP.

330
LOOP AT it_lips INTO DATA(ls_lips) .
  CHECK line_exists( it_vbap[ vbeln = ls_lipst-vbeln
                              posnr = ls_lipst-posnr
                              orqty = ls_lipst-lfigm ).
  DELETE it_vbap WHERE vbeln = ls_lips-vbeln and posnr = ls_lips-posnr .
ENDLOOP