Skip to Content
0
Former Member
Aug 02, 2008 at 12:40 PM

Problem in Sy-tabix value

162 Views

Hi Experts,

I have a scenario like this

Itab1

A | B | C

1050 | 10 | 88

1051 | 20 | 99

itab2

A | D

1050 | 1

1050 | 2

1050 | 3

1051 | 4

1051 | 5

now I want to combine these values in itab3

my result should be

A | B | C | D

1050 10 88 1

1050 10 88 2

1050 10 88 3

1051 20 99 4

1051 20 99 5

i did code like this

LOOP AT i_tab1 INTO w_tab1.

CLEAR w_tab3.

w_tab3-A = itab1-A.

w_tab3-B = itab1-B.

w_tab3-C = itab1-C.

APPEND w_tab3 TO i_tab3.

loop at i_tab2 INTO w_tab2 where A = w_tab2-A.

IF sy-tabix EQ 1.

w_tab3-D = w_tab2-D.

MODIFY i_tab3 INDEX sy-tabix FROM w_tab3 TRANSPORTING D.

else.

w_tab3-A = itab1-A.

w_tab3-B = itab1-B.

w_tab3-C = itab1-C.

w_tab3-D = itab2-D.

APPEND w_tab3 TO i_tab3

ENDIF.

CLEAR w_vttp.

CLEAR w_vttk_tknum.

endloop.

ENDLOOP.

ENDIF.

Probelm:

When I am pocessing 2 record of itab1, the value of sy-tabix for in internal table i_tab2 is not resetting, it's picking the old value.

Can you please tell me how i can reset the sy-tabix of inner loop for the second pass of outer loop.

Thnaks

Krishan

Edited by: Krishan Kumar on Aug 2, 2008 2:40 PM