‎2007 Jul 30 8:25 AM
Hi to all experts,
If I want to update the database table zabc through abap coding.
What is the process of that.
Please give a simple code for better understanding.
Thanks in advance and reward also.
Regard : deep
‎2007 Jul 30 8:28 AM
‎2007 Jul 30 8:30 AM
hi,,
&----
*& Report ZUPDAT
*&
&----
*&
*&
&----
REPORT ZUPDAT.
*tables zdep.
*
data t_dep like zdep occurs 0 with header line.
*
select *
from zdep
into table t_dep.
*
*
loop at t_dep.
write 😕 t_dep-name,
t_dep-id.
endloop.
*
uline.
*
*
*
UPDATE ZDEP SET ID = '49'
WHERE NAME = 'ASHU' AND ID = '24'.
*
*select *
from zdep
into table t_dep.
*
*
loop at T_DEP.
write 😕 T_dep-name,
T_dep-id.
endloop.
*
uline.
*
_______________________________________________________________
*
tables zdep.
data t_dep like zdep occurs 0 with header line.
select *
from zdep
into table t_dep.
*
DATA t_ITAB like zdep occurs 0 with header line.
T_ITAB-NAME = 'RAMA'.
T_ITAB-ID = '23'.
MODIFY ZDEP SET T_ITAB .
REFRESH T_ITAB.
select *
from zdep
into table T_ITAB.
loop at t_ITAB.
write 😕 T_ITAB-name,
T_ITAB-id.
endloop.
uline.
Reward points
Regards
ASHOK
‎2007 Jul 30 8:31 AM
hi Check this code.........
tables: rf180.
data: inr type i value 0.
data: itab like rf180 occurs 10 with header line.
parameters: t_sttag like rf180-sttag.
selection-screen: begin of block b1 with frame title new.
select-options: sttag for itab-sttag,
bukrs for itab-bukrs.
selection-screen: end of block b1 .
start-of-selection.
select * from rf180 into table itab where sttag in sttag
and bukrs in bukrs.
loop at itab.
inr = inr + 1.
itab-sttag = t_sttag.
modify rf180 from itab.
endloop.
write: 'Number of record updated = ' , inr.
Plz rerward points if helpful.
‎2007 Jul 30 8:32 AM
Hi,
Insert command is used to add records in the table.
For updating database table,you can use UPDATE or MODIFY command.
Modify will either insert the record if it does not exist or it will update the record if it exists.
UPDATE dbtab SET f1 ... fn.
UPDATE dbtab.
UPDATE dbtab FROM TABLE itab.
1. MODIFY dbtab. or
2. MODIFY dbtab FROM TABLE itab.
3. MODIFY dbtab VERSION vers.
Effect
Inserts new lines or updates existing lines in a database table (s. relational database). If a line with the specified primary key already exists, an UPDATE is executed. Otherwise, an INSERT is performed. MODIFY belongs to the Open SQL command set.
When the statement has been executed, the system field SY-DBCNT contains the number of edited lines.
For information about LUW,check this link.
http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/content.htm
Check this link also.
http://help.sap.com/saphelp_46c/helpdata/en/41/7af4e0a79e11d1950f0000e82de14a/frameset.htm
http://help.sap.com/saphelp_46c/helpdata/en/41/7af4e0a79e11d1950f0000e82de14a/frameset.htm
http://help.sap.com/saphelp_46c/helpdata/en/41/7af4e0a79e11d1950f0000e82de14a/frameset.htm
Regards
‎2007 Jul 30 1:05 PM
1 prepare internal table wt_zabc having same structure as zabc
2.Populate wt_zabc with require data for updation
3.loc table zabc with FM "ENQUEUE_E_TABLE"
4.MODIFY dbtab FROM TABLE itab
5. if success ful do commite work
6. on failuer do rollback work
7. unlock database table by FM "DEQUEUE_E_TABLE"
‎2007 Jul 30 1:08 PM
hi,
Chk this.
<u>
method 1.</u>
REPORT ztestreport .
DATA : BEGIN OF int OCCURS 0,
client LIKE ztable-client,
emp_name LIKE ztable-emp_name,
emp_id LIKE ztable-emp_id,
END OF int.
int-client = '501'.
int-emp_name = 'Test Data'.
int-emp_id = '0001'.
<b>APPEND int.</b>
INSERT ztable <b>FROM TABLE int</b>.
COMMIT WORK.
<u>Method 2.</u>
loop at itab_ztable into wa_ztab.
modify ztable from wa_ztab.
clear into wa_ztab.
endloop.Rgds
Reshma