2009 Feb 13 12:28 PM
Hi ,
In my code have written as
loop at gi_table.
read table1 some codns where f1 = 10
read table2 some codns where f2 = 25.
if table1-f1 = table2-f2.
modify some codns.
endloop.
My question is, consider in the table in have 5 entries but only 2 values satisfies the read codn and the if codn so its modifying the table.Again when its entering the loop again its fetching the same two values using the read stmt.There is no necessasity to again compare the values as it have already compared.But in this code its happening so.Wat to do.
Another thing is before endloop where i have to put clear stmt.
2009 Feb 13 1:04 PM
try this
loop at itab1.
READ TABLE itab with key f1 = itab1-f1.
itab-flag = 'X'.
MODIFY itab INDEX sy-tabix TRANSPORTING flag.
READ TABLE itab2 with key f1 = itab1-f1.
itab2-flag = 'X'.
MODIFY itab2 INDEX sy-tabix TRANSPORTING flag.
if itab1-dmbtr NE itab2-dmbtr.
message e000 with 'Not equal'.
endif.
DELETE itab WHERE flag = X.
DELETE itab2 WHERE flag = X.
endloop.
2009 Feb 13 12:32 PM
hi,
Just before endloop statement, write
Delete table1 where f1 = 10.
Delete table2 where f2 = 25.
These records will not be processed again.
Thanks
Sharath
2009 Feb 13 12:38 PM
Hi,
A small doubt.Please help in this.If i write delete stmt it would work only if 2 records are present.Consider is more records are present with value 10 and 25 it will completely delete the record from the table without comparing.Only the 1st one record of 10 and 25 would be compared.So how to code in this part.Hope am correct.Please correct me if am wrong.
2009 Feb 13 12:40 PM
Hi Divya,
read table1 some codns where f1 = 10
read table2 some codns where f2 = 25.
if table1-f1 = table2-f2.
modify some codns.
DO not keep the conditions inside the loop...hope it helps..
Regards,
Mdi.Deeba
2009 Feb 13 12:41 PM
hi,
set a flag = x when the row in a table is modified .
then read table where the flag is not checked.
can you paste your code?
2009 Feb 13 12:45 PM
Code is:
loop at gi_table .
read table gi_table into gi_price1 with key ebeln = gi_table-ebeln vgabe = 1.
read table gi_table into gi_price2 with key ebeln = gi_table-ebeln vgabe = 2.
if gi_price1-dmbtr NE gi_price2-dmbtr.
message e000 with 'Not equal'.
endif.
endloop.
how to set flag.
Edited by: Divya KR on Feb 13, 2009 1:46 PM
2009 Feb 13 1:40 PM
HI,
I think you want to check the records where the EBELN is having unique values.
Then sort itab on EBELN.
SO it will not check the vbeln availability in the gi_price1 or gi_price2 again and again.
only one time it will be done.
loop at itab.
on change of ebeln.
read table gi_table into gi_price1 with key ebeln = gi_table-ebeln vgabe = 1.
read table gi_table into gi_price2 with key ebeln = gi_table-ebeln vgabe = 2.
if gi_price1-dmbtr NE gi_price2-dmbtr.
message e000 with 'Not equal'.
endif.
endon.
endloop.
Regards,
Venkatesh
2009 Feb 13 12:44 PM
Hi,
Use in this way, Check sy-subrc for those two read statement and then compare
loop at gi_table.
read table1 some codns where f1 = 10
If sy-subrc = 0.
read table2 some codns where f2 = 25.
if sy-surc = 0.
if table1-f1 = table2-f2.
modify some codns.
Delete table1 some codns where f1 = 10.
Delete table2 some codns where f2 = 25.
endif.
endif.
endif.
Clear ur all the work areas here.
endloop.
Try this.
2009 Feb 13 1:04 PM
try this
loop at itab1.
READ TABLE itab with key f1 = itab1-f1.
itab-flag = 'X'.
MODIFY itab INDEX sy-tabix TRANSPORTING flag.
READ TABLE itab2 with key f1 = itab1-f1.
itab2-flag = 'X'.
MODIFY itab2 INDEX sy-tabix TRANSPORTING flag.
if itab1-dmbtr NE itab2-dmbtr.
message e000 with 'Not equal'.
endif.
DELETE itab WHERE flag = X.
DELETE itab2 WHERE flag = X.
endloop.
2009 Feb 13 1:15 PM
Hi,
One more doubt .I have declared the table itab as itab like rbkp occurs 0 with header line.
I cant change this declaration.For this how to set the flag.Please help.Thanks for ur patience..
2009 Feb 13 1:24 PM
Hi,
Store the sy-tabix after each READ in a local variable
now use delete itab index <idx>.
data: tabix_1 like sy-tabix,
tabix_2 like sy-tabix.
loop at gi_table.
read table1 some codns where f1 = 10.
check sy-subrc = 0.
tabix_1 = sy-tabix.
read table2 some codns where f2 = 25.
check sy-subrc = 0.
tabix_2 = sy-tabix.
if table1-f1 = table2-f2.
modify some codns.
delete table table1 index tabix_1
delete table table2 index tabix_2
endif.
endloop.
regards,
Advait
Edited by: Advait Gode on Feb 13, 2009 2:24 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |