Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to Insert data into database table

Former Member
0 Likes
39,830

Hi, I am new in abap I have a work area with 38 fields and i want to save some fields, specifically 25 fields from the work area, into a database table, maybe you can help with these.

tahnks.

Guillermo

1 ACCEPTED SOLUTION
Read only

Former Member
15,064

Sorry I forgot to mentioning that, i create the table ztreglog, is not a abap table.

thank you for your reply it was helpful.

5 REPLIES 5
Read only

Former Member
0 Likes
15,064

Hi ,

U have not mentioned which DB table u want to update SAP standard table or ur custom table..

SAP doesnt recommend updating its standard tables directly....it should be done only through transactions or BAPIs.

However if u still want to do it u can use the open SQL statement 'INSERT'.

Read only

Former Member
15,065

Sorry I forgot to mentioning that, i create the table ztreglog, is not a abap table.

thank you for your reply it was helpful.

Read only

0 Likes
15,064

Check the below process:

First declare one internal table :

data : i_ztreglog like ztreglog occurs 0 with header line." Internal table

data : wa_ztreglog like line of i_ztreglog. " Work area

start-of-selection.

move wa_ztreglog to i_ztreglog.

append i_ztreglog.

MODIFY ztreglog FROM TABLE i_ztreglog.

Thanks

Seshu

Read only

0 Likes
15,064


TABLES: ZEBAN.


DATA LINE TYPE ZEBAN .

DATA: ITAB
LIKE STANDARD TABLE OF LINE
WITH NON-UNIQUE KEY BANFN ZID.


DATA:
BEGIN OF IT_ZEBAN OCCURS 0 ,
BANFN
TYPE BANFN,
ZID
TYPE ZID_N,
END OF IT_ZEBAN.


SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_BAN
TYPE BANFN.
PARAMETERS: P_ID
TYPE ZEBAN-ZID.
SELECTION-SCREEN :END OF BLOCK B1.
START-OF-SELECTION.
SELECT BANFN
ZID
FROM ZEBAN INTO TABLE IT_ZEBAN
WHERE BANFN = P_BAN
AND ZID = P_ID.


LINE-BANFN = IT_ZEBAN-BANFN.
LINE-ZID = IT_ZEBAN-ZID.
APPEND LINE TO IT_ZEBAN.

LOOP AT IT_ZEBAN.
IT_ZEBAN-BANFN = P_BAN.
IT_ZEBAN-ZID = P_ID.
LINE-BANFN = IT_ZEBAN-BANFN.
LINE-ZID = IT_ZEBAN-ZID.
WRITE:/ IT_ZEBAN-BANFN,
IT_ZEBAN-ZID.
ENDLOOP.

INSERT INTO ZEBAN VALUES LINE.

Read only

0 Likes
15,064

Hi,

If u want to save the data to database table u have to folloe these steps.

1.First u declare your internal table and work area with database table names.

2.After declaring move the corresponding fields from old work area to new work area.

3.After complete these two steps then u use modify statement or insert.

ex:modify <dbtable> from <wa>.

    inser <dbtable> from <wa>.