Update Likp table from HUPAST

I've a scenerio where i've to updated LIKP table, when user save the HUPAST. I've created the BDC program which update the likp table using VL02N transacton. but when i'm calling the BDC from a BADI its giving a error, as i'm trying to update the same delivery number. (Delivery already updated by user).
I'm now trying using events, i've traced an event CHANGED in object type LIKP , which is fired when HUPAST is saved.
How do i update the event changed ??? and call the bdc program from the event.
pls share .
Sanju

hi,
You can do it PAI under module USER_COMMAND. and you can use standard UPDATE/MODIFY/DELETE statements to update ur database table and make sure u use a commit work after the use of ablove mentioned statements.
kindly check this.
PROCESS BEFORE OUTPUT.
MODULE status_9010.
LOOP WITH CONTROL tab_control.
MODULE move_data_to_table.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP WITH CONTROL tab_control.
MODULE move_data_from_table.
ENDLOOP.
*& Module move_data_to_table OUTPUT
This is to move the data from the internal table to the table control
MODULE move_data_to_table OUTPUT.
This is to move the data from the internal table to the table control
zmpets_mode-modecode,zmpets_range-rangeid,zmpets_servfacto-factor are column name of table control
READ TABLE int_factor INDEX tab_control-current_line.
IF sy-subrc = 0.
zmpets_mode-modecode = int_factor-modecode.
zmpets_range-rangeid = int_factor-rangeid.
zmpets_servfacto-factor = int_factor-factor.
ENDIF.
ENDMODULE. " move_data_to_table OUTPUT
*& Module move_data_from_table INPUT
Date is moved from the table control to the Internal Table
MODULE move_data_from_table INPUT.
To move the data from the table control to internal table 'INT_FACTOR'.
int_factor-modecode = zmpets_mode-modecode.
int_factor-rangeid = zmpets_range-rangeid.
int_factor-factor = zmpets_servfacto-factor.
*here if the data is there, it will modify
MODIFY int_factor INDEX tab_control-current_line.
IF sy-subrc NE 0. "data not exixting in table control . ie new data, then append it
APPEND int_factor.
CLEAR int_factor.
ENDIF.
ENDMODULE. " move_data_from_table INPUT
Also refer to this link:
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5e35c111d1829f0000e829fbfe/content.htm
<b>Reward points if found helpful…..
Cheers,
Chandra Sekhar.</b>

Similar Messages

  • Is it possible to update internal table from database table

    Hello All:
              I know how to update database table from internal table in one shot (batch) but is the reverse possible? Can I update some fields in an internal table from a database table in one shot (without looping) because my internal table is huge? Could you please provide me any ideas how to acheive something like this? Thanks in advance and answers will be rewarded.
    thanks.
    Mithun

    Hello my friend,
    You can do it MAYBE , i think you can reverse the update doing a ROLLBACK, but only after you update....not after the program finishes..
    To update some fields at once use:
    UPDATE DBTABLE FROM TABLE IT_TABLE
    Hope this helps!!
    Gabriel

  • Hi, Bapi or function module to update RBCO table from an internal table.

    I have a requirement to  update RBCO table from an internal table.  is there any Bapi or function module  or any other method other than update, modify statements.
    Moderator message: Welcome to SCN!
    Moderator message: please do more research before asking, show what you have done yourself when asking.
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
    Edited by: Thomas Zloch on Jul 12, 2011 12:28 PM

    I don't know if any FM exists for your requirement. But you may like to copy it into a custom table and modify it according to your enterprise needs.

  • How to update one table from another table?

    Hi,
    Please go through the case I am mentioning below and if possible try to provide with a solution.
    I am working on a report to generate cash flow forecast, where in one of the fields is "Payroll", in which its being mentioned as:
    In the selection screen: I am entering Project ID, profit Center and Period(in MM/YYYY format).
    Selection of all entries in table COSP for selected cost elements above, value type 1, version , all periods and for all selected WBS elements and all objects underneath.
    From this, update table COFP with information from COSP with value type 62 and same period.
    For updation of various fields the following information is being given.
    How should we update COFP?
    New entries per OBJNR/PERIO and HKONT are required via using the information from COSP:
    COFP-MANDT              =          SY-MANDT
    COFP-KOKRS              =          if COSP-OBJNR begins with ‘PR’
                                                   Check table PRPS with COSP-OBJNR = PRPS-OBJNR and enter PRPS-PKOKR
                                                    If COSP-OBJNR begins with ‘NV’
                                                   Check table AFVC with COSP-OBJNR = AFVC-OBJNR,
    go to Table AFKO with AFVC-AUFPL,
    go to table AUFK with AFKO-AUFNR and enter AUFK-KOKRS
    If COSP-OBJNR begins with ‘OR’
    Check table AUFK with COSP-OBJNR = AUFK-OBJNR
    and enter AUFK-KOKRS
    COFP-BELNR               =          Check table NRIV, CLIENT = SY-MANDT, OBJECT = RK_BELEG,
    SUBOBJECT = COFP-KOKRS, NRRANGENR = ‘05’,
    Add 1 to NRLEVEL and begin with 500000000
    Use same BELNR for one update-run
    COFP-BUZEI                =          ‘1’ + and 1 in next entry but same update-run
    COFP-TWAER              =          COSP-TWAER
    COFP-ZHLDT                =          always last day of month in field COFP-PERIO
    COFP-GJAHR               =          COSP-GJAHR
    COFP-PERIO               =          if entry in field WKG001 à PERIO = 001
                                                   If entry in field WKG006 à PERIO = 006……
    COFP-WRTTP              =          ‘62’
    COFP-VRGNG              =          ‘FIPL’
    COFP-POSIT                =          Check table SKB1 where SAKNR = COSP-KSTAR and use SKB1-FIPOS
                                                   for going to table FMCI-FIPOS and enter FMCI-POSIT
    COFP-OBJNR               =          COSP-OBJNR
    COFP-HKONT              =          COSP-KSTAR
    COFP-WKGBTR           =          WKGXXX
    COFP-WKGBTRO         =          -
    COFP-WTGBTR            =          WTGXXX
    COFP-WTGBTRO         =          -
    COFP-WOGBTR           =          WTGXXX
    COFP-WOGBTRO        =          -
    COFP-BUKRS1            =          -
    COFP-GJAHR1             =          -
    COFP-BELNR1             =          -
    COFP-BUZEI1              =          -
    COFP-BUKRS2            =          -
    COFP-GJAHR2             =          -
    COFP-BELNR2             =          -
    COFP-BUZEI2              =          -
    COFP-EBELN               =          -
    COFP-EBELP               =          -
    COFP-ZEKKN               =          -
    COFP-ETENRM            =          -
    COFP-STUNR               =          -
    COFP-LIFNR                =          -
    COFP-KUNNR              =          -
    COFP-GSBER              =          -
    COFP-BUKRS              =          (nearly same as COFP-KOKRS!)
                                                   if COSP-OBJNR begins with ‘PR’
                                                   Check table PRPS with COSP-OBJNR = PRPS-OBJNR and enter PRPS-PBUKR
                                                    If COSP-OBJNR begins with ‘NV’
                                                   Check table AFVC with COSP-OBJNR = AFVC-OBJNR,
    go to Table AFKO with AFVC-AUFPL,
    go to table AUFK with AFKO-AUFNR and enter AUFK-BUKRS
    If COSP-OBJNR begins with ‘OR’
    Check table AUFK with COSP-OBJNR = AUFK-OBJNR
    and enter AUFK-BUKRS
    COFP-EINDT                =          -
    COFP-SGTXT               =          -
    COFP-GEBER              =          -
    COFP-KURSF              =          -
    COFP-KUFIX                =          -
    COFP-GBETR              =          -
    COFP-KURSR              =          -
    COFP-KURSFIKRS       =          -
    COFP-KZKRS               =          -
    COFP-UMBKZ              =          -
    COFP-KBLNR               =          -
    COFP-KBLPOS            =          -
    COFP-HI FIVOR            =          -
    COFP-LO FIVOR          =          -
    COFP-HI ACCOUNT      =          -
    COFP-LO ACCOUNT     =          -
    COFP-HI LIFNR            =          -
    COFP-LO LIFNR           =          -
    COFP-HI KUNNR          =          -
    COFP-LO KUNNR         =          -
    COFP-XDELETE           =          -
    COFP-HI XOPVW         =          -
    COFP-LO XOPVW        =          -
    COFP-ZAEHK               =          -
    COFP-CHAINBELNR     =          -
    COFP-MWSKZ             =          -
    COFP-LEDNR               =          -
    COFP-BELTP               =          ‘1’
    COFP-VERSN              =          ‘0’
    COFP-OWAER             =          COSP-TWAER
    COFP-CPUDT               =          SY-DATUM
    COFP-CPUTM              =          SY-TIME
    after doing updation, its again saying Selection of all entries in table COFP with value type 51 to 62, selected year, selected cost elements above and for all selected WBS elements and all objects underneath. Summarisation by period.
    Now, can someone help me as how to proceed with the entire thing? An elaborate and illustrative answer would be highly appreciable.
    If you require any other information....then get back to me ..asap.
    Its bit urgent.
    Thanks & Regards,
    Ravi

    Hi
    update <table> from <i_tab>
    for different conditions.
    loop at i_cosp.
    if cosp-mandt eq sy-mandt and  cosp-objnr eq 'PR'.
    Read table i_PRPS with key  i_PRPS-OBJNR = i_COSP-OBJNR.
    if sy-subrc eq 0.
    update PRPS set PKOKR = ? where objnr = i_prpr-objnr.
    endif.
    endif.
    similarly for all the conditions
    Regards
    Message was edited by: Harikishore Sreenivasulu

  • How to update one table from another

    I am creating scripts in Oracle 10g. I have a table that has data corruption on three date fields.
    I created a table with the following sql of all the affected rows:
    CREATE TABLE LSU_INTER_FIX_DATE AS
    select request_id,received_date,planned_start_date, actual_start_date
    from lsu_inter2_requests_t
    where received_date < to_date('01-JAN-1900')
    OR planned_start_date < to_date('01-JAN-1900')
    OR actual_start_date < to_date('01-JAN-1900')
    I then repaired all of the rows with three data fixes
    UPDATE LSU_INTER_FIX_DATE
    SET received_date = TO_CHAR(received_date,'YY-MON') ||'-'||(TO_CHAR(received_date,'RRRR') + 2000)
    where received_date < to_date('01-JAN-1900')
    UPDATE LSU_INTER_FIX_DATE
    SET planned_start_date = TO_CHAR(planned_start_date,'YY-MON') ||'-'||(TO_CHAR(planned_start_date,'RRRR') + 2000)
    where planned_start_date < to_date('01-JAN-1900')
    UPDATE LSU_INTER_FIX_DATE
    SET actual_start_date = TO_CHAR(actual_start_date,'YY-MON') ||'-'||(TO_CHAR(actual_start_date,'RRRR') + 2000)
    where actual_start_date < to_date('01-JAN-1900')
    I now want to update the original base table with the corrected data so I wrote the following SQL UPDATE command:
    UPDATE lsu_inter2_requests_t aaa
    SET aaa.received_date = bbb.received_date
    FROM LSU_INTER_FIX_DATE bbb WHERE aaa.request_id = bbb.request_id
    When I run this sql Oracle returns the error “ORA-00933 SQL command not properly ended.” How do I update multiple rows in one table from another table that share the same primary key?

    Comet wrote:
    I am creating scripts in Oracle 10g. I have a table that has data corruption on three date fields.
    I created a table with the following sql of all the affected rows:
    CREATE TABLE LSU_INTER_FIX_DATE AS
    select request_id,received_date,planned_start_date, actual_start_date
    from lsu_inter2_requests_t
    where received_date < to_date('01-JAN-1900')
    OR planned_start_date < to_date('01-JAN-1900')
    OR actual_start_date < to_date('01-JAN-1900')
    I then repaired all of the rows with three data fixes
    UPDATE LSU_INTER_FIX_DATE
    SET received_date = TO_CHAR(received_date,'YY-MON') ||'-'||(TO_CHAR(received_date,'RRRR') + 2000)
    where received_date < to_date('01-JAN-1900')
    UPDATE LSU_INTER_FIX_DATE
    SET planned_start_date = TO_CHAR(planned_start_date,'YY-MON') ||'-'||(TO_CHAR(planned_start_date,'RRRR') + 2000)
    where planned_start_date < to_date('01-JAN-1900')
    UPDATE LSU_INTER_FIX_DATE
    SET actual_start_date = TO_CHAR(actual_start_date,'YY-MON') ||'-'||(TO_CHAR(actual_start_date,'RRRR') + 2000)
    where actual_start_date < to_date('01-JAN-1900')
    I now want to update the original base table with the corrected data so I wrote the following SQL UPDATE command:
    UPDATE lsu_inter2_requests_t aaa
    SET aaa.received_date = bbb.received_date
    FROM LSU_INTER_FIX_DATE bbb WHERE aaa.request_id = bbb.request_id
    When I run this sql Oracle returns the error “ORA-00933 SQL command not properly ended.” How do I update multiple rows in one table from another table that share the same primary key?I am not convinced you have what you think you have
    >
    UPDATE LSU_INTER_FIX_DATE
    SET received_date = TO_CHAR(received_date,'YY-MON') ||'-'||(TO_CHAR(received_date,'RRRR') + 2000)
    where received_date < to_date('01-JAN-1900')
    When you want to produce a DATE datatype when starting with a string,
    you must use TO_DATE() on the SET line!
    (TO_CHAR(received_date,'RRRR') + 2000)since when do you do add characters (from TO_CHAR) with a constant number (2000)?
    You should NEVER EVER rely on implicit datatype conversion
    Edited by: sb92075 on Jul 27, 2011 7:09 PM

  • Update LIKP table while saving the output type in VT02N transaction

    Hi All,
    I have a requirement where i have to update Delivery Priority(LPRIO) field in LIKP table while saving the output type in VT02N transaction. I am not able to use the BAPI "BAPI_OUTB_DELIVERY_CHANGE" or FM "WS_DELIVERY_UPDATE" because, when we save the output type the programs that are configured in NACE are triggered in update mode and hence i will get a roll back error.
    Let me know other ways of updating the table at the time of saving output type for shipment transaction VT02N.

    This could be a result of one of the following reasons:
    1: Incorrect smart form/routine assigned in the output configuration (NACE)
    2: Serial number range of the delivery expired
    3: The default settings of the user (SU01) processing the delivery is missing the default printer name.
    Hope this is helpful
    Manish

  • Update a table from a view

    I'm a newbie and I would like any suggestions and help with my problem.
    I have a view, m_jobs, that is based on the view, sys.dba_jobs. I want to add a two fields, user_id and update, to keep track of user who is adding and modifying scheduled jobs. So I decided to create a table which has the two new fields and the same fields from m_jobs. I populated my new table with the values from m_jobs, but since I created a table, the values aren't always updated. How can I update the table whenever the values in my view change? Do I create a trigger for that and how would that go? Thanks in advance.
    -Kristine

    I interpret the question differently:
    A view is nothing more than a select statement on other tables. you cannot put triggers on it since it does not contain data (with the exception of 'instead of'-triggers, but they have a different meaning). What you should do is put a trigger on the underlying table(s) that dba_jobs is querying. That trigger should then populate your table.
    However, this is not recommended since it might interfere with Oracle normal operation (if your trigger fails (e.g. when your table is dropped), the original insert into the underlying dba_jobs table by Oracle will also fail potentially resulting in nasty problems with Oracle.
    Alternatively, you could make a job that checks for changes in the data and maintains the table. Or see if auditing can help (don't know if that is possible on Oracle internal tables).
    Hope this helps,
    L.

  • Updating a table from tabular form using a process

    Hi
    I have a tabular from creating using wizard
    I've a field called Last_updated_by in the table
    the username is assigned to an item P2_user based on the user who logs in.
    What I need is,when any row is updated, I need to update the last_updated column with value in p2_user.
    Need help on this
    I'm using apex 3.2 with 11g
    tried the below
    declare
    idx number:=1;
    begin
    FOR i in 1 .. wwv_flow.g_f01.COUNT
    LOOP
    for j in idx .. wwv_flow.g_f02.count
    loop
    update table_name set last_updated_by=:p2_user where ID=APEX_APPLICATION.G_F02(j);
    idx:=j+1;
    end loop;
    END LOOP;
    end;
    Its updating the table,but all the rows are getting updated,just not the selected rows.
    Not sure what I'm doing wrong here
    thanks
    Archana
    Edited by: Agowda on Jan 12, 2012 1:55 AM

    I am looking for the same... can you please share how did you got this working
    thanks

  • Updating a table from a collection

    I have some data in a collection that is meant to update a table
    I have a string of colon delimited column names like
    pk:age:height:weight
    The table contains the PK and the data for column names as per the string above.
    So,
    c001=pk
    c002=age
    c003=height
    c004=weight
    How can I loop thru the table and create/execute a UPDATE statement that updates
    those columns in a pre-specified table?
    Of course using bind variables as much as possible?
    Thanks

    thought you may do it easier by loop through collection in a process as ...
    for c in (select c001 pk, c002 age, c003 height, c004 weight
    from yur_collectioin
    where c.pk = c001) loop
    update yur_tbl set age = c.age ....
    where pk = c.pk
    end loop;
    Or you may "loop thru the table" and update in a process as ...
    for c in (select * from tbl) loop
    for cc in (select c001 pk, c002 age, c003 height, c004 weight
    from yur_collectioin
    where c.pk = cc.pk) loop
    update tbl set age = cc.age ....
    where pk = cc.pk
    end loop;
    end loop;
    Should not have mutation problem but I am not sure. Good luck.
    DC

  • Update USR table from Java Code outside OIM

    Hi,
    I want to update a particular field in the USR table using the update query specifically from the java code. I dont want use updateUser api.
    I have written the code which works fine for some userids. But for some user ids it gets the tcUtility object successfully but when trying to execute the update query, it throws the tcDatasetException with message as Data Access Error.
    Please let me know how can i achieve this.
    Also let me know the groups the userid should be member to execute a update query on OIM DB from external java code..
    TIA...

    You are performing an unsupported process. I suggest you correctly code a connection to OIM, and perform the update correctly.
    If you need to update the database directly, use jdbc java connection and run the update. You can do a google search for jdbc and java to find plenty of samples.
    -Kevin

  • Update cluster table from Web dynpro

    Hi
    I am trying to export data to a cluster table from web dynpro using this statement:
    EXPORT zhr_sanct_st100 FROM zhr_sanct_st100 TO DATABASE zhr_clrm(ep) ID zhr_clrm-srtfd.
    same piece of code work well if I include it in a report program through se38, but If I use it in Web dynpro, it doesnt update the cluster table and there is no error shown.
    please reply ASAP.
    Vishal kapoor

    Thanks for your immediate reply. it worked this way:
    IMPORT structure name TO structure name
      FROM DATABASE cluster table name
      TO wa_zhr_clrm
      ID zhr_clrm-srtfd.
    initially i missed to insert a work area wa_zhr_clrm, which has all the key fields of the cluster table.
    Regards
    Vishal Kapoor

  • Update user table from matrix

    Hi I've created a matrix in a new tab on the Item Master data form. It loads data from a user table called @Test. This table has 2 udf U_Model and U_Engine. The matrix uses a datatable to query the table. Is there a way to update the table? this is my code:
                   // Adding a Matrix item
                   oNewItem = oForm.Items.Add( "Matrix1", SAPbouiCOM.BoFormItemTypes.it_MATRIX );
                   oNewItem.Left = 5;
                   oNewItem.Width = 400;
                   oNewItem.Top = 200;
                   oNewItem.Height = 150;
                   oNewItem.FromPane = 8;
                   oNewItem.ToPane = 8;
                   oMatrix = ( ( SAPbouiCOM.Matrix )( oNewItem.Specific ) );
                   oColumns = oMatrix.Columns;
                   // Adding Culomn items to the matrix
                   oColumn = oColumns.Add( "#", SAPbouiCOM.BoFormItemTypes.it_EDIT );
                   oColumn.TitleObject.Caption = "#";
                   oColumn.Width = 30;
                   oColumn.Editable = false;
                oColumn = oColumns.Add("Code", SAPbouiCOM.BoFormItemTypes.it_EDIT);
                oColumn.TitleObject.Caption = "Code";
                oColumn.Width = 20;
                oColumn.Editable = true;
                oColumn = oColumns.Add("Name", SAPbouiCOM.BoFormItemTypes.it_EDIT);
                oColumn.TitleObject.Caption = "Name";
                oColumn.Width = 20;
                oColumn.Editable = true;
                oColumn = oColumns.Add("Model", SAPbouiCOM.BoFormItemTypes.it_EDIT);
                   oColumn.TitleObject.Caption = "Model";
                   oColumn.Width = 20;
                   oColumn.Editable = true;
                   // Add a column for Name
                   oColumn = oColumns.Add( "Engine", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX );
                   oColumn.TitleObject.Caption = "Engine";
                   oColumn.Width = 20;
                //Add Valid Values
                oColumn.ValidValues.Add("10", "");
                oColumn.ValidValues.Add("12", "");
                oColumn.ValidValues.Add("32", "");
                oColumn.ValidValues.Add("42", "");
                oColumn.ValidValues.Add("52", "");
                oColumn.ValidValues.Add("62", "");
                dbDatasource = (oForm.DataSources.DBDataSources.Add("@Test"));
                DBTable = (oForm.DataSources.DataTables.Add("MyDataTable"));
                   oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Single;
    oItem = oForm.Items.Item("5");
                oEdit = ((SAPbouiCOM.EditText)(oItem.Specific));
                string item = oEdit.Value.ToString();
                   oForm.DataSources.DataTables.Item( 0 ).ExecuteQuery( "SELECT Code, Name, U_Model, U_Engine from [@Test] where U_ItemCd = '" + item +"' ");
      oColumn = oColumns.Item("Code");
                oColumn.DataBind.Bind("MyDataTable", "Code");
                oColumn = oColumns.Item("Name");
                oColumn.DataBind.Bind("MyDataTable", "Name");
                   oColumn = oColumns.Item( "Model" );
                   oColumn.DataBind.Bind("MyDataTable", "U_Model");
                oColumn = oColumns.Item("Engine"); 
                   oColumn.DataBind.Bind("MyDataTable", "U_Engine");
                        oMatrix.Clear();
                        oMatrix.AutoResizeColumns();
                        oMatrix.LoadFromDataSource();

    Hi Costas,
    You can use Matrix.FlushToDataSource() to save the data in the Matrix into the datasource.
    But if you want to update the data in the DB, you have to use DI API.
    Regards,
    Jay.

  • How to update database table from Internal Table

    hi experts,
        Can anyone please assist me in inserting records to a database table from an Internal Table
    whose structures are identical.
    Thanks in Advance,
    Sudhaa............

    Hi Sudha,
    Here are some example of update and insert:
    UPDATE SFLIGHT SET PLANETYPE = 'A310'
    PRICE = PRICE - '100.00'
    WHERE CARRID = 'LH' AND CONNID = '0402'.
    This example overwrites the contents of the PLANETYPE column with A310 and decreases the value of the PRICE column by 100 for each entry in SFLIGHT where CARRID contains u2018LHu2019 and CONNID contains u2018402u2019.
    TABLES SPFLI.
    DATA WA TYPE SPFLI.
    MOVE 'AA' TO WA-CARRID.
    MOVE '0064' TO WA-CONNID.
    MOVE 'WASHINGTON' TO WA-CITYFROM.
    UPDATE SPFLI FROM WA.
    MOVE 'LH' TO SPFLI-CARRID.
    MOVE '0017' TO SPFLI-CONNID.
    MOVE 'BERLIN' TO SPFLI-CITYFROM.
    UPDATE SPFLI.
    CARRID and CONNID are the primary key fields of table SPFLI. All fields of those lines where the primary key fields are "AA" and "0064", or "LH" and "0017", are replaced by the values in the corresponding fields of the work area WA or the table work area SPFLI.
    DATA: ITAB TYPE HASHED TABLE OF SPFLI
    WITH UNIQUE KEY CARRID CONNID,
    WA LIKE LINE OF ITAB.
    WA-CARRID = 'UA'. WA-CONNID = '0011'. WA-CITYFROM = ...
    INSERT WA INTO TABLE ITAB.
    WA-CARRID = 'LH'. WA-CONNID = '1245'. WA-CITYFROM = ...
    INSERT WA INTO TABLE ITAB.
    WA-CARRID = 'AA'. WA-CONNID = '4574'. WA-CITYFROM = ...
    INSERT WA INTO TABLE ITAB.
    UPDATE SPFLI FROM TABLE ITAB.
    This example fills a hashed table ITAB and then overwrites the lines in SPFLI that have the same primary key (CARRID and CONNID) as a line in the internal table.
    Insert statement :
    TABLES SPFLI.
    DATA WA TYPE SPFLI.
    WA-CARRID = 'LH'.
    WA-CITYFROM = 'WASHINGTON'.
    INSERT INTO SPFLI VALUES WA.
    WA-CARRID = 'UA'.
    WA-CITYFROM = 'LONDON'.
    INSERT SPFLI FROM WA.
    SPFLI-CARRID = 'LH'.
    SPFLI-CITYFROM = 'BERLIN'.
    INSERT SPFLI.
    If the database table does not already contain a line with the same primary key as specified in the work area, the operation is completed successfully and SY-SUBRC is set to 0. Otherwise, the line is not inserted, and SY-SUBRC is set to 4.
    Regards,
    Premraj kaushik

  • Updating database table from an internal table

    Hi All,
    I am updating a database table from an internal table.
    I am changing the non-key fields in that table.
    when I check sy-subrc = 4.
    Record already exists, because I am changing non-key fields of the
    database table.
    Is there any addition like to accept the duplicate keys with update.
    Alternatively, I have used Modify, It is adding new record,
    Again, I have search the old record and use Delete on the database table.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP ABAP Consultant

    Hi,
    You are right, the field which I am trying to change is a part of primary key.
    Because, sy-subrc = 4. says,
    No line with specified primary key exits in the database table.
    I have a Z-tabel, with Kunnr Vkorg Matnr Bzirk Bztxt Split_percentage
    In this table primary key consists of KunnrVkorgMatnr+Bzirk.
    I am able to change the Split_percentage using UPDATE.
    Now, my client want to change Bzirk, Bztxt also in the table.
    How can I Go.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP ABAP Consultant

  • Updating database table from internal table

    I am updating the database table from internal table for this is have used the following syntax
    Update kna1 from table itab.
    And it is giving error message as the work are itab is not long enough.
    Please help me.

    Hi,
       Refer this code
    *&      Form  SUB_READ_UPDATE_BSEG
          text
    FORM sub_read_update_bseg.
      IF NOT it_final[] IS INITIAL.
        LOOP AT it_final INTO wa_final.
          UPDATE bseg SET zuonr = wa_final-ccnum
                      WHERE bukrs EQ wa_final-bukrs
                      AND   belnr EQ wa_final-vbeln
                      AND   rfzei EQ wa_final-rfzei
                      AND   saknr NE ' '.
        ENDLOOP.
    *--Message data updated successfully
        MESSAGE i888 WITH text-002.
        LEAVE LIST-PROCESSING.
      ELSE.
    *--Message No data found
        MESSAGE i888 WITH text-003.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " SUB_READ_UPDATE_BSEG
    Regards,
    PRashant

Maybe you are looking for