2008 Jun 30 10:49 AM
loop at...
loop at...where
delete from int_tab index sy-tabix
endloop
endloop
I want to delete only those records which are fetched in the inner loop, can I use sy-tabix, is this the index of inner loop or outer loop
Also is there a way to delete all records fetched in inner loop
loop at...
loop at...where
delete from int_tab index sy-tabix
endloop
endloop
I want to delete only those records which are fetched in the inner loop, can I use sy-tabix, is this the index of inner loop or outer loop
Also is there a way to delete all records fetched in inner loop
2008 Jun 30 10:51 AM
2008 Jun 30 10:54 AM
Hi ,
The sy-index will be filled for the latest loop pass.
So for your case it will for inner loop.
Regards,
Sachin M M
2008 Jun 30 10:54 AM
sy-tabix is the index of the immediate loop. here in ur case..its the inner loop.
if u want the index of the 1st loop then pass the index of that into v_tabix.
regards,
madhu
2008 Jun 30 10:56 AM
it wont work you have to calculate the value of index like.
data: index like sy-tabix.
index = Base + sy-stepl - 1.
then write ur code
if useful do rewards
regards
Prakash Varun
2008 Jun 30 10:57 AM
loop at itab.
loop at itab1 where field = itab-field.
delete from itab1 index sy-tabix.
endloop
endloop
2008 Jun 30 11:00 AM
Hi,
sy-tabix is always the actual count after LOOP, READ, DELETE. So in that particular case its the count of the inner loop and you may use it.
You may save the inner loop by using DELETE innner_table WHERE cond. - after that all entries matching the condition cond. will be deleted.
If further checks inside the inner LOOP are neccessary I would rather set a delete flag (inner_table-delflg = 'X'. MODIFY inner_table from wa index sy-tabix) and usage mass deletion afterwards (DELETE inner_table WHERE NOT delflg IS INITIAL.). Mass deletion recalculates the table index only once - deletion inside a loop will calculate it every single time.
Kind regards,
HP
2008 Jun 30 11:01 AM
Hello
This is an index of inner loop.
By the way,
loop at...where
delete from int_tab index sy-tabix
endloop
equial
delete int_tab where ...
2008 Jun 30 11:13 AM
Hi,
For your requirement it will not work by using SY-TABIX.
You can do it by using table key option in DELETE.
Please go through the below code for your reference.
DATA:
t_spfli1 LIKE STANDARD TABLE OF spfli WITH HEADER LINE,
t_spfli2 LIKE STANDARD TABLE OF spfli WITH HEADER LINE,
t_spfli3 LIKE STANDARD TABLE OF spfli WITH HEADER LINE WITH KEY carrid.
SELECT * FROM spfli INTO TABLE t_spfli1 WHERE carrid EQ 'AA'.
SELECT * FROM spfli INTO TABLE t_spfli2.
SELECT * FROM spfli INTO TABLE t_spfli3.
LOOP AT t_spfli1.
LOOP AT t_spfli2 WHERE carrid EQ 'LH'.
DELETE TABLE t_spfli3 WITH TABLE KEY carrid = t_spfli2-carrid.
ENDLOOP.
ENDLOOP.
Thanks & Regards,
Rajni.
2008 Jun 30 11:48 AM
Hi,
It is the index of inner loop. All the records which satisfy the where condition gets deleted.
Regards,
Swapna.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |