Application Development 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: 

INSERT STATEMENT

Former Member
0 Kudos
193

Hi friends,

i have one internal table.. that structure with two fields...its like this..

DATA:BEGIN OF ITAB1 OCCURS 0,

MATERIAL LIKE MARA-MATNR,

MTATERIAL LIKE MARA-MTART,

END OF ITAB1.

after that i select the data from data base table.. and i did some modifications on the data which is in ITAB1..

SELECT MATNR MTART FROM MARA INTO TABLE ITAB1 WHERE MTART = 'BABU'.

itab1-MATERIAL = 'M09'.

modify itab1 TRANSPORTING MATERIAL WHERE MATERIAL = '000000000000000058'.

itab1-MATERIAL = 'M10'.

modify itab1 TRANSPORTING MATERIAL WHERE MATERIAL = '000000000000000059'.

ITAB1-MTATERIAL = 'vijayawada'.

modify itab1 TRANSPORTING MTATERIAL WHERE MTATERIAL = 'BABU'.

now i want to insert those modified data.. for this what is the statement... can i write.. ..

thanks

Bbau

1 ACCEPTED SOLUTION

Former Member
0 Kudos
164

hi..

Use <b>APPEND</b> statement..

Eg: <b>append itab1</b>..

I u wanna insert into database table use <b>insert</b> statement..

Eg: <b>insert ztable</b>

<b>U cant insert into standard table.. u can insert only to thecustom table..</b>

<b>Reward points if useful</b>

Regards

Ashu

12 REPLIES 12

Former Member
0 Kudos
164

hi,

U can use

APPEND itab1.

0 Kudos
164

Thanks

but I'm not an abaper.. so, can u plz give me the exact statement what i have to write for inserting those modified data into MARA table..

thanks

babu

0 Kudos
164

Hi,

using modify itab command u r already modifying entries in itab.

but if u want those entries to update into data base then use :

modify dbtab from table itab.

or if u want to insert those entires:

insert dbtab from table itab.

Jogdand M B

Former Member
0 Kudos
165

hi..

Use <b>APPEND</b> statement..

Eg: <b>append itab1</b>..

I u wanna insert into database table use <b>insert</b> statement..

Eg: <b>insert ztable</b>

<b>U cant insert into standard table.. u can insert only to thecustom table..</b>

<b>Reward points if useful</b>

Regards

Ashu

Former Member
0 Kudos
164

Hi,

APPEND ITAB. - adds it into the internal table.

INSERT <DBTABLE> FROM TABLE ITAB.

DBTABLE - Ztable created by u not SAP standard table like MARA.

<b>Remember u can insert only into Ztables not into standard SAP tables.</b>

Regards,

Priyanka.

Former Member
0 Kudos
164

Hi BAbu,

loop at itab1.

itab1-MATERIAL = 'M09'.

modify itab1 TRANSPORTING MATERIAL WHERE MATERIAL = '000000000000000058'.

itab1-MATERIAL = 'M10'.

modify itab1 TRANSPORTING MATERIAL WHERE MATERIAL = '000000000000000059'.

ITAB1-MTATERIAL = 'vijayawada'.

modify itab1 TRANSPORTING MTATERIAL WHERE MTATERIAL = 'BABU'.

Append itab1.

Endloop.

Thanks.

Reward If Helpful.

Former Member
0 Kudos
164

Hi

First change the field name in Internal Table change the seond one to MTART

and then do the correct coding

It is confusing since you are using both internal table fields with same name as MATERIAL

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos
164

(use a append statement) check the following code.

DATA:BEGIN OF ITAB1 OCCURS 0,

MATERIAL LIKE MARA-MATNR,

MTATERIAL LIKE MARA-MTART,

END OF ITAB1.

after that i select the data from data base table.. and i did some modifications on the data which is in ITAB1..

SELECT MATNR MTART FROM MARA INTO TABLE ITAB1 WHERE MTART = 'BABU'.

itab1-MATERIAL = 'M09'.

modify itab1 TRANSPORTING MATERIAL WHERE MATERIAL = '000000000000000058'.

itab1-MATERIAL = 'M10'.

modify itab1 TRANSPORTING MATERIAL WHERE MATERIAL = '000000000000000059'.

ITAB1-MTATERIAL = 'vijayawada'.

modify itab1 TRANSPORTING MTATERIAL WHERE MTATERIAL = 'BABU'.

append ITAB1.

regards,

srinivas

<b>

*reward for useful answers*</b>

former_member491305
Active Contributor
0 Kudos
164

Hi,

If u want to modify all the record with the possibility of different valus,

then you can simply use loop endloop.

Loop at itab1.

if itab1-matnr = '000000000000000058'.

itab1-MATERIAL = 'M09'.

elseif itab1-MATERIAL = '000000000000000059'.

itab1-MATERIAL = 'M10'.

endif.

modify itab1.

Endloop.

Former Member
0 Kudos
164

hi babu

its very simple..jus try this...

DATA:BEGIN OF ITAB1 OCCURS 0,

MATERIAL LIKE MARA-MATNR,

MTATERIAL LIKE MARA-MTART,

END OF ITAB1.

after that i select the data from data base table.. and i did some modifications on the data which is in ITAB1..

SELECT MATNR MTART FROM MARA INTO TABLE ITAB1 WHERE MTART = 'BABU'.

itab1-MATERIAL = 'M09'.

modify itab1 TRANSPORTING MATERIAL WHERE MATERIAL = '000000000000000058'.

itab1-MATERIAL = 'M10'.

modify itab1 TRANSPORTING MATERIAL WHERE MATERIAL = '000000000000000059'.

ITAB1-MTATERIAL = 'vijayawada'.

modify itab1 TRANSPORTING MTATERIAL WHERE MTATERIAL = 'BABU'.

<b>append itab1.

loop at itab1.

write 😕 itab1.

endloop.</b>

reward if useful.....!!!

0 Kudos
164

See friends..

my data was modyfied which i wrote those statements itself.. but my requirement is.. i want to insert those modified data into DATABASES table...

for that i wrote statement like this..

INSERT MARA FROM ITAB1..

but it was showing itab structure is not same the data base table structure..

so, what can i do..

regards

BABU

0 Kudos
164

Hi,

Dont insert into Master table directly .If you just want to test then,just do like this.

Tables :mara.

Loop at itab1.

mara-matnr = itab1-matnr.

mara-mtart = itab1-mtart.

insert mara.

Endloop.

Commit work.

If you want to insert all the values with one statement then both iab and table structure should be same.