‎2005 Mar 18 2:02 PM
I have a situation that I'm having trouble resolving.
I'm looping through this list, each time getting a table of keys and offsets. But each time I loop through it, I only want to retain the records that are common and get rid of new or unique records.
I'm thinking the code should be something like:
Loop at itab1.
call function ...
exporting
e_result = reference []
if count = 0.
master_list = reference.
count = count + 1.
ELSE.
DELETE FROM MASTER_LIST WHERE RECORDS DON'T MATCH UP IN reference. ???
ENDIF.
ENDLOOP.Please help out,
Natasha
‎2005 Mar 18 2:17 PM
Hi Natasha, when i read your problem i understand that you wanna do this:
Loop at itab1.
call function ...
exporting
e_result = reference []
if count = 0.
master_list = reference.
count = count + 1.
ELSE.
**-
loop at master_list.
read table reference with key FIELD = master_list-field.
if sy-subrc <> 0.
delete master_list.
endif.
endloop.
**-
ENDIF.
ENDLOOP.Is this what are you looking for?
Regards,
Carlos A. Lerzundy
‎2005 Mar 18 2:17 PM
Not the prettiest way of doing it, but here is a sample program.
report zrich_0002 .
data: begin of itab occurs 0,
field1 type c,
field2 type c,
field3 type c,
end of itab.
start-of-selection.
itab-field1 = 'A'.
itab-field2 = 'B'.
itab-field3 = 'C'.
append itab.
append itab.
itab-field1 = 'C'.
itab-field2 = 'D'.
itab-field3 = 'E'.
append itab.
itab-field1 = 'F'.
itab-field2 = 'G'.
itab-field3 = 'H'.
append itab.
append itab.
data: counter type i.
loop at itab.
clear counter.
loop at itab where field1 = itab-field1.
counter = counter + 1.
endloop.
if counter = 1.
delete itab.
continue.
endif.
endloop.
check sy-subrc = 0.
Regards,
Rich Heilman
‎2005 Mar 18 2:17 PM
Hi Natasha, when i read your problem i understand that you wanna do this:
Loop at itab1.
call function ...
exporting
e_result = reference []
if count = 0.
master_list = reference.
count = count + 1.
ELSE.
**-
loop at master_list.
read table reference with key FIELD = master_list-field.
if sy-subrc <> 0.
delete master_list.
endif.
endloop.
**-
ENDIF.
ENDLOOP.Is this what are you looking for?
Regards,
Carlos A. Lerzundy
‎2005 Mar 18 2:32 PM
How can I enable the read to check multiple fields.
Both reference and master_list have fields KEY and OFFSET.
So when I want to check that both fields are equal in the condition, how do I do this (syntactically)?
I tried:
read: table reference with key key = itab_mstr-key, OFS = itab_mstr-OFS.
‎2005 Mar 18 2:35 PM
‎2005 Mar 18 2:36 PM
You will do
read table reference with key key = itab_mstr-key
OFS = itab_mstr-OFS.