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: 

Add record to Database table

former_member780881
Participant
0 Kudos
732

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

Sandra_Rossi
Active Contributor
621

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

vijay_hariharan
Contributor
0 Kudos
621

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>.

former_member780881
Participant
0 Kudos
621

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?

DominikTylczyn
SAP Champion
SAP Champion
621

Hello myilmaz03

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

Best regards

Dominik Tylczynski

former_member9115
Participant
621

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.

Sandra_Rossi
Active Contributor
622

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.