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 use a specific column in an internal table without looping?

walkerist
Participant
0 Kudos
411

HI, currently this is my code and it works, however I want to add a filter using the internal table IT_LIPS. Specifically the LFIMG field of it. Can I do it without looping? The reason I don't want to loop because when it loops, it satisfies the conditions and some entries in IT_RECORDS were deleted when it shouldn't.


Current code:
LOOP AT it_vbap ASSIGNING FIELD-SYMBOL(<lfs_it_vbap>).
IF it_records IS NOT INITIAL.
CHECK line_exists( it_records[ vbeln = <lfs_it_vbap>-vbeln
posnr = <lfs_it_vbap>-posnr ] ).
DELETE it_records
WHERE vbeln = <lfs_it_vbap>-vbeln
AND posnr = <lfs_it_vbap>-posnr.
ENDIF.
ENDLOOP.
This is want I want to happen:
LOOP AT it_vbap ASSIGNING FIELD-SYMBOL(<lfs_it_vbap>).
IF it_records IS NOT INITIAL.
CHECK line_exists( it_records[ vbeln = <lfs_it_vbap>-vbeln
orqty = IT_LIPS-LFIMG <--------------Is it possible to insert this?
posnr = <lfs_it_vbap>-posnr ] ).
DELETE it_records
WHERE vbeln = <lfs_it_vbap>-vbeln
AND orqty = IT_LIPS-LFIMG <--------------Is it possible to insert this?
AND posnr = <lfs_it_vbap>-posnr.
ENDIF.
ENDLOOP.
2 REPLIES 2

ThorstenHoefer
Active Contributor
0 Kudos
359

Hi,

can you use something like this?

data: lt_records like it_records[].
loop at it_records assigning field-symbols(<wa_record>). 
  read table it_vbap transporting no fields with key " or with table 
    FIMG = <wa_record>-orqty
    posnr = <wa_record>posnr.
  check sy-subrc is not initial.
  insert <wa_record> into table lt_records.
endloop.

Sandra_Rossi
Active Contributor
0 Kudos
359

You didn't explain how IT_LIPS is related to the internal tables IT_VBAP and IT_RECORDS.