Updating entries in a ztable

Hi,
I have a database table with the following structure: -
MANDT: -        PK (Primary Key)
PLANT: -         PK
MATNR: -        PK
VALID TO: -     PK
VALID_FROM
The table contains a record such as the following: -
400    3330    material1    31/12/9999    28/06/2008
What I am trying to do programmatically is to replace the above record with the following 2 records (CONTAINED IN AN INTERNAL TABLE PT_PRICE_LEVEL): -
400    3330    material1    28/06/2008    28/06/2008
400    3330    material1    31/12/9999    29/06/2008
In order to achieve this, I created a function module and called it in update mode. The function module has the following code in it: -
      DELETE FROM table_name
        WHERE plant = 3330
          AND matnr = 'material1'
          AND valid_to = '31/12/9999'. (This deletes the existing record)
      INSERT zptp_rcd_pricelv FROM TABLE pt_price_level. (This inserts the new records).
This should have worked but instead it generates an error message saying that duplicate records can't be inserted.
I think I know the reason. I think I need to call a commit after the delete operation and then insert the new records. But, this code is in an update FM. I don't think I am allowed to call the COMMIT statement within an update FM. Can anyone provide me with suggestions on how an existing records primary key can be updated? My approach certainly doesn't seem to work.
Any help would be appreciated.
Regards,
Divyaman

