Primary key change

Hi Everybody,
I have created a ztable"EMP1" having three keys empno,empname,address.Empno and empname are the primary keys.I had put 10 records in table.Now my req changes and i want one more field in a table i.e.ciry.and empno and city should be primary keys.Can I do this without deleting the original data from the table .

Hai  Vaibhav,
To enable ABAP programs to access database tables correctly, the  runtime object of a table must correspond to the structure of the table in the database. If the table is changed in the ABAP Dictionary, you must ensure that the database structure of the table is adjusted to the change in the ABAP Dictionary during activation (when the runtime object is rewritten).
The database structure does not need to be changed for certain changes in the ABAP Dictionary. For example, the database table does not need to be adjusted to a change in the field sequence (except for key fields) in the ABAP Dictionary, since the field sequence in the ABAP Dictionary does not have to correspond to the field sequence in the database. In this case, the changed structure is simply activated in the ABAP Dictionary and the database structure remains unchanged.
The database structure of a table can be adjusted to its changed ABAP Dictionary definition in three ways:
By deleting and recreating the database table The table is deleted in the database. The revised version of the table is then activated in the ABAP Dictionary and created again in the database. Data in the table is lost during this process.
By changing the database catalog (ALTER TABLE) Only the definition of the table is changed in the database. Data in the table is retained. The indexes on the table might have to be rebuilt.
By converting the table (see Conversion Process). The database table is renamed and serves as a temporary buffer for the data. The revised version of the table is activated in the ABAP Dictionary and created in the database. The data is reloaded from the temporary buffer to the new database table (with MOVE-CORRESPONDING) and the indexes on the table are built.
The procedure actually used by the system in a particular case depends on the following:
type of structural change
database system used
whether data already exists in the table
If the table does not contain any data, the existing table is deleted in the database and recreated. If there is data in the table, the system tries to change the structure using ALTER TABLE. If the database system used cannot execute the structural change with ALTER TABLE, the table is converted.
Conversion is usually the most resource-intensive method of adjusting structures. But structural changes involving changes to the database catalog can also result in costly internal data reorganizations in some database systems. For details on the processes occurring in the database for structural changes with ALTER TABLE, refer to the documentation of your database system.
Normally you should not adjust the database structure during production. At least all the applications that access the table should be deactivated during the structural adjustment. Since the table data is not consistent during the structural adjustment (in particular during conversion), programs could behave incorrectly when they access this data.
Regards.
Eshwar.

