‎2014 Jan 27 11:11 AM
Hello Experts,
I'm trying to insert the values into Data Dictionary table from a program.
It is allowing only first row.
When I try to add the second row it is not taking the values.
I'm using the statement as
INSERT INTO ZANX1 <table name> VALUES W_ANNXR <work area>.
After this statement sy-subrc = 4.
Please help me.
Thank you..
Satya
‎2014 Jan 27 11:13 AM
Hi Satya
What is key field ZANX1 if key field is same in both iteration it will not allow.
Nabheet
‎2014 Jan 27 11:47 AM
Nabheet and Sivasamy..
Thank you for your immediate solution..
‎2014 Jan 27 11:22 AM
Hi Satya,
Use MODIFY <table name> FROM <work area.
If records are already exist, it will change otherwise it will create new record.
Arivazhagan S
‎2014 Jan 27 11:44 AM
Hii Satya,
Seems that the data base table contains the same records with the key fields.
So, before using insert statement , first sort your internal table with the key fields.Then delete duplicate records from internal table by using DELETE ADJACENT DUPLICATES FROM <itab COMPARING <keyfields by which sorted itab>.
NOTE: If your database table ZANSX1 has two key fields then while sorting the internal table specify all those key fields.
then finally use INSERT statement.
Alternate Suggestion:
As you are inserting data one by one at a time into database table from work area by looping your internal table into work area, you can insert all rows in a single INSERT statement by the below statement.
INSERT ZANX1 FROM TABLE <your internal table name>.
If you doubt about the duplicates entries, then you can add ACCEPTING DUPLICATE KEYS.
You can also go with MODIFY statement as it will work as a dual.
If the records exist with same keys then it will modify the rows otherwise will insert new row into the database table.
regards
Syed
‎2014 Jan 27 11:58 AM
If your second record has the same key field values it will fail due to primary key duplication. Using MODIFY will allow you to insert the record with same primary key but will edit the first record with second in the table.