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

problem in inserting data into database tabel

Former Member
0 Likes
1,898

hi all,

If i am using the syntax

INSERT <database table> from table <itab>. i am getting the syntax error

" the work area "itab" is not long enough long enough" . why i am getting this error even though itab has the same structure of database table.

Is it necessary to have the header line for the itab?

Pls help me.

Thanks,

Praveena

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,379

HI PRAVEENA,

I ANSWERED YOU IN THE OTHER THREAD.

yes the Itab should have the header line

then use

insert <db table> from ITAB.

Reward points if useful

Regards

Anji

11 REPLIES 11
Read only

Former Member
0 Likes
1,379

Hi,

The internal table should of the structure of the database table..

Ex..

data: itab type standard table of ztable.

INSERT ztable FROM TABLE itab.

Thanks,

Naren

Read only

Former Member
0 Likes
1,380

HI PRAVEENA,

I ANSWERED YOU IN THE OTHER THREAD.

yes the Itab should have the header line

then use

insert <db table> from ITAB.

Reward points if useful

Regards

Anji

Read only

0 Likes
1,379

Hi AnjiReddy,

Thank you for your answer. I am declaring the internal table by using types.so its not possible for me to declare it by using occurs 0. can you pls suggest me some other solution to insert into database table from internal table without using header line.kindly help me.

Thanks,

Praveena

Read only

Former Member
0 Likes
1,379

Hi,

Please check my reply.

Thanks,

Naren

Read only

0 Likes
1,379

Hi Narendran,

Thank you fro your reply.I declared itab as per your suggestion .syntax error is not coming now but records are not inserted into database table after executing insert statement.

kindly help me.

Thanks,

Praveena.

Read only

Former Member
0 Likes
1,379

Hi,

Make sure you have all the key fields populated...Including MANDT..

Also check for SY-SUBRC after the INSERT statement..

If sy-subrc = 0. Then do a commit work.

if sy-subrc = 0.

COMMIT WORK.

endif.

Thanks,

Naren

Read only

0 Likes
1,379

hi Narendran,

i declared itab as follows

DATA: tb_final TYPE STANDARD TABLE OF ztable,

wa_final TYPE ztable. "work area

i am populating tb_final as follows:

wa_final-vkorg = wa_ycostctr_kunwe-vkorg.

wa_final-vtweg = wa_ycostctr_kunwe-vtweg.

wa_final-spart = wa_ycostctr_kunwe-spart.

wa_final-kunwe = wa_ycostctr_kunwe-kunwe.

wa_final-kondm = wa_ycostctr_kunwe-kondm.

wa_final-kschl = wa_ycostctr_2-kschl.

wa_final-hkont = wa_ycostctr_2-saknr.

wa_final-kostl = wa_ycostctr_kunwe-kostl.

APPEND wa_final TO tb_final.

CLEAR wa_final.

here i am not populating Mandt field.

finally in tb_final am not getting the proper data .

kindly help me.

Thanks,

Praveena

Read only

0 Likes
1,379

data: itab like standard table of ztable<b> with header line.</b>

itab-vkorg = wa_ycostctr_kunwe-vkorg.

itab-vtweg = wa_ycostctr_kunwe-vtweg.

itab-spart = wa_ycostctr_kunwe-spart.

itab-kunwe = wa_ycostctr_kunwe-kunwe.

itab-kondm = wa_ycostctr_kunwe-kondm.

itab-kschl = wa_ycostctr_2-kschl.

itab-hkont = wa_ycostctr_2-saknr.

itab-kostl = wa_ycostctr_kunwe-kostl.

append itab.

-


insert ztable from table itab.

-


OR

-


loop at itab.

insert ztable from itab.

endloop.

-


reward if it helps.

Read only

Former Member
0 Likes
1,379

use MODIFY instead of INSERT and checkout if it works

Read only

Former Member
0 Likes
1,379

insert (table name) from <internal table >

This is the procedure to insert .

Read only

Former Member
0 Likes
1,379

Hi,

I believe It is not necessary the internal table declared with header line for inserting records to the table..

Thanks,

Naren