sy-tabix and the mole’s mother

Let’s talk a bit about my idiocy. Maybe if you read this and never though about sy-tabix, you will find this post useful. If you knew the basics of sy-tabix, you will find this post useless and trivial.

But hey! I am an idiot, and must thing all we can be idiots sometimes.

Look at this piece of code:
LOOP AT t_table INTO w_warea.
l_tabix = sy-tabix.
...
MODIFY t_table FROM w_warea INDEX l_tabix.
ENDLOOP.

Do you want to ruin it? Just add a READ TABLE sentence in the wrong place… as I did.
LOOP AT t_table INTO w_warea.
READ TABLE t_table2 INTO w_warea2 WITH KEY field = value.
IF sy-subrc = 0.
...
ENDIF.
l_tabix = sy-tabix.
...
MODIFY t_table FROM w_warea INDEX l_tabix.
ENDLOOP.

What will be the value of sy-tabix now? Yes, its value is the position of the found row in t_table2. And everybody and his mother knows it. I knew it. But I wrote that fucking READ TABLE before the sy-index read.

I am an idiot… but, luckily, a tuly one.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s