Skip to Content
author's profile photo Former Member
Former Member

Inserting values into DDIC table from program

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Jan 27, 2014 at 11:13 AM

    Hi Satya

    What is key field ZANX1 if key field is same in both iteration it will not allow.

    Nabheet

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 27, 2014 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 27, 2014 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 27, 2014 at 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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.