Similar Messages

  • Physical Model - Primary Key changed

    I have a report called 'Service Report' running fine. This report uses multiple tables like Service,Specification etc...
    Now that the primary key of service table has changed from 'jdoid' to 'entityId' (The primary key of all the other tables also have changed).
    Wondering what is the best way to rewrite this report?
    Do I have to import 'Service' table (and all other tables) and redefine physical model,business model and presentation model from scratch?
    Is there any other strategy that anybody could think of?
    Appreciate your help.
    Thanks
    Kavi

    No you don't need to re-import. You can edit manually in the Admin tool - start with the physical layer, then the BMM layer.
    Depending on the columns and how the report is built you might not need to edit the report at all.

  • Issues while changing primary key in table

    Hi
    I have one table. In that two fields are primary key. I want to change the second PK as FK only. But when i am changing this field as FK. Its showing one error 'Primary Key Change not permitted for value Table ZCAUSECATMASTER' . How to avoid this error.
    Please help me.

    Hi.....
    Remove that primary key for the second field and assign your foregin key..table to that filed.....
    So when you give entries in that second filed it will be validated with its foregin key table......its nothing but check table...
    what all values in the foregin table only can given.....
    regards
    raja

  • How to add a new data element for existing table filed(Primary key field)

    Hi Experts,
    How to add a new data element for existing table field(Primary key field)
    For this filed ther is no foreign key relation ships and even check table.
    while activating table it is giving message like below.
    can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
    Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)           
    Primary key change not permitted for value table /TC/VENDOR
    Check on table  /TC/VENDOR resulted in errors              
    Thanks
    Ravi

    Hi,
    Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
    You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
    Maybe there are other ways, but this works.
    Success,
    Rob

  • Problems deleting a primary key field in a table.

    Hello Guys,
    I deleted a primary key field in a custom table by clicking 'delete row' icon and then tried activating it through se14 - database utility. It is throwing an error saying 'Primary key change not permited for the value table zxxxx'. What is the problem???
    How can I delete a primary key in a table??
    Please help.
    Thanks,
    Naren

    I am pasting the detail explaination over that error.
    Primary key change not permitted for value table ZTV_RANGE_NUMBER
    Message no. AD 300
    Diagnosis
    This table is defined as a check table. For reasons of consistency, changes to the primary key of the table are not allowed.
    Procedure
    If it is essential that you change the primary key, you must delete the relevant foreign keys. Refer to the where-used list to find all tables containing a field that is checked against this table. Delete the foreign keys for these fields.
    If necessary, maintain the deleted foreign keys again.

  • Primary key deletion in custom database table

    hi,
        I've created a ztable.In which i've have created primary key and foreign key.
    I've activated the table.Now my requirement is that i want to delete the primary key as i've shoosen wrong field as primary key.
    For that first of all i deleted the foreign key relationship than i have unchecked the primary key but it is giving me an error.
    even though if i deleted that field having primary key it is also giving me error as "Primary key change not permitted for value table.
    Please help me out if possible.
    waiting for ur response.
    Thanks,
    Dheeraj

    Make sure u dont have any data in the table..u have to delete all the data..Also make sure you are not using that table any where else.do a where used list in the table.

  • IR - if count (primary key) cannot change to count different column

    Apex 4.1.1.00.23 Windows 7 IE8 / Firefox 16
    If I add a Group By and Count to an Interactive report and choose the primary key column as the one to Count, run the report and then edit the Group By to count a different column, the result set does not change, and if I edit the Group By again it shows that the Counted column has reverted back to the primary key column.
    If I initially choose a different column I can change it and rerun the report successfully, but once I choose the primary key column it cannot be changed. This seems to happen on all applications and all browsers. Is it a bug in Apex?
    Thanks,
    Nick.

    I've tried this in 4.1.0.00.32: works normally. In 4.1.1.00.23 however i'm getting the weird behaviour: you can count on any column, but the moment you count the same column as the one grouped on you can not change the column back to another one anymore. Something which works fine in 4.1.0.00.32.

  • JBO-25014: Another user has changed the row with primary key oracle.jbo.Key

    Hi,
    I am developing a Fusion Web Application using Jdeveloper 11.1.2.1.0. I have a home.jspx page that has a ADF table built on efttBilling View Object. . When you click on one of the rows in the table, it will take you to detail.jspx where you can edit the row and save. When 'save' is clicked, stored procedures are executed to update/insert rows into few tables , and then go back to home.jspx where you need to see updated content for that row.
    To get down to the exact issue, updates are made to the tables on which the efttBilling View Object is built using a stored procedure. Once this is done, I am trying to requery view object to see new content. But I keep getting JBO-25014: Another user has changed the row with primary key oracle.jbo.Key error. Following are the approaches I followed to query new results:
    a. Executed Application Modules Commit Method. Created 'Commit' Action binding and tied it to homePageDef.xml. Called this binding from a view scope bean.
        BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
         OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        Object result = operationBinding.execute();
       if (!operationBinding.getErrors().isEmpty())
        return null;
    b. Marked 'Refresh on Insert' , 'Refresh on Update', 'Change Indicator' checkboxes for all the attributes in the entities associated with efttBilling View Object.
    c. Tried to Requery View Object. Created a refreshViewObject method in Application Module Impl.java file, exposed this method to the client interface and created a invokeMethod Action binding in home.jspx
    Code in Application Module:
      public void refresheftTransactionsforBillingAccountViewObj1View()
        System.out.println("In eftTransactionsforBillingAccountViewObj1");
      findViewObject("eftTransactionsforBillingAccountViewObj1").executeQuery();
    Code in view scope bean
            DCBindingContainer bindings =
           (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            OperationBinding operation =
            bindings.getOperationBinding("refresheftTransactionsforBillingAccountViewObj1View");
            operation.execute();
    I have searched web, ADF forums and tried methods suggested in there but no sucess.
    Could anyone please provide some insight in this issue. I have been battling with this since quite some time. I can provide you with the log file too.
    Thanks!
    Shai.

    What code does your Commit method have .. can you try using the Commit executable from the AM itself instead ?
    Also -
    Shai wrote:
    'Change Indicator' checkboxes for all the attributes in the entities associated with efttBilling View Object.
    which all attributes you set this property for . it should just be for History columns as such.
    Did you also check if this could be your scenario ?
    Decompiling ADF Binaries: Yet another reason for "JBO-25014: Another user has changed the row with primary key orac…
    OR
    JBO-25014: Another user has changed the row with primary key oracle.jbo.Key
    OR
    Another user has changed the row with primary key -Table changed externally
    Message was edited by: SudiptoDesmukh

  • How to change the source type for a primary key on a form?

    Hi,
    At the time of creating a form, I had set the source type for the primary key to an existing sequence.
    Now I want to change the source to a trigger.
    Can anyone suggest how to do it?
    Thanks in advance,
    Annie

    Annie:
    Define the trigger and then delete the page process named 'Get PK'
    Varad

  • How to change primary keys of existing InfoCube.

    Greetings everyone!
    I’m trying to change the Key Fields in my reporting architecture as per our new company mandate.  I’ve been able to successfully change the primary keys for DS, DSO and InfoSource.  Can any kind soul out there please tell me how to change the primary keys on an existing InfoCube?  I will surely appreciate all the assistance I can get.  Its kinda urgent!
    Regards,
    Philips

    Hi,
    Check the possibility with Remodelling option . If it is not possible with Remodelling, then you can only change the cube deleting the Data.
    With rgds,
    Anil Kumar Sharma .P

  • DBMS_CDC find only the columns that are changed along with the primary key in the table

    Hello,
    We are having a requirement to find the change data in the production environment.
    We are planning to use the DBMS_CDC utility.
    But for  example in the create change table 1 picked emp_id,ename, address, salary,dob.
    I have a sample data of
    empid
    ename
    address
    salary
    DOB
    1
    test1
    24 test street
    2000
    20-Jan-98
    2
    test2
    25 test street
    2500
    15-Aug-97
    if ename for empid 1 is changed to test1_test3 from test1.
    My CDC is capturing  the values in the old and new values in the 5 columns.
    But i need to get only the empid (primary key of the source table) and the ename column as only that's been updated not the rest of the 3 columns.
    Can i accomplish this.
    Please advice.

    Hello,
    Thanks for the information.
    but if i change the change table  then i will miss the other columns right?
    I want to get the columns( empid and ename) only if ename is changed. i.e when ever any column in emp table changes i need to get all the columns where the data is changed along with the primary key columns empid.
    Is there any way i can tweak the parameters so that i can achieve this or is there any other way using the cdc i can get this data.
    Thanks

  • Another user has changed the row with primary key -Table changed externally

    Hello,
    I am facing the error: "Another user has changed the row with primary key oracle.jbo.Key[94 ]." during the delete operation.
    User case scenario:
    1. Added new row in the table.
    2. Once new row is added to the the table, another application will update few columns in the newly added row based on some logic.
    3. On the same session I am trying to delete the newly added row and getting above mentioned error.
    I have added a "Button" in the table to partialRefresh the table to check the new values of the changed columns.
    I have checked the forum and found many similar errors and tried the following but nothing helped.
    1. By setting "Auto Refresh = True" for the view object.
    Issue faced-> It worked fine but after few add and remove my db is getting to inconsistent state after which, I am not able to do any add/delete from my page.
    Error: "Too many objects match the primary key oracle.jbo.Key". I have checked this and I am not getting this error when "Auto Refresh = False" even after multiple add and remove actions.
    2. By Setting "Auto Refresh" the iterator associated with the page.
    Issue -> Did not work at all.
    Looking forward inputs from gurus.
    Thanks
    Abhijeet

    Finally I found one solution to this problem at: [ http://www.avromroyfaderman.com/2008/05/bring-back-the-hobgoblin-dealing-with-rowinconsistentexception/|http://www.avromroyfaderman.com/2008/05/bring-back-the-hobgoblin-dealing-with-rowinconsistentexception/]
    Simply overriding the lock() method in the entity object resolved issue. Kudos to the author.
    Code:
    public void lock() {
    try {
    super.lock();
    } catch (RowInconsistentException e) {
    refresh(REFRESH_WITH_DB_ONLY_IF_UNCHANGED | REFRESH_CONTAINEES);
    super.lock();
    But, Now my refresh button is not working as depend on the "Auto Refresh = True" to update the table.
    Can anyone tell me how can I refresh the VO of my table from the button.
    Thanks
    Abhijeet.
    P.S: I have already added the partial trigger but it is work not working as the data is cached in the VO. Removing the Cached property for the VO is creating other problems.

  • How do you change the value of the primary key in the CMP?

    Hi,
    The cmp that I built has the phone as the Prikey field.
    The bean has the get/set methods. The servlet invokes the cmp
    to change the phone number. How could I do that?
    The setXXX for the priKey can not be called outside of the ejbCreate() so
    how would I change the prikey value of a particular row of the table. Do I have
    to remove the bean then create the new bean with the new priKey value?
    Please help,
    Thanks

    Thanks Mona
    Tom.
    Mona Ramlawi <[email protected]> wrote:
    Hi TOM,
    The primary key is the unique identifier of an Entity Bean.
    To change it, you have to remove the bean instance = database delete
    then you have to create a new one with the new primary-key value =
    database insert.
    Hard luck tom, maybe you should consider changing your primary key. You
    can easily change it to an AutoNum
    Tom wrote:
    Hi,
    The cmp that I built has the phone as the Prikey field.
    The bean has the get/set methods. The servlet invokes the cmp
    to change the phone number. How could I do that?
    The setXXX for the priKey can not be called outside of the ejbCreate()so
    how would I change the prikey value of a particular row of the table.Do I have
    to remove the bean then create the new bean with the new priKey value?
    Please help,
    Thanks

  • Primary key and change indicator

    So I was creating an employee and then I committed the records and then I tried to delete a record from the same table. I encountered an error like below:
    "Another user has changed the row with primary key"
    So I searched the solution of this problem, and then I read this article https://blogs.oracle.com/onesizedoesntfitall/entry/the_case_of_the_phantom
    This is the solution according to the above article:
    Alternatively you can set the Change Indicator on one of the attributes.  This will work as long as the relating column for the attribute in the database itself isn't inadvertently updated.  In turn you're possibly just masking the issue rather than solving it, because if another developer turns the Change Indicator back on the original issue will return.*
    Well, then set the Change Indicator of the EmployeeID attribute (which happens to be the primary key of the table). Now its working fine.
    But my question is: Is this okay if I am setting the Change Indicator of a primary key attribute to be True?

    >
    Sonull wrote:
    I have set the Type property of employeeID as DBSequence. So when the system creates a row, the values displayed for the employee ID is in the form of negative numbers (-1, -2, -3). Only after committing the rows does the trigger gets fired, and the next number in the sequence is generated, and the row is saved in the database.
    >
    I don't understand you? are you asking a question or provide information?
    When set the type of an attribute to DBSequence, by default Jdeveloper sets the Refresh on Insert property.
    What I want to say is that the problem is not in the EmployeeId attribute.

  • Change primary key in ztable

    Hello everyone
    I need some advice.
    I have transp. table ZINVOICE which have data in production system.
    field  of table are
    VBELN  Primary key
    KUNNR
    NAME
    FKART
    FKDAT
    NETWR
    STAT
    TAXINVNUM
    ZFKDAT
    ZNETWR
    now i want table ZINVOICE have 2 primary (VBELN + TAXINVNUM)
    when i activate system show
    Key is already defined; field TAXINVNUM cannot be in the key
    Message no. AD434
    Diagnosis
    When defining table fields, you added further key fields at the end after entering a block of key fields followed by a block of non-key fields.
    All the key fields of a table must be in a block at the beginning of the table.
    Procedure
    All key fields in a table should be entered in a single block.
    is it mean that primay key must be in beginning of the table ?
    can i delete field in table ZINVOICE and insert field and change position of fields to
    VBELN  Primary key
    TAXINVNUM Primary key
    KUNNR
    NAME
    FKART
    FKDAT
    NETWR
    STAT
    ZFKDAT
    ZNETWR
    can i do like this ?
    is it impact my existing data in SAP ?
    please advice.

    As you are adding a new key, you should not get problem with duplicate records.
    You should create two transport requests and activate/transport the table twice.
    - In the first request, change the order of fields in the database table, don't add primary key now, activate , if required adjust database table (should not be required), transport database table in target system.
    - In the second request, declare the second field as a primary key, proceed same way.
    DON'T TRANSPORT BOTH REQUESTS TOGETHER
    First step
    VBELN K
    TAXINVNUM
    KUNNR
    NAME
    Second step
    VBELN K
    TAXINVNUM K
    KUNNR
    NAME
    Question: Did you forget to add the client field, if yes you will have to adjust the table and the records will be copied in every client, you will have to create and execute a small cleanup program
    Third step
    MANDT K
    VBELN K
    TAXINVNUM K
    KUNNR
    NAME
    Regards,
    Raymond

Maybe you are looking for