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

sy-tabix

Former Member
0 Likes
1,412

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

9 REPLIES 9
Read only

Former Member
0 Likes
1,317

Index is of inner loop ...

Read only

sachin_mathapati
Contributor
0 Likes
1,317

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

Read only

Former Member
0 Likes
1,317

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

Read only

Former Member
0 Likes
1,317

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

Read only

Former Member
0 Likes
1,317

loop at itab.

loop at itab1 where field = itab-field.

delete from itab1 index sy-tabix.

endloop

endloop

Read only

Former Member
0 Likes
1,317

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

Read only

Former Member
0 Likes
1,317

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

Read only

Former Member
0 Likes
1,317

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.

Read only

Former Member
0 Likes
1,317

Hi,

It is the index of inner loop. All the records which satisfy the where condition gets deleted.

Regards,

Swapna.