Application Development 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: 

sy-index

Former Member
0 Kudos

hi guys ,

how can i increase the index value..this is my logic..everytime i loop is processing the sy-index = 0..its not changing anything wrong with the code..

LOOP AT lt_bomitem WHERE item_categ = 'N'.

IF sy-index GT 2.

DELETE lt_bomitem.

ENDIF.

ENDLOOP.

regards

6 REPLIES 6

Former Member
0 Kudos

use sy-tabix in this case.

it shows current loop pass.

Regards

vasu

former_member200338
Active Contributor
0 Kudos

Hi,

Can you explain whats the requirement? if you want to delete the record of more than 2 existing record, then try this.

data: l_index type sy-index.

LOOP AT lt_bomitem WHERE item_categ = 'N'.

l_index = l_index + 1.

IF l_index GT 2.

DELETE lt_bomitem.

ENDIF.

ENDLOOP.

Regards,

Niyaz

former_member583013
Active Contributor
0 Kudos

It should be like this...


DATA: GS_TABIX TYPE SY-TABIX.

LOOP AT lt_bomitem WHERE item_categ = 'N'.
GS_TABIX = SY-TABIX.
IF GS_TABIX GT 2.
DELETE lt_bomitem.
ENDIF.
ENDLOOP.

Greetings,

Blag.

Former Member
0 Kudos

LOOP AT lt_bomitem WHERE item_categ = 'N'.

IF sy-tabix GT 2.

DELETE lt_bomitem.

ENDIF.

ENDLOOP.

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please use SY-TABIX instead of SY-INDEX.

Regards,

Ferry Lianto

Former Member
0 Kudos

Do not use sy-index in loop of the internal table

sy-index - mainly for do loops

sy-tabix for internal table loops.

Thanks

Seshu