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 ztable

Former Member
0 Likes
1,608

i have 5 rows with matnr lgort........

i create ztable that matnr lgort ---key

but only 1 row is entered why?????

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,577

Hi,

If the entries are duplicate it wont enter in DB table with primary keys.

Rgds,

Prakash

17 REPLIES 17
Read only

Former Member
0 Likes
1,577

Hello Rani,

You cannot have entries with duplicate keys in the database table. can you specify the values you are trying to enter into your Z-Table?

Regards,

Anand Mandalika.

Read only

0 Likes
1,577

i

look at this

INSERT INTO ztab VALUES ztab.

<b>data:itab like table of ztab</b> . (an internal table of the type of the Z table into which we want to insert.

Now we have to populate required data into this internal table. For inserting these values into the table ZTAB we can go by 2 different syntax.

1)insert ZTAB from table ITAB or

2)modify ZTAB from tabel ITAB.

Read only

Former Member
0 Likes
1,577

Hello RANI.

Before using the insert statement add

SORT ITAB BY MATNR.

DELETE ADJACENT DULPICATES FROM ITAB COMPARING MATNR.

INSERT INTO ZTABL FROM ITAB.

If useful reward.

Vasanth

Read only

Former Member
0 Likes
1,578

Hi,

If the entries are duplicate it wont enter in DB table with primary keys.

Rgds,

Prakash

Read only

0 Likes
1,577

i have matnr

1111111111 lgort 20

1111111111 lgort 10

1111111111 lgort 30

Read only

0 Likes
1,577

i think in ur ztable matnr is primary key.

Read only

0 Likes
1,577

matnr and lgort is key and mandt

Read only

0 Likes
1,577

Inserting or Changing Lines

To insert lines into a database table regardless of whether there is already a line in the table with the same primary key, use the following:

MODIFY <target> <lines>.

If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like INSERT, that is, the line is added.

If the database already contains a line with the same primary key as the line to be inserted, MODIFY works like UPDATE, that is, the line is changed.

The first syntax inserts the values into the table and if there occurs some duplication you will end in error.

The second syntax inserts into the table the values in ITAB if it is not already present or if already present the existing value is modified with the new value.

Instead of internal table you can also use a workarea where the syntax will be

data: WA type ZTAB.

insert into ZTAB values WA.

hope this helps

Read only

0 Likes
1,577

i use this

loop at zins.

INSERT zml FROM zins.

endloop.

Read only

0 Likes
1,577

Hi,

As others have said, using INSERT statement when there's an existing record will result in error. You can use the MODIFY statement. To know more about the said commands, press F1 while it is highlighted on the command.

Regards!

P.S. Please award points for useful answers

Read only

0 Likes
1,577

Hi Rani,

U can do it making the third entry of ztable as a key field.

Not Sure but atleast u can have a try.

Thanks

-


Sachin Dhingra

Read only

0 Likes
1,577

Hi Rani,

Can this way help you.


LOOP AT zins.

  UPDATE ztable SET    <fields to be updated> = <values>
                   WHERE matnr = zins-matnr AND
                         lgort = zins-lgort.

ENDLOOP.

Regards,

Arun Sambargi.

Read only

0 Likes
1,577

Hi rani,

1. along with mandt,

matnr,

lgort,

<b>u will have to add one more field

as a part of primary key.</b>

(for the values 10,20,30 etc)

2. u can keep this as

ZEILE (like MBLPO Item in Material Document)

( see table MSEG)

3. Then things would get allright.

regards,

amit m.

Read only

Former Member
0 Likes
1,577

You have to use standard table.

Read only

0 Likes
1,577

icant do it i need my ztable because i need to download the data

Read only

0 Likes
1,577

send ur code, so that we can check where its going wrng

Read only

Former Member
0 Likes
1,577

another problem maybe ir's the solution

i create the key of lgort and the lgort was the no 6 in se11

now it's no 3 mandt,matnr,lgort

if i make se16 i still see it no 6