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

insert into dabase table

Former Member
0 Likes
917

hi all,

can i insert data into database table taking the data from user through select option statements.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
888

Hi

Make use of the following statement in a similar way as shown below,

INSERT <DATABASE TABLE NAME> FROM TABLE <INTERNAL TABLE>.

Note that the internal table has the same structure as the database table.

No need of looping at the internal table.

OR

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.

<b>Reward if usefull</b>

9 REPLIES 9
Read only

Former Member
0 Likes
888

You can do that in case of custom tables if that s ur requirement.

But in case of std tables you have to enter it through a Transaction which will update the table.

Read only

Former Member
0 Likes
888

take data from select-options into internal table and then use BDC to upload data....as insert statement is risky if u use insert statement...as validations are skipped.....

so use BDC.....

Regards

Vasu

Read only

0 Likes
888

i want to write code in se38. then how to do...........

Read only

0 Likes
888

check which transaction code is used to update data in ur database table....

if u find that then goto SHDb...do a recording .....and generate program.....use taht code in ur se38 program......then use call transaction method or session method to upload data into that transaction...which in turn will update database table.....

if u don't find transaction....then just transafer select-options data into internal tabel and use...

insert databasetable from internaltable.

Regards

vasu

Read only

Former Member
0 Likes
888

Hi Samir,

U can directly insert data in any database table.

Thank you.

Read only

Former Member
0 Likes
889

Hi

Make use of the following statement in a similar way as shown below,

INSERT <DATABASE TABLE NAME> FROM TABLE <INTERNAL TABLE>.

Note that the internal table has the same structure as the database table.

No need of looping at the internal table.

OR

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.

<b>Reward if usefull</b>

Read only

Former Member
0 Likes
888

hi

you can make use of

INSERT INTO table VALUES wa

or insert into table FROM wa/ table i tab

you can use the update stattement as well

regards

Gururaj

Read only

Former Member
0 Likes
888

Hi,

You can insert the data into the tables using the report (SE38). If you are going to insert the data to customized tables it is recommended. But if you want to insert the data to Standard tables it is not recommended because in SAP the data is inserted to tables using transaction codes, using this tcodes the data in one will be simultaneously updated in many different tables. If you try to insert data thru program to standard prg it is not advisable.

If you want to insert data into customized tables use the below code :

DATA: wa TYPE scustom.

wa-id = '12400177'.

wa-name = 'Robinson'.

wa-postcode = '69542'.

wa-city = 'Heidelberg'.

wa-custtype = 'P'.

wa-discount = '003'.

wa-telephone = '06201/44889'.

INSERT INTO scustom VALUES wa.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
888

hi,

INSERT <DATABASE TABLE NAME> FROM TABLE <INTERNAL TABLE>.

try like this.

data: itab like mara occurs 0 with header line.

itab-matnr = 9393.

itab-maktx = 'aluri'.

append itab.

loop at itab.

modify itab1313 from itab.

endloop.

where itab1313 is a database table.

with out loop u have to mention index as

modify itab1313 from itab index sy-index or 13.

if helpful reward some points.

with regards,

Suresh Aluri.