Problem regarding Update-Statement on se11 table

Hello I tried to update a dataset in a se11 table using UPDATE Statement.
It doesn't work and I get a sy-subrc = 4.
That is my code:
TABLES ZTDM_SAPOUTPUT.
* Arbeitsbereich definieren
DATA:
wa_ZTDM_SAPOUTPUT LIKE ZTDM_SAPOUTPUT.
wa_ZTDM_SAPOUTPUT-PK = '1'.
wa_ZTDM_SAPOUTPUT-FNCODE = '3'.
wa_ZTDM_SAPOUTPUT-MATNR = '3'.
wa_ZTDM_SAPOUTPUT-MAKTX = '3'.
wa_ZTDM_SAPOUTPUT-ZEINR = '3'.
wa_ZTDM_SAPOUTPUT-MATKL = '3'.
wa_ZTDM_SAPOUTPUT-STATE = '1'.
UPDATE ZTDM_SAPOUTPUT FROM wa_ZTDM_SAPOUTPUT.
Write: 'UPDATE returned' , sy-subrc.
SKIP.
The given Dataset having PK=1 doesn't get updated.
Maybe my understanding is wrong:
Is it correct that the updated dataset ist defined by the primary key in this workingarea?
My Primary Key is PK.
Can you see the error?

UPDATE  dbtab      FROM wa. or
UPDATE (dbtabname) FROM wa.
Changes one single line in a database table, using a primary key to identify the line and taking the values to be changed from the specified work area, wa. The data is read out of wa from left to right, matching the line structure of the database table dbtab. The structure of wa remains unchanged. This means that wa must be at least as wide (see DATA) as the line structure of dbtab, and have the same alignment. Otherwise, a runtime error occurs.
If either the database table, dbtab, or the work area, wa, contain Strings, wa must be compatible with the line structure of dbtab.
Example
Changing the telephone number of the customer with customer number '12400177' in the current client:
DATA   wa TYPE scustom.
SELECT SINGLE * FROM scustom INTO wa
  WHERE id = '12400177'.
wa-telephone = '06201/44889'.
UPDATE scustom FROM wa.
When the command has been executed, the system field SY-DBCNT contains the number of updated lines (0 or 1).
Examples
Update discount for the customer with the customer number '00017777' to 3 percent (in the current client):
DATA: wa TYPE scustom.
SELECT SINGLE * FROM scustom INTO wa
  WHERE id = '00017777'.
wa-discount = '003'.
UPDATE scustom FROM wa.
The Return Code is set as follows:
SY-SUBRC = 0:
The specified line has been updated.
SY-SUBRC = 4:
The system could not update any line in the table, since there is no line with the specified primary key.
rwrd if helpful
bhupal

