‎2007 Jun 22 3:21 AM
Hi Friends,
I need to modify my database table from the internal table, pls tell me how to do it.
Regards,
Parvez
‎2007 Jun 22 3:30 AM
Use below like statement
describe table int_table lines v_line.
if not v_line is initial.
comitt work.
modify dbtable from table int_table.
endif.
Thanks
Seshu
‎2007 Jun 22 3:23 AM
MODIFY dbtab FROM itab.
Check the standard SAP help for MODIFY statement for examples and details.
Use the F1 power
‎2007 Jun 22 3:25 AM
‎2007 Jun 22 3:28 AM
‎2007 Jun 22 3:30 AM
‎2007 Jun 22 3:29 AM
Hi,
MODIFY dbtab FROM TABLE itab.
Check this link for mor einformation.
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/modify.htm
‎2007 Jun 22 3:30 AM
Use below like statement
describe table int_table lines v_line.
if not v_line is initial.
comitt work.
modify dbtable from table int_table.
endif.
Thanks
Seshu
‎2007 Jun 22 3:54 AM
Hi
Here is my code, can you please correct it.
LOOP AT lt_invmov INTO lw_invmov.
IF lw_invmov-check = 'X'.
move 'CL' to lw_invmov-status.
ENDIF.
append lw_invmov to lt_invmov.
ENDLOOP.
MODIFY zinv_mov FROM lt_invmov.
regards,
Line
‎2007 Jun 22 3:56 AM
LOOP AT lt_invmov INTO lw_invmov.
IF lw_invmov-check = 'X'.
move 'CL' to lw_invmov-status.
ENDIF.
append lw_invmov to lt_invmov.
ENDLOOP.
MODIFY zinv_mov FROM <b>table</b> lt_invmov.
‎2007 Jun 22 3:59 AM
Hi Seshu,
I checked it but even though it is displaying the same error 'The work area "LT_INVMOV" is not long enough'
LOOP AT lt_invmov INTO lw_invmov.
IF lw_invmov-check = 'X'.
move 'CL' to lw_invmov-status.
ENDIF.
modify lt_invmov from lw_invmov index sy-tabix.
ENDLOOP.
MODIFY zinv_mov FROM table lt_invmov.
‎2007 Jun 22 4:16 AM
Hi,
I checked it but even though it is displaying the same error 'The work area "LT_INVMOV" is not long enough'
LOOP AT lt_invmov INTO lw_invmov.
IF lw_invmov-check = 'X'.
move 'CL' to lw_invmov-status.
ENDIF.
modify lt_invmov from lw_invmov index sy-tabix.
ENDLOOP.
MODIFY zinv_mov FROM table lt_invmov.
Thanx in advance,
‎2007 Jun 22 4:25 AM
YOUR INT TABLE SHOULD BE THE SAME STRUCTURE AS YOUR DATABASE TABLE.
DATA : lt_invmov LIKE zinv_mov OCCURS 0 WITH HEADER LINE. OR SOMETHING LIKE THAT....
REGARDS
SHIBA DUTTA
‎2007 Jun 22 4:37 AM
Sorry for delay..
decalre internal table or work area as like table
data : wa_mara like mara.
data : i_mara like <b>mara</b> occurs 0.
here i_mara is same like mara.
now use modify command.
‎2007 Jun 22 4:42 AM
Hi Shiba,
Thanx for your reply.
I have data in the table control and i need to update only selected record from the table control selection to the database table.
How to do it, Can you please tell me
Regards,
‎2007 Jun 22 4:48 AM
‎2007 Jun 22 4:49 AM
just declare a table like your database table now from your table cntrl table pass the value to the int table like database table...now use modify statement with the newly declare table(like database table)...
i think in your pai you are writting the code like this..
loop at itab where mark = 'X'."here itab tab cntrl int tab and mark is selection field
itabnew-f1 = itab-f1.
itabnew-f2 = itab-f2.
append itabnew.
endloop.
now use
modify itab from table itabnew.
if you want to only update the existing record then better to use update with where condition.
regards
shiba dutta
‎2007 Jun 22 5:21 AM
‎2007 Jun 22 9:08 AM
Hi Shiba,
But it is modifying only one record at a time can you tell me how to modify batch of records once.
Regards
‎2007 Jun 22 9:09 AM
Pls find my code
LOOP AT lt_invmov INTO lw_invmov WHERE check = 'X'.
itab_reg-lifnr = lw_invmov-lifnr.
itab_reg-xblnr = lw_invmov-xblnr.
itab_reg-bukrs = lw_invmov-inv_date.
itab_reg-inv_date = lw_invmov-inv_date.
itab_reg-invr_date = lw_invmov-invr_date.
itab_reg-zterm = lw_invmov-zterm.
itab_reg-dmbtr = lw_invmov-dmbtr.
itab_reg-waers = lw_invmov-waers.
itab_reg-kursf = lw_invmov-kursf.
MOVE 'CL' TO itab_reg-status.
APPEND itab_reg.
ENDLOOP.
MODIFY zinv_reg FROM itab_reg.
‎2007 Jun 22 9:11 AM
put the break point on modify statement and check the table how much data it contain? and let us know if it contain more than one data?
regards
shiba dutta
‎2007 Jun 22 9:21 AM
Yes it contains more than one record but it is only modifying the first record.
‎2007 Jun 22 9:27 AM
just check you have repeating the value or not for the secondary index of that table if it is so then it will not update the database from the repeating value and you will get the sy-subrc as 4.
regards
shiba dutta
‎2007 Jun 22 9:32 AM
‎2007 Jun 22 3:34 AM
Check with below program ,here i am getting the data from file and updating the data into custom table using modify statement.
REPORT ZLWMI151_UPLOAD no standard page heading
line-size 100 line-count 60.
*tables : zbatch_cross_ref.
data : begin of t_text occurs 0,
werks(4) type c,
cmatnr(15) type c,
srlno(12) type n,
matnr(7) type n,
charg(10) type n,
end of t_text.
data: begin of t_zbatch occurs 0,
werks like zbatch_cross_ref-werks,
cmatnr like zbatch_cross_ref-cmatnr,
srlno like zbatch_cross_ref-srlno,
matnr like zbatch_cross_ref-matnr,
charg like zbatch_cross_ref-charg,
end of t_zbatch.
data : g_repid like sy-repid,
g_line like sy-index,
g_line1 like sy-index,
$v_start_col type i value '1',
$v_start_row type i value '2',
$v_end_col type i value '256',
$v_end_row type i value '65536',
gd_currentrow type i.
data: itab like alsmex_tabline occurs 0 with header line.
data : t_final like zbatch_cross_ref occurs 0 with header line.
selection-screen : begin of block blk with frame title text.
parameters : p_file like rlgrap-filename obligatory.
selection-screen : end of block blk.
initialization.
g_repid = sy-repid.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = g_repid
IMPORTING
FILE_NAME = p_file.
start-of-selection.
Uploading the data into Internal Table
perform upload_data.
perform modify_table.
top-of-page.
CALL FUNCTION 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
.
&----
*& Form upload_data
&----
text
----
FORM upload_data.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = $v_start_col
I_BEGIN_ROW = $v_start_row
I_END_COL = $v_end_col
I_END_ROW = $v_end_row
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
write:/10 'File '.
ENDIF.
if sy-subrc eq 0.
read table itab index 1.
gd_currentrow = itab-row.
loop at itab.
if itab-row ne gd_currentrow.
append t_text.
clear t_text.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'.
t_text-werks = itab-value.
when '0002'.
t_text-cmatnr = itab-value.
when '0003'.
t_text-srlno = itab-value.
when '0004'.
t_text-matnr = itab-value.
when '0005'.
t_text-charg = itab-value.
endcase.
endloop.
endif.
append t_text.
ENDFORM. " upload_data
&----
*& Form modify_table
&----
Modify the table ZBATCH_CROSS_REF
----
FORM modify_table.
loop at t_text.
t_final-werks = t_text-werks.
t_final-cmatnr = t_text-cmatnr.
t_final-srlno = t_text-srlno.
t_final-matnr = t_text-matnr.
t_final-charg = t_text-charg.
t_final-erdat = sy-datum.
t_final-erzet = sy-uzeit.
t_final-ernam = sy-uname.
t_final-rstat = 'U'.
append t_final.
clear t_final.
endloop.
delete t_final where werks = ''.
describe table t_final lines g_line.
sort t_final by werks cmatnr srlno.
Deleting the Duplicate Records
perform select_data.
describe table t_final lines g_line1.
modify zbatch_cross_ref from table t_final.
if sy-subrc ne 0.
write:/ 'Updation failed'.
else.
Skip 1.
Write:/12 'Updation has been Completed Sucessfully'.
skip 1.
Write:/12 'Records in file ',42 g_line .
write:/12 'Updated records in Table',42 g_line1.
endif.
delete from zbatch_cross_ref where werks = ''.
ENDFORM. " modify_table
&----
*& Form select_data
&----
Deleting the duplicate records
----
FORM select_data.
select werks
cmatnr
srlno from zbatch_cross_ref
into table t_zbatch for all entries in t_final
where werks = t_final-werks
and cmatnr = t_final-cmatnr
and srlno = t_final-srlno.
sort t_zbatch by werks cmatnr srlno.
loop at t_zbatch.
read table t_final with key werks = t_zbatch-werks
cmatnr = t_zbatch-cmatnr
srlno = t_zbatch-srlno.
if sy-subrc eq 0.
delete table t_final .
endif.
clear: t_zbatch,
t_final.
endloop.
ENDFORM. " select_data
Thanks
Seshu
‎2007 Jun 22 5:32 AM
see the modify query ...
SELECT INVOICE_NO GATE_ENTRY_NUM
INTO CORRESPONDING FIELDS OF TABLE I_ZFBPS_INV_LINK
FROM ZFBPS_INV_LINK
FOR ALL ENTRIES IN GATEIN_ITAB
WHERE GATE_ENTRY_NUM = GATEIN_ITAB-GATE_ENTRY_NUM.
LOOP AT I_ZFBPS_INV_LINK.
read table GATEIN_ITAB with key GATE_ENTRY_NUM = I_ZFBPS_INV_LINK-GATE_ENTRY_NUM
****just have if logic it will work
IF GATEIN_ITAB-INVOICE_NO = I_ZFBPS_INV_LINK-INVOICE_NO .
MODIFY GATEIN_ITAB INDEX SY-TABIX.
ENDIF .
ENDLOOP.reward points if it is usefull ..
Girish