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

Clear and refresh stmt

Former Member
0 Likes
1,405

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,380

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.

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.

10 REPLIES 10
Read only

Former Member
0 Likes
1,380

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

Read only

0 Likes
1,380

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.

Read only

Former Member
0 Likes
1,380

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

Read only

Former Member
0 Likes
1,380

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?

Read only

0 Likes
1,380

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

Read only

0 Likes
1,380

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

Read only

Former Member
0 Likes
1,380

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.

Read only

Former Member
0 Likes
1,381

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.

Read only

0 Likes
1,380

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..

Read only

0 Likes
1,380

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