2006 Jun 23 5:34 PM
I have a Database Table called Zcustomers.
An internal table called ITZcustomers. I have read all the records from Zcustomers into ITZcusotmers. I have modified my ITZcusomers using my business logice and now I need to move this ITZcustomers modifications to my Zcustomers DB table?
Whats the Syntax for this? Thanks a lot.
2006 Jun 23 5:37 PM
Hi,
Loop at itzcustomers into wa_customers.
modify zcustomers from wa_customers.
endloop.
Best regards,
Prashant
2006 Jun 23 5:36 PM
data: itzcustomers type table of zcustomers with header line.
loop at itzcustomers.
modify zcustomers from itzcustomers.
endloop.
or.....
data: itzcustomers type table of zcustomers .
data: wazcustomers type zcustomers.
loop at itzcustomers into wazcustomers.
modify zcustomers from wazcustomers.
endloop.
Regards,
Rich Heilman
2006 Jun 23 5:37 PM
Hi,
Loop at itzcustomers into wa_customers.
modify zcustomers from wa_customers.
endloop.
Best regards,
Prashant
2006 Jun 23 5:40 PM
<b>Loop at itzcustomers into wa.
modify zcustomers from wa.
endloop.</b>
2006 Jun 23 5:45 PM
2006 Jun 23 5:47 PM
Are you only changing existing records, or might you insert or delete records as well?
Rob
2006 Jun 23 6:08 PM
If you are only changing existing records, you should use:
update zcustomers from table itzcustomers.
This will be quicker than modify.
Rob
2006 Jun 23 5:48 PM
2006 Jun 23 5:49 PM
Hi vijaya,
check this, hope it helps u.
Inserting or Changing Single Lines
To insert or change a single line in a database table, use the following:
MODIFY <target> FROM <wa> .
The contents of the work area <wa> are written to the database table <dbtab>. The work area <wa> must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.
If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0.
A shortened form of the above statement is:
MODIFY <dbtab>.
In this case, the contents of the table work area <dbtab> are inserted into the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.
Inserting or Changing Several Lines
To insert or change several lines in a database table, use the following:
MODIFY <target> FROM TABLE <itab> .
Those lines of the internal table <itab> for which there is not already a line in the database table with the same primary key are inserted into the table. Those lines of the internal table <itab> for which there is already a line in the database table with the same primary key overwrite the existing line in the database table. The same rules apply to the line type of <itab> as to the work area <wa> described above.
SY-SUBRC is always set to 0. SY-DBCNT is set to the number of lines in the internal table.
regards,
keerthi.
2006 Jun 23 5:53 PM
HI Vijaya,
Loop at internal table into workarea.
Modify internal table from workarea
endloop.
Ex:
loop at itab into wa.
modify ztab from wa.
endloop.
Regards
Laxmi.
Message was edited by: Laxmi
2006 Jun 23 6:04 PM
Hi Vijaya,
You can use the Modify statement. The advantage of this statement is that if the record you are updating the table is already there it justs modifies the record else it updates a new entry in the database table.
MODIFY Zcustomers from table ITZcustomers.