Hi,
Thank you all for your suggestions. But, the real cause of the problem is as follows: -
The primary key had been specified on the following four keys: -
MANDT: - PK (Primary Key)
PLANT: - PK
MATNR: - PK
VALID_TO: - PK
However, a unique index had also been created (something which I wasn't aware of) which included only the first 3 fields. As a consequence, when I entered 2 rows with the same combination of mandt, plant and matnr but a different valud for valid_to, I was getting an error message stating that duplicate records can't be inserted.
Regards,
Divyaman

Similar Messages

  • Overwrite a single field entry in the ZTABLE

    Hi ALL,
    I have to overwrite a single field entry in the ZTABLE .
    How can I do it so the previous field entry is replaced by new one.
    Thanks in ADVANCE!!!

    Hi,
    Try this within a loop (wa_pernr).
    update ztable
    set field = 'field-value'
    where pernr = wa_pernr-pernr.
    *Here wa_pernr-pernr is the primary key for  the Ztable.
    Edited by: storm on Jul 24, 2008 8:11 AM
    Edited by: storm on Jul 24, 2008 8:11 AM

  • Lock Objects Problem while updating entries in custom table

    Hi Friends,
    Iam updating a custom table ztable from internal table entries.
    ie : Modify ZTABLE from table ITAB.
    Now the entries are updating and inserting perfectly..
    But my problem is i need to use lock objects before doing this..
    I have created a lock obect EZTABLE with all th ekey fields of the table.. ie : it has 2 key fields
    item & matnr .
    Now how to use lock objects here.. do i need to loop the internal table and use enque & deque function module each and every time in loop or use it out side the loop..
    Can any one explain me this..
    Regards,
    Kumar

    hi kumar,
    **check if the equipment is already locked by user, if yes, trigger a mail
                CALL FUNCTION 'ENQUEUE_EIEQUI'
                 EXPORTING
                MODE_EQUI            = 'E'
                MANDT                = SY-MANDT
                   equnr                = lv_equi_temp
                X_EQUNR              = ' '
                _SCOPE               = '2'
                _WAIT                = ' '
                _COLLECT             = ' '
                 EXCEPTIONS
                   foreign_lock         = 1
                   system_failure       = 2
                   OTHERS               = 3.
                IF sy-subrc <> 0.
                  lv_subrc1 =  sy-subrc.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                ELSE.
                  CALL FUNCTION 'DEQUEUE_EIEQUI'
                   EXPORTING
                MODE_EQUI       = 'E'
                MANDT           = SY-MANDT
                     equnr           =  lv_equi_temp
                X_EQUNR         = ' '
                _SCOPE          = '3'
                _SYNCHRON       = ' '
                _COLLECT        = ' '
                ENDIF.
    try like this to check if the object is locked....
    u can also use
    call function 'ENQUEUE,.
    do the needful changes update the database then commit work
    then call function 'DEQUEUE'
    hope this helps,
    tanmaya

  • Insert delete or update entry in Custom table from KONV entry changed

    Hi All,
    I have custom table ZKONV with only few required columns and should have same number of records as KONV has at any point in time.
    KONV is a cluster table so its not readable from ORACLE level. So ZKONV is created. But I dont know how to keep these both tables in sync.
    I need to perform insert delete or update entry in Custom table if insert delete or update happens on cluster table KONV from any transactions.
    As KONV is a cluster table and does not have changed time stamp I am not able to know the number of records changed in perticulat time period.
    Thanks,

    Thanks for reply,
    There is a Outside SAP system which needs to read KONV data to feed into their system, but as KONV is cluster table they are not able to read it from ORACLE level.
    To solve this we are thinking to create a transparent Z-table and will fill it with KONV and catch Update, delete or Insert statement and do same on ZKONv.
    Is this possible some how? by some database event or something....

  • How to retrive the deleted entries in the ztable

    please let me know how to retrive the deleted entries in the ztable.

    >
    Naseer uddin wrote:
    > Hi,
    >
    >   While creating a table have u activated the buffering (full).
    >   if not then it is not possible to retrive the lost data, and if u have activated the full buffering of table then it is possible to retrive data, up to some extent, using transaction Code se14.
    Complete Nonsense.*
    buffering doesn't mean that it will buffer the records back in database ,once you deleted.it means it will allow the buffer the table to memory only while read access.

  • Can we update the data of ztable by using the BAPI FM

    Hi Experts,
    Can we update the data of ztable by using BAPI FM  'BAPI_CUSTOMERCONTRACT_CHANGE'.
    Can anyone help this issue.
    regs
    rams

    Hi Ramesh,
    After the BAPI 'BAPI_CUSTOMERCONTRACT_CHANGE' is called, check the return message and use UPDATE <DBTABLE_NAME> command to update the ZTABLE.
    Use COMMIT WORK after the call. If the BAPI is standard BAPI and not a customized BAPI, then it wont update Z Table direclty. You need to build the logic in program to update Z Table.
    Best regards,
    Prashant
    PS : Please reward all helpful answers

  • Update Screen with the updated entries?

    I have create a simple interface where user can see the entries that are in the tab view.
    I have a delete button where once pressed, LOV will pop up and allow the user to choose which entry they wish to delete.
    When the user has selected the entry, it will be deleted from the db.
    Now my question is: how can I update the screen such that the screen will show the updated entries in the db.

    the problem is that the entries are already shown on the screen... in a tab view.
    Hence, the button allows a lov to pop up for user to select which one to delete.
    I have added the commit but it doesn't refresh. I have to manually click on the next and previous entry button to see the newly updated screen.
    So is there a way to refresh the screen without doing the manual refreshing?

  • Updation in SM30 for ztable takes long time

    Hi All,
               I have got one issue on Ztable.
              when i try to modify even the single value in the ztable in SM30, it is taking long time(10 min) to save the changes.
              This table is a view and I checked with indexes also, it seems to be fine.
              After debugging i found that even for one chnage in the entry it is reading almost 83000 records.
              Can anyone please guide me on this, how should i correct the error.
    Thanks in Advance

    Hi
    When creating table maintenance generator you will able to create events so try to create event and add source code in the event
    to delete the entries which are not required .
    Check with Link
    http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=93454609
    Regards
    Chandra

  • Deleting/Updating Entries of Blocked Invoices

    Hi,
    The Incoming INvoices were parked because of the Quantity variance and was blocked for Payment.
    That particular Invoice got listed in MRBR transaction. We have released the Invoice without deleting the Blocking Reason(Qty Variance). This particular Invoice got paid in the payment run successfully after getting released.
    Now when I look at RSEG table I see the Check Mark agains the field SPGRM(Blocking Reason: Qty). 
    Pls let me know the ways to update the RSEG table to delete this field entry. We are using this table for our Blocked INvoice Report hence because of this Blocking reason even though the INvoice is Paid, the Invoice is getting listed in the report.
    Thanks for all your help.
    Regards,
    Satya

    Please read OSS Note 685688 - Release of "old" invoices as of SAP R/3 Enterprise
    maybe you can use one of the reports and hints to solve your issue

  • Problem in updating entries in Table Maintenance of custom table

    Hi Gurus,
    Need help. When I update existing entries in the table maintenance generator, they do not get updated after save. Is there a setting in data dictionary that causes this?

    Just noticed that the field that I'm trying to update is a KEY FIELD.
    Usually, when a table maintenance is generated, key field columns are set to uneditable. But for apparent reason, previous programers set it as editable. Is there a way to edit the Key fields?

  • Multiple iTunes/iPod Updater Entries in Add/Remove Programs

    There are three entries for iTunes in the "Add or Remove Programs" window.
    iTunes 6.0.3.5
    iTunes 6.0.2.23
    iTunes 6.0.1.3
    I never bothered uninstalling the previous version before upgrading (I fear it will mess up my music library if I take iTunes completely off). I always figured, like with most other programs, it would replace/delete the previous version on its own.
    The same thing happens with the iPod Updater. I have two of those.
    iPod for Windows 2005-11-17 (4.17.0)
    iPod for Windows 2005-09-23 (4.3.0)
    Should I uninstall them all (iTunes & iPod Updater) and reinstall only the latest versions (iTunes 6.0.4 & iPod Updater 2006-01-10)? I have like 30GB of music, and if anything were to happen...I'd seriously jump in front of a speeding car before reripping everything...ok no I wouldn't, but I'd be extremely ****** off.
    Thanks in advance for any help! =D
    Sony Vaio   Windows XP  

    Uninstalled everything an reinstalled most current version.

  • How to update entries of already uploaded master data?

    Hi Experts,
    Master data for one of the infoprovider 0PROMOTION has uploaded with blank value for one of it's attribute zcatgrp and zcatgrp master data is being maintained in BI. Recently one more Zcatgrp has been uploaded but business wants existing records with this new catgrp .
    Please suggest how to update the existing master data entries?
    Regards,
    BW USER

    RELOAD the masterdata with zcatgrp for the promotions.
    when you reload the masterdata with the zcatgrp associated to the promotion (key), the existing records(with blank values) would be overwritten with new records with the associated zcatgrp value.

  • Deleting Software Update entries?  Part II

    The previous topic has been marked answered - http://discussions.apple.com/thread.jspa?messageID=11217724&#11217724
    Reason for part II
    I would also like to know how to delete updates that you want to skip because you do not need them. *Can you delete entries?*
    What I want to delete are the *Digital Camera Raw Compatibility* - I do not use Aperture nor have any of the cameras listed.
    *ProKit Update* - I do not have Final Cut Studio, Final Cut Pro, Motion, Soundtrack Pro, DVD Studio Pro, Aperture, Final Cut Express, Soundtrack, Logic Pro and Logic Express installed on my computer.

    Sorry to bother. I just figured it out.
    Select the item then go to Update/Ignore Update.

  • Trigger WF when updating entries through custom MSS screen

    Hi can anyone tell how to trigger a workflow when entry in 2007 infotype is updated using custom MSS screen.What are the steps need to follow.
    Thanks in advance...

    Hello,
    For HR, you can do it using transaction SWEHR1 to define infotype 2007 as "triggerable". Then, use transaction SWEHR3 to link that object with an event.
    I got this from a website called SAPTechnical and I could not post the link here. Go to that website, then, click tutorials and select Business Workflow. Search for the word HR and you'll find an article on this.
    Regards,
    Abdullah Azzouni

  • How to avoid "DBIF_RSQL_SQL_ERROR" while updating data to a ztable?

    Hi Friends,
    I am in urgent need of solution to reduce or come out DBIF_RSQL_SQL_ERROR at time of updating a Z table.
    the code are below mentioned.
    There is no inconsistency b/w table and internal table strcture.I also used commit work.Buat everthing is fail.
    "ORA-01438:
    11020   *LOGIC FOR CLAERING PREVIOUS RELEATED DATA IN TABLE
    11030     LOOP AT WA.
    11040       DELETE FROM YMATPRICNG WHERE WERKS = WA-WERKS.
    11050   *                         AND MATNR = WA-MATNR
    11060   *                         AND MAKTX = WA-MAKTX.
    11070   *                         AND V_BPMNG = WA-V_BPMNG
    11080   *                         AND V_BAMNG = WA-V_BAMNG
    11090   *                         AND V_INCREASE = WA-V_INCREAS
    11100   *                         AND V_DECREASE = WA-V_DECREAS
    11110   *                         AND INCREASE1 = WA-INCREASE1
    11120   *                         AND DECREASE1 = WA-DECREASE1
    11130   *                         AND NET = WA-NET.
    11140   COMMIT WORK.
    11150     ENDLOOP.
        >     MODIFY YMATPRICNG FROM TABLE WA.
    11170     COMMIT WORK.
    Please suggest me as soon as possible.

    Hi,
    I am deleting the first record which are already existing b'z I want only latest value update corresponding plant and material.
    And I had declared WA as a internal table type of ymatpricng table only.And again If put up few record to selection screen via material no,It update successfully.
    Only thing is that why it get cancelled with thsi dump showing that nametab and abap/4 is not consistent or buffer is out of time.
    The problem has arisen because, within the database interface,
    one of the data buffers made available for the INSERT (UPDATE)
    is longer than the maximum defined in the database.
    On the other hand, it may be that the length in the NAMETAB
    does not match the maximum length defined in the database.
    (In this case, the length in the NAMETAB is longer.)
    Regards
    Ricky

Maybe you are looking for

  • I can't import images from the web into my iphoto 8

    I installed snow leopard a few weeks ago and when I try to click on an image on a website like a friends photo from myspace, and drag it to my Iphoto's icon in my dock it gets rejected, But I was able to do that very same thing before and it would wo

  • Problem with 2.0.1 update

    So I went to do my update to 2.0.1 on my first gen and something went horribly terribly wrong. It was unable to install completely and sent the phone into recovery mode. I attempted to do a restore and all I get is an unknown error. So, I have a coup

  • Creating Employee with Foreign currency

    HI HR gurus Our company code currency is INR and till now employees were paid in INR. Now we got new requirement that is , we have to create some new employees with currency SGD (Singapore dollar) . with this we want to generate all MIS in SGD only .

  • Oracle Heterogeneous Services to create link With Excel spreadsheet.

    Hi Please adivse how to use "Oracle Heterogeneous Services" to create a database link from Oracle to the Excel spreadsheet. Wishes Jawad

  • MBAM 2.5 Unable to find compatible TPM despite TPM available and device encrypted

    We have just installed and are piloting MBAM 2.5. Everything seems to have gone fine, machines are checking in getting policies, encrypting as they are supposed to and we can query MBAM for recovery keys and TPM passwords to do recoveries as needed.