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: 

problem with INSERT

Former Member
0 Kudos

REPORT ZDW_LOC_MSTR .

tables : t001l.

data : begin of itab occurs 0.

include structure zloc.

data: end of itab.

field-symbols: <ls_itab> type zloc.

SELECT werks lgort lgobe

FROM T001L

into (t001l-werks , t001l-lgort , t001l-lgobe ).

MOVE: T001L-WERKS TO ITAB-zsite,

T001L-LGORT TO ITAB-zloc,

T001L-LGOBE(8) TO ITAB-zdesc.

append itab.

endselect.

loop at itab assigning <ls_itab>.

<ls_itab>-ztable_name = 'loc'.

endloop.

<b>INSERT zloc_mstr FROM itab .</b>

<b>i tried FROM TABLE itab too.

and i get only 1 record and in debug i see 20 rows why?</b>

11 REPLIES 11

Former Member
0 Kudos

Hi,

When you say itab, you are referring to the header line which will have only one row. When you say table itab, you are referring to entire table.

In the debug mode, you are looking at the table, which has 20 rows. If you use the FROM TABLE ITAB, you should see 20 rows in the database table.

Regards,

Ravi

0 Kudos

i wrote that i made it too

and i get 1 row

0 Kudos

Is that an already existing record in the table?

Put a commit work statement at end.

Regards,

Ravi

0 Kudos

i add this

INSERT zloc_mstr FROM TABLE itab ACCEPTING DUPLICATE KEYS .

commit work.

and delete all the record and still i get 1 row

0 Kudos

Can you tell us what are the keys in the table and show us the sample data you are passing, including the duplicates if any?

Regards,

Ravi

0 Kudos

after using

INSERT zloc_mstr FROM TABLE itab ACCEPTING DUPLICATE KEYS .

statement if only one record is updated in the table (from 25 entries of itab) it means all of them are duplicate records .(same value for key fields)

Regards

Raja

0 Kudos

the key i mandt only?

the data is mosttly the same always except of site that is change to 800 900 ext....

0 Kudos

raja hi

if all of them are duplicate ( they not)

so i need to have all the records insert right?

0 Kudos

That's exactly is the problem, if MANDT is the only key you will NOT be able to enter more than one row. Have a column as a key that will different values. As MANDT will be same across all the rows, it will a duplicate key.

Have a column that will have seq. number.

Regards,

Ravi

0 Kudos

thanks

i want to give you points but i see that it was answered and i did not mark it?

0 Kudos

The thread is NOT closed yet, please close the thread and mark all the helpful answers.

Regards,

Ravi