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: 

Insert records to DDIC table from internal table

arindam_samanta
Participant
0 Kudos
512

Hi Experts,

I have a DDIc table with following table structure. Here I assign seven fields as primary key.

Update Date        - Update runtime system date (PK)

Update Time    - Update runtime system time (at start of run) (PK)

Plant        - WERKS (PK)

Material        - MATNR (PK)

MRP Element type    - MDEZX-DELKZ (PK)

MRP Element    - MDEZEX-EXTRA  (PK)

Date        - MDEZX-DAT00  (PK)

Quantity        - MDEZX-MNG01

Cumulative Quantity    - Calculated cumulative.

Noe my internal table contains 65 records. After inserting records, I checked DDIC table. There is only 7 records added. Because of primary key combination.

How to add all the records to DDIC table?? How to set PK combination to add all the records?

Any possible solution will gratefully accepted.

Regards,

Arindam Samanta.

15 REPLIES 15

anilkumar_kalkivai
Active Participant
0 Kudos
189

Hi Arindam,

The records with all the primary key combination having same values, then only we can not insert into the DDIC Table.

Here in your Date and Time fields are included, i wonder how these records are matched every time.

Please check data, try to insert the data having records with different primary key combinations.

Regards,

Anil.

Former Member
0 Kudos
189

Hi Arindam,

In your internal table with 65 records how many are unique based on primary key? Also were there any existing records in your DDIC table which got modified?

Check these and respond plz.

While Inserting in DDIC table only 1 record per PK will go. That is the whole concept of primary key. If you want all 65 records to go then there should be some difference in the values of the entire PK combination.

BR.

venkateswaran_k
Active Contributor
0 Kudos
189

Hi Arindam

Primarily,   Step 1

I do not know the functionality behind this table.  However,  if you want all the 65 records to be inserted in the table,  then you need to add one more key to the Primary key combination.

Add  POSNR  type POSNR   just below the Update time.  Mark it as a primary key.

And make sure that, while inserting keep this PSONR value incremented by 1.

Secondly If ,

If you still want to keep the same primary key combinaltion, then you need to update instead of insert by checking the sy-subrc Value. 

Regards,

Venkat

Former Member
0 Kudos
189

What is the key to your DDIC table?

What is the structure of your internal table?

We can't really know how to answer you without the above information.

Viewing the internal table through the key of the DDIC table, are all records unique based on key?

If this is not true, there is no way to add all of the records to your table.  For them to be added, the uniqueness of the key MUST be maintained.

Neal

Former Member
0 Kudos
189

Hi Arindam,

I am just wondering why you made the decision for making timestamps(update date and time) in the primary key.

I think removing the below fields as primary key will solve your issue.

Update Date        - Update runtime system date (Not required as PK)

Update Time    - Update runtime system time (at start of run) (Not required as PK)

Try making the update date and update time non key field and rerun the program.

Regards,

Karthik

Former Member
0 Kudos
189

hi Arindam,

As pointed out already that there will be only one record per PK. You need to check that if your 65 records have all the PK different, it might happen that some of your records are having exactly same PK (they might include blank for some columns). So please check on your data.

I would suggest you to sort the internal table with your PKs and then DELETE ADJACENT DUPLICATES comparing PKs. Now you check how many entries are left in the table. If they are 7 then your data is faulty. In this case either you need correct data or need correction in your requirement for TABLE. You might want to change the table structure in that case.

Please test for above condition and revert.

Regards,

DN.

Former Member
0 Kudos
189

Hi Arinadam,

Primary key will not allow the duplicate records to enter into DB Table.

Primary Key ----> The combination of values of primary key fields makes a primary key.

                   -----> Part of the primary key can be null but the entire key should not be null.

you check the combination of 7 fields whether any duplicates are present in the records that are you are going to insert in the Database table.

Let me know if any clarification/help required.

Thanks & Best Regards.

Pavan Neerukonda.

Former Member
0 Kudos
189

Hi,

you can use document number field as primary key and use the number range to get new number for every record of your internal table.

Regards,

Mordhwaj

former_member209120
Active Contributor
0 Kudos
189

Hi Arindam samanta,

Make Quantity field as Primary Key in DDIC Table, your problem will be solved.

or change your table like this

Plant        - WERKS (PK)

Material        - MATNR (PK)

MRP Element type    - MDEZX-DELKZ (PK)

MRP Element    - MDEZEX-EXTRA  (PK)

Date        - MDEZX-DAT00  (PK)

Cumulative Quantity- Calculated cumulative (PK)

Quantity        - MDEZX-MNG01

Update Date        - Update runtime system date

Update Time    - Update runtime system time (at start of run)

0 Kudos
189

Ramesh,

I'm afraid that it is an unlikely scenario that in the life of the transaction, there would never be duplicate amounts.  You might want to rethink your advice.

Neal

former_member184958
Active Participant
0 Kudos
189

Hi,

  In your table have the duplicate records for all combinations of primary key then you can't insert all data into DDIC table.

Do one thing design your table like standard ekko and ekpo.

    - Design two table First table have the seven record as you said.

   - In second table add one more field like posnr(Item number) or Sno based on these field you insert all data whenever you want to display the data you get from the combination of both table.

You design like above not require that much of Primary key enough single primary key.

If suppose you create more unwanted primary key  defiantly it will lead the performance issue try to design as per the standard.

If you are concentrate on your DDIC design defiantly you can't insert all data but you want only one table then remove the data and time field as primary key then add your quantity field as primary key.

  Hope now it will insert all data.

Warm Regards,

John.

narendar_naidu
Active Participant
0 Kudos
189

Arindam ,

Add another field with serial no(SRNO) in ur table as PK and do the same in ur internal table also and increment it by one and insert all records.

problem gets resolved.

0 Kudos
189

Thanks all..

I have made all the fields as PK... I am thinking It is working  fine.

I will update if any thing goes wrong..

0 Kudos
189

Are you serious? All fields as Primary key? I recon this is a bad database design. First understand the database design concepts, read your business requirement and choose primary key. Just randomly changing primary key may work now but not a reliable solution.

0 Kudos
189

Perhaps the real solution should be that instead of doing an insert or what ever, it should be select, collect, update.

Otherwise, it could be changed to a DB with an artificial key.

Neal