‎2008 Dec 02 4:03 AM
Hi,
i am modifying a internal table in which i am using this statement :-
MODIFY T_DD FROM W_DD INDEX SY-TABIX
and the work area is further used to insert the data base table . i just want to know that is this the correct way to modify the internal table bcoz when i execute the program for updating the database it is hardly taking 1 minute to get updated and i think the problem lies in the above statement.
Please provide me guidelines to sove this problem.
‎2008 Dec 02 4:08 AM
Hi ,
Use MODIFY and TRANSPORTING exact fields. So that it will reduce your performance.
Regards
Dinesh
‎2008 Dec 02 4:09 AM
Hi
why r u using the work area to insert into the DB table? you can use the internal table to do that.
Thanks
Shivika
‎2008 Dec 02 4:09 AM
Hi,
1. Dont use the sy-tabix variable directly. Try to store sy-tabix value in a variable and use it in the modify statement. Since if you have some inner loops or read statements inside this loop then it might change the value of sy-tabix value.
For Ex:
loop at itab into wa.
v_tabix = sy-tabix.
some read stataments
MODIFY itab FROM wa INDEX v_tabix.
endloop.
2. Try to avoid modify within a loop. Try using modify itab1 from table itab.
Modify whole table at once.
Thanks & Regards,
Navneeth K.
‎2008 Dec 02 4:13 AM
Hi,
SY-TABIX is dynamically changes , I mean
loop at itab.
sy-tabix here incremented by 1 for every loop cycle
now if you say
read table itab1 with key f_name = itab-fname
now sy-tabix hold the line number of the new found row in the itab1
endloop.
instead of updating the database table from with in the loop, complete all the modifications to the loop
then update the database table from the table itself (not within the loop)
MODIFY DBTAB FROM TABLE ITAB
For further info go through the KEY word documenatiaon of MODIFY
Regards
Ramchander rao.K
‎2008 Dec 02 4:22 AM
HI ALL,
Yes there is there are 3 loops which are executing and is there any difference in using the Work area than the internal table for inserting the database tables?
should i store the value in the variable of sy-tabix?
‎2008 Dec 02 4:30 AM
Hi
for example you have 100 rows in itab and updating the database table within a loop, then system accesses the database 100 times. if you achieve the same using the internal table the DB access is onetime only so it is obviously faster the first method.
it is always suggested to store the sy-tabix value in a variable as the value of sy-tabix changes in a loop as we use read statements
data tabix type sy-tabix
loop at itab
here assign the value of sy-tabix to tabix
tabix = sy-tabix ( like this )
endloop
Regards
Ramchander Rao.K
‎2008 Dec 02 4:32 AM
Ya it is good to store the value of sy-tabix in local varaible. Right after the loop statement of that itab which you want to modify.
‎2008 Dec 02 5:04 AM
Hi ricx,
See following code.
Wrong Way:
LOOP AT ITAB1.
"SY-TABIX = 1
READ TABLE ITAB2 WITH KEY ITAB1-FIELD1.
" let the record with the key specified exists in ITAB2 at index 5, now SY-TABIX will have value 5 and not 1
MODIFY ITAB1 INDEX SY-TABIX.
ENDLOOP.
Right Way:
LOOP AT ITAB1.
L_TABIX = SY-TABIX.
READ TABLE ITAB2 WITH KEY ITAB1-FIELD1.
MODIFY ITAB1 INDEX L_TABIX.
ENDLOOP.
‎2008 Dec 02 5:17 AM
Hi,
Refer below code
LOOP AT it_crmm_territory INTO wa_crmm_territory.
l_index = sy-tabix.
CLEAR : wa_crmm_territory_v.
READ TABLE it_crmm_territory_v INTO wa_crmm_territory_v WITH KEY terr_guid = wa_crmm_territory-terr_guid.
IF sy-subrc EQ 0.
wa_crmm_territory-valid_from = wa_crmm_territory_v-valid_from.
wa_crmm_territory-valid_to = wa_crmm_territory_v-valid_to.
wa_crmm_territory-guid = wa_crmm_territory_v-guid.
ENDIF.
MODIFY it_crmm_territory FROM wa_crmm_territory INDEX l_index
TRANSPORTING guid valid_from valid_to.
CLEAR : wa_crmm_territory.
ENDLOOP.
Regards,
Prashant