Similar Messages

  • Problem in Update Statement

    I got some problem in update statement.Can anybody discuss with me regarding my problem? Below is the occured problem.
    //all the declaration like Connection, ResultSet are declared, setting the ODBC path and so on steps have been set up before this method. When compile it, no error, when I start to run my program, the program�s interface is shown, but the following error was appearred and data cannot be updated, can anybody tell me where is my mistake?
    //ERROR:SQL Error in update statement:java.sql.SQLException [Microsoft][ODBC][ODBC Microsoft Access Driver] Syntax Error in UPDATE statement.
    //emp_overview is the table name
    // last_name, first_name, office_phone�.is the attributes of the table
    //this method had declare in the interface class already
    public String updateData (String idd, String ln, String fn, String op,
                   String oe, String hp, String ps, String ss)
                   throws java.rmi.RemoteException
         {//begin of this method
              String result ="";
              try
              Statement statement = connection.createStatement();
              String sql = "UPDATE emp_overview SET" +
              "last_name=' "+ln+
              " ', first_name=' "+fn+
              " ', office_phone=' "+op+
              " ', office_ext=' "+oe+
              " ', home_phone=' "+hp+
              " ', primary_skill=' "+ps+
              " ', secondary_skill=' "+ss+
              " ' WHERE id="+idd;
              statement.executeUpdate(sql);
              statement.close();
              catch (java.sql.SQLException e)
         System.out.println("SQL Error in update statement: "+e);
              //throw a RemoteException with the exception
              //embedded for the client to receive
         throw new java.rmi.RemoteException("Error in Updating exist row into DB", e);
              return result;
         }//end of this method

    Hi Kevin,
    According to the code you have posted, it looks like you are missing a space between "SET" and "last_name". I suggest you add the following line of code:
    System.out.println(sql);
    before the invocation of "executeUpdate()".
    I also suggest you add the following line of code:
    e.printStackTrace();in your "catch" block.
    Hope this helps.
    Good Luck,
    Avi.

  • Update statement in Internal Table

    Plz tell me the syntax and e.g. of update statement in Internal Table program
    Moderator message: Welcome to SCN, please research yourself before asking basic questions.
    Edited by: Thomas Zloch on Feb 25, 2010 12:47 PM

    Hi,
    Use UPDATE statement , check below description from SAP help.
    UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab.
    Effect
    Mass update of several lines in a database table.Here, the primary key for identifying the lines tobe updated and the values to be changed are taken from the lines of theinternal table itab. 
    The system field SY-DBCNT contains the number of updated lines,i.e. the number of lines in the internal table itab which havekey values corresponding to lines in the database table.
    Regards
    L Appana

  • Problem in Update statement using Execute Immediate

    Hi All,
    I am facing problem in update statement.
    I am creating dynamic sql and use "execute immediate" statement to execute a update statement.
    But it is not updating any thing there in the table.
    I have created a query like :
    update_query='Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
    Execute immediate update_query using V_Id;
    commit;
    But it is not updating the table.
    I have a question , is execute immediate only does insert and delete?
    Thanks
    Ashok

    SQL> select * from t;
                     TID P
                     101 N
    SQL> declare
      2     V_Id          number := 101;
      3     Table_Name    varchar2(30) := 'T';
      4     update_query  varchar2(1000);
      5  begin
      6     update_query := 'Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
      7     Execute immediate update_query using V_Id;
      8     commit;
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> select * from t;
                     TID P
                     101 Y                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Problem in UPDATE statement In Multiple Record Block

    Hi Friends,
    I have problem in update Statement for updating the record in multiple record data Block.
    I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
    I am inserting the fields like category,and post_no for partiular job in single data block
    Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
    There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
    then its updating all the record.
    my code is Bellow,
    IF v_count 0 THEN
    LOOP
    IF :SYSTEM.last_record 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
    :POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    next_record;
    ELSIF :SYSTEM.last_record = 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
    :POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    EXIT;
    END IF;
    END LOOP;
    SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
    v_button_no := SHOW_ALERT('user_alert');
    FORMS_DDL('COMMIT');
    CLEAR_FORM(no_validate);
    Please Guide me
    Thanks in advence

    As you do a loop over all the records in the block, of course every record is updated.
    Also, what you do is not the way is intended to be used. In general, you base a block on a table,then there is no need at all for writing INSERT's or UPDATE's. Forms also know's then, which records to be updated and which not.

  • Problem In Update Statement In Multiple Record Data Block

    Hi Friends,
    I have problem in update Statement for updating the record in multiple record data Block.
    I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
    I am inserting the fields like category,and post_no for partiular job in single data block
    Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
    There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
    then its updating all the record.
    my code is Bellow,
    IF v_count <> 0 THEN
    LOOP
    IF :SYSTEM.last_record <> 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
    :POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    next_record;
    ELSIF :SYSTEM.last_record = 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
         VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
              :POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    EXIT;
    END IF;
    END LOOP;
    SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
    v_button_no := SHOW_ALERT('user_alert');
    FORMS_DDL('COMMIT');
    CLEAR_FORM(no_validate);
    Please Guide me
    Thanks in advence

    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;These update statements are without where clause, so it will update all records.
    If it is specific to oracle forms then u may get better help at Forms section.

  • Regarding "Update .. From Table" Statement

    Hi,
    I have an existing piece of code which I'm trying to understand.
    There are two scenarios regarding the UPDATE statement.
    1) Scenario 1:
    There exists a database table with around 100 or more fields/columns [Eg: DB_TABLE1].
    An Internal Table exists with the same key as the above database table [EG: I_TABLE1].
    code:
    loop at I_TABLE1.
      update DB_TABLE1
      set kf1 = I_TABLE1-kfa
       kf2 = I_TABLE1-kfb
       kf3 = I_TABLE1-kfc
       kf4 = I_TABLE1-kfd
      where key1 = I_TABLE1-keya AND key2 = I_TABLE1-keyb.
    Endloop.
    In the above scenario the records in database table [DB_TABLE1] with matching condition are updated and the rest of the fields are not touched.  - Correct me if I am wrong.
    2) Scenario 2:
    There exists a database table with around 100 or more fields/columns [Eg: DB_TABLE1].
    Two Internal Tables exist with the same key as the above database table [EG: I_TABLE1 And  I_TABLE2].
    Code part a:
    SELECT * FROM DB_TABLE1 INTO TABLE I_TABLE2
          WHERE  KF1 <> 0.
    Internal Table 1 has some data.
    Code part b:
    loop at I_TABLE1.
      update DB_TABLE1
      set kf1 = I_TABLE1-kfa
       kf2 = I_TABLE1-kfb
       kf3 = I_TABLE1-kfc
       kf4 = I_TABLE1-kfd
      where key1 = I_TABLE1-keya AND key2 = I_TABLE1-keyb.
    Endloop.
    Code part c:
    update DB_TABLE1 FROM TABLE I_TABLE2.
    In the second scenario what will be the final effect of DB_TABLE1?
    As i understand it, there is no use of Code part b. Am I right?
    I thought that the records in I_TABLE2 with matching key in DB_TABLE1 will be updated and the rest of the records will be deleted.
    But actually there is not change in the DB_TABLE1 when the above code is executed.
    Help is appreciated.
    Thanks.

    Hi Joey,
    Scenario 1: In the above scenario the records in database table DB_TABLE1 with matching condition are updated and the rest of the fields are not touched.
    - That's right.
    Scenario 2: As i understand it, there is no use of Code part b.
    - Exactly because of the following reasons:
    1. Code part a shows data selected from DB_TABLE1 INTO TABLE I_TABLE2.
    2. Code part c shows DB_TABLE1 updated from TABLE I_TABLE2 whereas Code part b uses ONLY internal table I_TABLE1.
    3. If there are any operations performed in Code Part b on 'I_TABLE2', then this would have been different.
    Regards,
    Pranav.

  • Problem regarding updation of Z-table through maintenance view

    hi ,
    I m facing problem in updation of Z-table through maintenance view (SM30).
    The scenario is that I have one customizing field in my Z-table which is checkbox.
    Now I need to populate 2 fields in Z-table on tick of this checkbox and clicking of SAVE button.
    For this I have created one module  ''change_field''  in PAI.
    Actually my database table is being updated but as soon as the control left my module all the updation that take place vanishes away.....
    So please help me in this matter.

    Thanks for ur previous effort it is updating the database but its effect is not shown immediately on screen.After i referesh the transaction it is dispalying the data.
    So can u please suggest me any way....
    Now i have one scenario infront of me....
    I need to restrict the data shown in maintenance view.
    I think it would be same as pop-up window displayed when we tick on 2nd radiobutton ("ENTER CONDITIONS")
    of intial screen of t-code SM30.
    Please suggest what shud i do....
    Thanks and reagrds,
    Amit
    Edited by: amit gupta on Jul 18, 2008 1:35 PM

  • Emergency: problem with update statement!

    hello guys, i have a very serious problem with an update statement in pl/sql.
    i had an application written in sybase, where i had the following update statement:
    update mis_dik_adeia
    set trexon_etos_days = days_per_year
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_dik_adeia.adeia_id between :aapo and :aews
    and mis_dik_adeia.employee_id = :erg
    and mis_dik_adeia.etos = :etos
    and mis_plafon_adeivn.years_yphr = ( select max( a.years_yphr ) from mis_plafon_adeivn a where a.adeia_id = mis_plafon_adeivn.adeia_id and a.years_yphr <= :eth ) using sqlca;
    This is working properly in sybase. When i copied this code in pl/sql it displayed me error and it's impossible to work. Then i thought to make a nested select statement like this:
    update mis_dik_adeia
    set trexon_etos_days = (select days_per_year
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    but as you can understand, it is working, but it doesn't produce the same results as the update statement in Sybase!
    It is very important for me to solve this problem , which is a very big trouble for me for a long time.
    Please if anyone can help me i would appreciate it a lot!
    Regards ,
    Bill...

    Bill,
    folowing the logic of your original query by Sybase
    (it's embedded SQL in Power Builder, isn't it ?):
    update mis_dik_adeia
    set trexon_etos_days = (select days_per_year
    from mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    where
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and
    exists (select 1
    from mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    In 9i you can also try the following:
    megre into mis_dik_adeia
    using (
    select
    days_per_year,
    mis_dik_adeia.rowid rid
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr =
    (select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth)
    ) src
    on (mis_dik_adeia.rowid = src.rid)
    when matched then
    update set mis_dik_adeia.trexon_etos_days = src.days_per_year
    when not matched then
    insert (mis_dik_adeia.adeia_id) values(0);
    In 10G it can be easily:
    megre into mis_dik_adeia
    using (
    select
    days_per_year,
    mis_dik_adeia.rowid rid
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr =
    (select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth)
    ) src
    on (mis_dik_adeia.rowid = src.rid)
    when matched then
    update set mis_dik_adeia.trexon_etos_days = src.days_per_year;
    I have to notice I didn't check it carefully, so I can miss...
    Rgds.
    Corrected a mistake in the table name
    Message was edited by:
    dnikiforov

  • Update statement for object table.

    Hi,
    I have created one type as
    Create type test as object(
    ins_by varchar2(30),
    ins_on date,
    upd_by varchar2( 30),
    upd_on date);
    and then created an object table as
    create table imst(
    i_code number(5),
    i_desc varchar2(35),
    i_op test);
    now i am able to insert record in this table as
    insert into imst values(1,'Hawkins cooker',test(user,sysdate,'',''));
    Above works fine.
    But I would also like to update the record with i_op.upd_by,i_op.upd_on with some other values.
    Can any body help me specifying how to write a plain update statement for the same.
    Regards.
    Soumen

    Check it out:
    SQL> Create type myTest as object(
      2  ins_by varchar2(30),
      3  ins_on date,
      4  upd_by varchar2( 30),
      5  upd_on date);
      6  /
    Type created.
    SQL> create table imst(
      2  i_code number(5),
      3  i_desc varchar2(35),
      4  i_op myTest);
    Table created.
    SQL> insert into imst values(1,'Hawkins cooker', mytest(user,sysdate,'',''));
    1 row created.
    SQL> select * from imst;
        I_CODE I_DESC
    I_OP(INS_BY, INS_ON, UPD_BY, UPD_ON)
             1 Hawkins cooker
    MYTEST('APC_LOAD', '12-JUL-04', NULL, NULL)
    SQL> update imst i set i.i_op.upd_by = USER, i.i_op.upd_on = add_months(sysdate, 1);
    1 row updated.
    SQL> select * from imst;
        I_CODE I_DESC
    I_OP(INS_BY, INS_ON, UPD_BY, UPD_ON)
             1 Hawkins cooker
    MYTEST('APC_LOAD', '12-JUL-04', 'APC_LOAD', '12-AUG-04')
    SQL> Smoke me a kipper I'll be back before breakfast.
    Cheers, APC

  • Problem with update statement

    Hi, i have the following data
    document_seq_num, Country, LE, SOB
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    i want an update statement for every change in the document sequnce with the other combination..
    the seqence number should change.
    i tried to write a rank over partion and and sequence but when i am trying to update, this is always updating
    90000000 in first run, as it is in loop for all records it is updating the same. i want an
    increment to the sequence for every change in document_seq_num
    Can any one help me to correct this procedure
    create or replace PROCEDURE test is
    cursor cur_voc_ref
    IS SELECT a.document_seq_num,
    a.country, a.LE, a.SOB, 2009, Rank() over (partition by
    a.country, a.LE, a.SOB
    order by a.document_seq_num, a.country, a.LE, a.SOB)
    from (select distinct document_seq_num,
    country, LE, SOB,period_name
    from temp_tab
    where country= 'NL'
    and LE= '000320'
    and SOB=13
    order by SOB,LE,document_seq_num) a
    where
    a.country= 'NL'
    and a.LE= '000320'
    and a.SOB=13
    and substr(a.period_name,5,6) =substr(2009,3,4);
    v_base number;
    BEGIN
    FOR c_rec IN cur_voc_ref
    LOOP
    BEGIN
    select nvl(max(ggtsi.reference), substr(2009,3,2)*1000000) into v_base
    from temp_tab ggtsi;
    update temp_tab
    set reference= v_base
    where document_seq_num= c_rec.document_seq_num
    and country=c_rec.country
    and le=c_rec.le
    and sob=c_rec.sob;
    commit;
    END;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line( 'Exception in opening balance insert ' || SQLCODE || ' ' || SQLERRM );
    END;

    user11289444 wrote:
    Hi, i have the following data
    document_seq_num, Country, LE, SOB
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    i want an update statement for every change in the document sequnce with the other combination..
    the seqence number should change.
    i tried to write a rank over partion and and sequence but when i am trying to update, this is always updating
    90000000 in first run, as it is in loop for all records it is updating the same. i want an
    increment to the sequence for every change in document_seq_num
    Can any one help me to correct this procedure
    create or replace PROCEDURE test is
    cursor cur_voc_ref
    IS SELECT a.document_seq_num,
    a.country, a.LE, a.SOB, 2009, Rank() over (partition by
    a.country, a.LE, a.SOB
    order by a.document_seq_num, a.country, a.LE, a.SOB)
    from (select distinct document_seq_num,
    country, LE, SOB,period_name
    from temp_tab
    where country= 'NL'
    and LE= '000320'
    and SOB=13
    order by SOB,LE,document_seq_num) a
    where
    a.country= 'NL'
    and a.LE= '000320'
    and a.SOB=13
    and substr(a.period_name,5,6) =substr(2009,3,4);
    v_base number;
    BEGIN
    FOR c_rec IN cur_voc_ref
    LOOP
    BEGIN
    select nvl(max(ggtsi.reference), substr(2009,3,2)*1000000) into v_base
    from temp_tab ggtsi;
    update temp_tab
    set reference= v_base
    where document_seq_num= c_rec.document_seq_num
    and country=c_rec.country
    and le=c_rec.le
    and sob=c_rec.sob;
    commit;
    END;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line( 'Exception in opening balance insert ' || SQLCODE || ' ' || SQLERRM );
    END;Hi,
    I suggest you to add a column to preserve current RANK value for all rows, <preserve_rank> for example, and
    when you add the new rows you will update your <preserve_rank> but you must pay attention to have the same value for
    document_seq_num, with other words you may insert yours rows in a batch like this:
    -- first update preserve_rank with RANK function
    declare
    v_doc_seq_num numeric;
    begin
    v_doc_seq_num:=33100040;
    -- note !!!
    -- put all into a valid sql command
    -- and apply execute immediate
    insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
    insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
    insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
    -- update preserve_rank
    update temp_tab x  set x.preserve_rank = (Select max(preserve_rank) from temp_tab y
                                              where y.document_seq_num=v_doc_seq_num) old_rank + 1)
    where (prserve_rank is null) and x.document_seq_num=v_doc_seq_num;
    end;  I know it's a lost a memory but the trigger is the last solution who can give us a nightmare.
    Regards,
    Ion
    Edited by: user111444777 on Sep 25, 2009 11:12 AM
    Edited by: user111444777 on Sep 25, 2009 11:35 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

  • Possible to check how much time an update statement on a table would take ?

    Hello @all
    I have a table with a fragmented Index, the table has an actula "user_updates" from 226'699.
    How can i find out how much time an update on this table takes ?
    i would like to check if there is any performance increase when i regroup the index (rebuild), cause the index has a fragementation of 85% now... (or should i delete the index completely) cause there are no user_seeks... only user_updates on the table...
    and i thought that indexes only makes sense if users are reading from the table... am i wrong ? (cause on every update from the table, the index (indexes) have to be updated too...
    Thanks and Regards
    Dominic

    Rebuilding the index will not likely result in a modification be quicker. At least not more than marginal. In fact, it might wven be slower, since if you currently have space on the index page for the new row and then rebuild so you *don't* have space then
    the index rebuild will make that update be slower (at least for the cases where you get page splits). 
    However if the index isn't used to find rows (any of the other three columns), then you have an index which only cost you and doesn't help you!
    Tibor Karaszi, SQL Server MVP |
    web | blog
    Tibor, check out this forum thread:
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/64ad4f52-2fd8-4266-b4a4-5657c8870246/needed-more-answerers?forum=sqlgetstarted
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Problem in updating of standard database tables( S011, S012, S013).

    Hi Gurus,
    Here i am having the probelm with these transactions MCE1, MCE3, MCE5, MCE7.
    In these t-codes we are not able to get Purchase Order Values... Please help me out from this ... To get the PO Value what should i do .... there PO values are showing '0.00' (Zero)..
    These t-codes  are using S011, S012, S013 tables, in those tables also PO value is not updating ( in these tables field NETWR is showing Zeros only)
    this is urgent for my client... 
    Rewards in advance....
    Regards,
    Naveen Myneni

    This is not ABAP but configuration issue. I'd suggest to contact your MM consultant or move this question to MM area.

  • Problems with Update Statement

    How Can I combine these three statements into one single statement.. Heard that I can use Decode command over here... But dont know whether that was correct or not..
    Appreciate ur help..
    UPDATE LOTIDS_FINAL SET TEAM = 'MLA' WHERE SUBSTR( EXPT,1) = 'A';
    UPDATE LOTIDS_FINAL SET TEAM = 'AMD' WHERE SUBSTR( EXPT,1) = 'D';
    UPDATE LOTIDS_FINAL SET TEAM = 'TMP' WHERE SUBSTR( EXPT,1) = 'G';
    I want these three statements to one statement which can reduce my full table scans from 3 times to 1 time (I think)

    Try this:
    UPDATE LOTIDS_FINAL
    SET TEAM = DECODE (SUBSTR( EXPT,1,1), 'A', 'MLA', 'D', 'AMD', 'G', 'TMP', TEAM)
    WHERE SUBSTR( EXPT,1,1) in ( 'A', 'D', 'G');

Maybe you are looking for

  • IPAD/IPOD playing music to a Airport Express - No Sound?

    I have an IPAD and an IPOD.  IPAD is 4th gen, IOS7.  IPOD is 4th gen, IOS6. Airport express is the new one second generation.  Airport Express is wired to my home network, and its in bridged mode with wireless off.  Its purpose is only to play music

  • How to generate a simpler version of container.xsd . Tool and steps, please

    Hello, Let see if I'm able to express correctly the help I need... Some tutorials, for example FileDebatching (FileAdapter) or FTPDebatching (FtpAdapter) use the container.xsd file as an XMLschema. I think this file is based in the container.txt file

  • Reflect changes of 3KEH table in PCA

    Dear experts, I've added a new account to 3KEH table and obviously SAP is transferring the values of this GL to PCA for all postings that were posted after the table 3KEH update. But in this way the document posted to that account before the table up

  • Auto Email to vendor for followup balance quantity deliver

    Hi All, Auto Email to vendor for followup balance quantity deliver, I have an requirement that Auto email to vendor for reminder with some fixed days (example : 10 days), Please suggest me any configurations for this and suggest me how to proceed on

  • I/O Slave processes

    Dear friends, Can anybody explain the parameters used for large pool, and the function/definition of I/O Slave processes, used in Recovery manager. Thanx a lot