‎2007 Dec 23 7:31 PM
Hi any body pls explain me how to transfer data from internal table to data base table.
‎2007 Dec 23 7:47 PM
‎2007 Dec 23 7:47 PM
‎2007 Dec 24 4:13 AM
Hi Kaladhar,
suppose u have a DB table named ZTEST. having 3 fields ID NAME AGE.
u declare TABLES: ZTEST in your program.
ZTEST-ID = '01',
ZTEST-NAME = 'XXXX'.
ZTEST-AGE = '20'
INSERT ZTEST. " it'll insert this row into the table
if u declare a structure in DATA section. u can do it in this way:
INSERT ZTEST VALUES RECORD. "record has the same structure.
if u have an int tab , do it:
INSERT ZTEST FROM T_RECORD.
also see UPDATE, DELETE, MODIFY statements.
Reward if useful
Regards
ANUPAM
‎2007 Dec 24 9:10 AM
Hi
modifying datbase table useing internal table
advises before updating this datbase table plz lock that table to avoid incosistency
write the logic for modifying
Modify the database table as per new dunning procedure
MODIFY fkkvkp FROM TABLE lt_fkkvkp .
and finally unlock the table
example
*To lock table for further operations
constants: lc_tabname TYPE rstable-tabname VALUE 'FKKVKP' . "FKKVKP
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = lc_tabname
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc EQ 0.
To fetch all the contract accounts for customers of the segment
Households/SME.
PERFORM fetch_contract_accounts using lc_tabname .
ENDIF. " IF sy-subrc EQ 0.
*wrote the logic
Modify the database table as per new dunning procedure from internal table
MODIFY fkkvkp FROM TABLE lt_fkkvkp .
*unlock the tbale
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
TABNAME = uc_tabname .
Reward if usefull
‎2007 Dec 26 10:11 AM
‎2008 Jan 07 10:07 AM
Use this:
loop at (ur internal table).
insert into (ur DDIC table) values (ur internal table).
endloop.
If useful, award point.
‎2008 Jan 07 11:21 AM
Use Update DT from IT.
using insert inside the loop land up with the less performance.
Before updating the databse table make sure that u r using Lock objects for the same in order to lock the table for avoiding incosistencies.
create lock object in SE11.
Call function ENQUE_<LOCKOBJECT>.
update DT from IT.
Call function DEQUE_<LOCKOBJECT>.
Regds,
Ashish
‎2008 Jan 08 4:52 AM
hi
tables zemploy.
loopat itab into wa.
insert into zemploy from wa .
endloop.
this will insert data from internal table to database table.
‎2008 Jan 08 7:56 AM
Hi,
When storing data in internal tables, you often use one internal table for each database you read. Each one contains some or all columns of the relevant database table. It is up to you whether you create an internal table with a flat structure for each database table or if you create, for example, internal tables with nested structures. If you have several tables, each one with a flat structure, you have to work with redundant key fields to link the tables. If, on the other hand, you use nested internal tables, you can store the data from the database tables hierarchically.
Saving and processing very large amounts of data in internal tables has disadvantages. If you divide up the data into different internal tables, processing it can be very runtime-intensive, since the tables have to be processed individually. Furthermore, it requires a lot of storage space, since internal tables are not stored in compressed form. The system may even need to store the dataset outside of its working memory. This means that processing it takes even longer.
regards,
vasavi.
reward if helpful.
‎2008 Jan 08 11:04 AM
Hi ,
Database tables and open SQL Add a single record to a database table insert into values Inserting all lines from an internal table into a database table: insert from table Delete all records Select * from zmellemtab. delete zmellemtab. endselect. Deleting records using records from an internal table delete employees from table itab.
with regards,
sowjanya.gosala
‎2008 Jan 08 2:06 PM
Hi Kaladhar Reddy,
There are several ways of populating data base tables.
MODIFY - Will update the table, if the data already exists, if NOT inserts new rows.
UPDATE - Will update the table, errors out if the data is not found.
In case of MODIFY the sy-subrc is always 0 so you would't know whether the data is actually updated or not.
INSERT - Inserting Data in Database Tables
Variants:
1. INSERT INTO dbtab CLIENT SPECIFIED VALUES wa.
INSERT INTO (dbtabname) CLIENT SPECIFIED VALUES wa.
2. INSERT dbtab CLIENT SPECIFIED FROM TABLE itab. oder
INSERT (dbtabname) CLIENT SPECIFIED FROM TABLE itab.
3. INSERT dbtab CLIENT SPECIFIED. oder
INSERT *dbtab CLIENT SPECIFIED. oder
INSERT (dbtabname) CLIENT SPECIFIED ... .
Effect Adds new records to a database table (see relational
database). You can specify the name of the database table
either directly in the program in the form dbtab or at runtime
as the contents of the field dbtabname. In either case, the
database table must be declared in the ABAP Dictionary. You
can only insert data using a view if the view refers to a
single table and has the maintenance status "No restriction"
in the ABAP Dictionary.
By default, data is only inserted in the current client.
However, if you use the CLIENT SPECIFIED addition, you can
switch off the automatic client handling. This enables you to
enter data for any client in a cross-client table, not just in
the client in which you are logged on. In this case, the
client field is treated like a normal field to which you can
assign a value in the work area.
MODIFY - Change a database table
Variants:
1. MODIFY dbtab. or
MODIFY *dbtab. or
MODIFY (dbtabname) ... ..
2. MODIFY dbtab FROM TABLE itab. or
MODIFY (dbtabname) FROM TABLE itab.
3. MODIFY dbtab VERSION vers. or
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. You can specify the name of the
database table either in the program itself in the form MODIFY
dbtab ... or at runtime as the contents of the field dbtabname
in the form MODIFY (dbtabname) ... . In both cases, the
database table must be defined in the ABAP Dictionary.
Normally, records are inserted or updated only in the current
client. Data can only be inserted or updated using a view, if
the view refers to a single table and was created in the ABAP
Dictionary with the maintenance status "No restriction".
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.
'Insert' will add a new record or a new row into the database table.
'Update' will modify a record in the DB table.
'Modify' it is a combination of both insert and update...
Also check these links
UPDATE->
Bundling using Function Modules for Updates
If you call a function module using the statement CALL FUNCTION ... IN UPDATE TASK, the function module is flagged for execution using a special update work process. This means that you can write the Open SQL statements for the database changes in the function module instead of in your program, and call the function module at the point in the program where you would otherwise have included the statements. When you call a function module using the IN UPDATE TASKaddition, it and its interface parameters are stored as a log entry in a special database table called VBLOG.
The function module is executed using an update work process when the program reaches the COMMIT WORKstatement. After the COMMIT WORKstatement, the dialog work process is free to receive further user input. The update work process is responsible for the update part of the SAP LUW. The statement COMMIT WORKcloses the SAP LUW for the dialog part of the program and starts the update. The SAP LUW is complete once the update process has committed or rolled back all of the database changes. Bundling using function modules is called Update.
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/content.htm
MODIFY->
To modify the lines of a completed list from within the program, use the MODIFY LINE statement. There are two ways to specify the line you want to modify:
· Explicitly:
MODIFY LINE n OF CURRENT PAGE
modifications.
You can refer to the line most recently read:
MODIFY CURRENT LINE modifications.
This statement modifies the line most recently read by means of line selection (F2) or read by the READ LINE statement.
Apart from the ones described above, the modificationsaddition contains several other possibilities to modify the line. For more information on this and on the individual additions of the MODIFY LINEstatement , refer to the keyword documentation.
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba4b235c111d1829f0000e829fbfe/content.htm
plz reward if helpful,
thanks and regards,
srikanth tulasi.
‎2008 Jan 09 5:26 AM
Hai,
loop at
internal table(itab_dep) into workarea.
modify originaltable(zdep) from workarea(wa_dep).
endloop.
regards,
sowjanya.b.