Application Development and Automation 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: 
Read only

Read table

Former Member
0 Likes
641

hi experts,

i need to change loop with READ table.

Loop at vit_fil.

Loop at vit_tab where loc = vit_fil-loc AND

( matnr = vit_fil-mat OR matnr = ' ' ).

endloop.

if sy-subrc <> 0.

Delete vit_fil.

endif.

endloop.

thanks in advance.

Bijal

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
620

hi,

Check thsi code

Loop at vit_fil.
  lv_tabix = sy-tabix.
  clear vit_tab.
  read table vit_tab with key loc = vit_fil-loc.
  if sy-subrc ne 0.
    if not ( vit_tab-matnr eq vit_fil-mat or vit_tab-matnr = ' ' ).
      delete vit_fil index lv_tabix.
    endif.
  endif.

endloop.

Regards

Sailaja.

8 REPLIES 8
Read only

alex_m
Active Contributor
0 Likes
620

Loop at vit_fil.

Read table vit_tab with key loc = vit_tab-loc

matnr = vit_tab-matnr.

if sy-subrc <> 0.

Delete vit_fil index sy-tabix..

endif.

endloop.

Read only

former_member491305
Active Contributor
0 Likes
620

Loop at vit_fil.

read table vit_tab with key loc = vit_fil-loc matnr = vit_fil-mat binary search.

if sy-subrc ne 0.

read table vit_tab with key loc = vit_fil-loc matnr = ' ' binary search.

if sy-subrc <> 0.

Delete vit_fil.

endif.

endif.

endloop.

Read only

Former Member
0 Likes
620

Hi,

Try this:

Loop at vit_fil.
read table vit_tab with key loc = vit_fil-loc 
 and  matnr = vit_fil-mat OR matnr = ' ' .

if sy-subrc <> 0.
Delete vit_fil.
endif.

endloop.

Jogdand M B

Read only

Former Member
0 Likes
621

hi,

Check thsi code

Loop at vit_fil.
  lv_tabix = sy-tabix.
  clear vit_tab.
  read table vit_tab with key loc = vit_fil-loc.
  if sy-subrc ne 0.
    if not ( vit_tab-matnr eq vit_fil-mat or vit_tab-matnr = ' ' ).
      delete vit_fil index lv_tabix.
    endif.
  endif.

endloop.

Regards

Sailaja.

Read only

Former Member
0 Likes
620

Hi Bijal,

Read is used to retrieve the value from the internal table and DB taable..But read all the time will only retrieve one value at a time...

READ table INT_Table into Workarea index 2.

-->It will take the second values from the table...

If we want to retrieve a name means

READ table INT_Table into Workarea with key name = 'XXX'.

If there is more than one name we want to put in to loop which the first answer tells u..

REWARD if useful

Read only

Former Member
0 Likes
620

hi,

in read statement u are not able to put logical operations.by default it peforms AND.

Loop at vit_fil.

read table vit_tab with key loc = vit_fil-loc

matnr = vit_fil-mat

matnr = ' ' .

if sy-subrc <> 0.

Delete vit_fil index sy-tabix.

endif.

endloop.

Read only

Former Member
0 Likes
620

hi,

Loop at vit_fil .

read table vit_fil with key loc = vit_fil-loc.

if sy-subrc ne 0.

read table vit_tab with key matnr = vit_fil-matnr

if sy-subrc ne 0.

read table vit_tab with key matnr = ''.

if sy-subrc <> 0.

Delete vit_fil.

endif.

endif.

endif.

endloop.

Reward with points if helpful.

Message was edited by:

Vinutha YV

Message was edited by:

Vinutha YV

Read only

0 Likes
620

hi,

to make the whole thing faster do binary search on every read with key statement, e.g.:

<b>READ TABLE vit_fil WITH KEY loc = vit_fil-loc BINARY SEARCH.</b>

Remember to Sort vit_fil by loc before that:

<b>SORT vit_fil BY loc.</b>

Please reward points, if helpful!