09-14-2010 7:08 AM
Hi all,
Im facing a problem in processing an internal table..especially with MODIFY.
The internal table is having following records.(t_vttp)
TKNUM VBELN KUNNR NAME1 LAND1
0000975179|0071004839|0000022946|HUNTSMAN APC LIMITED |SA |
0000975180|0071004845|0000022946| | |
In the above, there are two delviry documents with same customers.
The customer data is coming from different internal table.
LOOP AT t_vttp.
READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
IF sy-subrc = 0.
t_vttp-name1 = wa_kna1_temp-name1.
t_vttp-land1 = wa_kna1_temp-land1.
MODIFY t_vttp INDEX sy-tabix TRANSPORTING name1 land1.
ENDIF.
ENDLOOP.
Here for second record,,the customer name and country is nt getting populated to t_vttop.
Pls correct where it is going wrong.
Thanks,
Priya
09-14-2010 7:15 AM
Hi,
Store the value of sy-tabix of t_vttp before READ TABLE t_kna1_temp.
data : lv_tabix type sy-tabix. "Added"
LOOP AT t_vttp.
move sy-tabix to lv_tabix. "Added"
READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
IF sy-subrc = 0.
t_vttp-name1 = wa_kna1_temp-name1.
t_vttp-land1 = wa_kna1_temp-land1.
MODIFY t_vttp INDEX lv_tabix TRANSPORTING name1 land1. "Changed from sy-tabix to lv_tabix"
ENDIF.
ENDLOOP.
Regards
Vinod
09-14-2010 7:13 AM
Hi,
Do like this
Data : l_index type sy-tabix.
LOOP AT t_vttp.
l_index = sy-tabix.
READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
IF sy-subrc = 0.
t_vttp-name1 = wa_kna1_temp-name1.
t_vttp-land1 = wa_kna1_temp-land1.
MODIFY t_vttp INDEX l_index TRANSPORTING name1 land1.
ENDIF.
ENDLOOP.
Regards,
Prashant
09-14-2010 7:15 AM
Hi,
Store the value of sy-tabix of t_vttp before READ TABLE t_kna1_temp.
data : lv_tabix type sy-tabix. "Added"
LOOP AT t_vttp.
move sy-tabix to lv_tabix. "Added"
READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
IF sy-subrc = 0.
t_vttp-name1 = wa_kna1_temp-name1.
t_vttp-land1 = wa_kna1_temp-land1.
MODIFY t_vttp INDEX lv_tabix TRANSPORTING name1 land1. "Changed from sy-tabix to lv_tabix"
ENDIF.
ENDLOOP.
Regards
Vinod
09-14-2010 7:19 AM
data : lv_tabix type sy-tabix.
LOOP AT t_vttp.
*-- passing the sy-tabix to a variable
move sy-tabix to lv_tabix.
READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
IF sy-subrc = 0.
t_vttp-name1 = wa_kna1_temp-name1.
t_vttp-land1 = wa_kna1_temp-land1.
*-- modify the t_vttp table based on the lv_tabix.
MODIFY t_vttp INDEX lv_tabix TRANSPORTING name1 land1.
ENDIF.
ENDLOOP.
Regards
Manoj
09-14-2010 7:19 AM
Hi Try the follwoing code with a little modification in your code.
LOOP AT t_vttp.
READ TABLE t_kna1_temp INTO wa_kna1_temp WITH KEY kunnr = t_vttp-kunnr.
IF sy-subrc = 0.
t_vttp-name1 = wa_kna1_temp-name1.
t_vttp-land1 = wa_kna1_temp-land1.
MODIFY t_vttp INDEX sy-tabix TRANSPORTING name1 land1.
append t_vttp.
ENDIF.
clear: wa_kna1_temp, t_vttp.
ENDLOOP
Also Please debugg your code and check if you are getting values.
also check the value of t_vttp-kunnr in debugging for the second run of your loop.
thanks
lalit
09-14-2010 7:32 AM
It has worked out, by declaring sy-tabix separately.
Thanks all for your help.