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

Add record to Database table

former_member780881
Participant
0 Likes
2,245

Hi ,

I have some trouble about adding record to Z's Database table.

I created a new table and it include a four key parameter and several parameter in this table.

Also i have a internal table and i added new record to this internal table in program.

I want to , add record to this db table from internal table. But when i added new record db table modify specific row, not added new row.

How can i do; when every new row added in my internal table also added my db table like new row ?

Best regards.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
2,134

By definition, the "Primary Key" of a database table means that each line is UNIQUE (values of all columns of the key).

If you want to have "several lines with same key", you must add a dummy column to the key that you increment (1, 2, 3...) It will make each line unique.

5 REPLIES 5
Read only

vijay_hariharan
Contributor
0 Likes
2,134

You may check the ABAP keyword Documentation for the Modify Statement(Press F1 with your Cursor on Modify).. Below code should ideally work for all records except if there are duplicate key records.. In case you have any specific problem you may edit and add additional details to your question..

MODIFY <ZTABLE> FROM TABLE <your internal table>.
Read only

former_member780881
Participant
0 Likes
2,134

Hi,

When i use this code. İt doesn't work.

It updates the most recent record while asking it to enter the value I just entered. Can't I add the records again even if they are the same?

Read only

Dominik_Tylczynski
SAP Champion
SAP Champion
2,134

Hello myilmaz03

Check out the SAP Help page on Open SQL - Write Accesses

Best regards

Dominik Tylczynski

Read only

former_member9115
Participant
2,134

Hi,

1.Check weather it is appending / looping properly or not .

2.check below code if it may helpful.


IF InternalTableXX is not initial.
Modify tableXX from table InternalTableXX. IF SY-SUBRC = 0. commit work and wait. Message 'Data Inserted Successfully' type 'S'. ENDIF. ENDIF.
Read only

Sandra_Rossi
Active Contributor
2,135

By definition, the "Primary Key" of a database table means that each line is UNIQUE (values of all columns of the key).

If you want to have "several lines with same key", you must add a dummy column to the key that you increment (1, 2, 3...) It will make each line unique.