‎2008 Feb 19 8:43 AM
hi
i need to update and the data base table using fiel symbol and i need to count the records
following is the code. pls hepl me.
FIELD-SYMBOLS : <fs_op> TYPE zfifn_op .
SELECT * FROM zfifn_op INTO TABLE zfifn_op_upd
WHERE opbel = itab_custom-opbel
AND bukrs = itab_custom-bukrs.
SORT zfifn_op_upd BY opbel.
LOOP AT zfifn_op_upd ASSIGNING <fs_op>.
READ TABLE itab_custom WITH KEY opbel = <fs_op>-opbel.
IF sy-subrc = 0.
<fs_op>-opbel = itab_custom-opbel.
ENDIF.
ENDLOOP.
UPDATE zfifn_op
FROM TABLE zfifn_op_upd.
COMMIT WORK AND WAIT.
Points will be reward
‎2008 Feb 19 8:52 AM
Hi please see this sample code, might be useful.
1. For selecting data using field symbol.
SELECT * FROM
<db table name> INTO TABLE <fs_itab>.
2. Modify database table using field symbol.
MODIFY <db table name> FROM TABLE <fs_itab>.
Note: <fs_itab> is a field symbol of type any table.
Please get back if you need some more info.
‎2008 Feb 19 8:48 AM
hi Kumar,
while LOOPing the internal table you don't write back the changed values.
DATA : lv_tabix TYPE sy-tabix.
LOOP AT zfifn_op_upd ASSIGNING <fs_op>.
lv_tabix = sy-tabix.
READ TABLE itab_custom WITH KEY opbel = <fs_op>-opbel.
IF sy-subrc = 0.
<fs_op>-opbel = itab_custom-opbel.
MODIFY TABLE zfifn_op_upd FROM <fs_op> INDEX lv_tabix.
ENDIF.
ENDLOOP.
New lines are in bold.
hope this helps
ec
‎2008 Feb 19 8:52 AM
Hi
I dont want to update the table one by one.
for example my file having 100,000 records means it ll affect performance. first i need to update structure. then i need to update data base table
‎2008 Feb 19 8:58 AM
Kumar,
the changes I suggested only updates the internal table, other part of the source code has to remain the same (I just did not include them), only the LOOP is changed. this means the DB update will be in one go, like before. Pls. give it a try!
ec
‎2008 Feb 19 9:14 AM
Your code looks absolutely correct. I tried following code bundle and it is working.
data: zfifn_op_upd like ztest125 occurs 0 with header line.
FIELD-SYMBOLS : <fs_op> TYPE ztest125 .
SELECT * FROM ztest125 INTO TABLE zfifn_op_upd
WHERE matnr = '22510G'.
SORT zfifn_op_upd BY matnr.
LOOP AT zfifn_op_upd ASSIGNING <fs_op>.
<fs_op>-mtart = 'HM01'.
ENDLOOP.
UPDATE ztest125
FROM TABLE zfifn_op_upd.
COMMIT WORK AND WAIT.
Thanks and regards,
Atanu
‎2008 Feb 19 8:52 AM
Hi please see this sample code, might be useful.
1. For selecting data using field symbol.
SELECT * FROM
<db table name> INTO TABLE <fs_itab>.
2. Modify database table using field symbol.
MODIFY <db table name> FROM TABLE <fs_itab>.
Note: <fs_itab> is a field symbol of type any table.
Please get back if you need some more info.