Update ztable from internal table

I want to update the Ztable from internal table datas.
what is the syntax to update.
Its urgent send with coding example is better

Hi
PARAMETERS: p_carrid TYPE sflight-carrid,
            percent(1) TYPE p DECIMALS 0.
DATA sflight_tab TYPE TABLE OF sflight.
FIELD-SYMBOLS <sflight> TYPE sflight.
SELECT *
       FROM sflight
       INTO TABLE sflight_tab
       WHERE carrid = p_carrid AND
             fldate = sy-datum.
IF sy-subrc = 0.
  LOOP AT sflight_tab ASSIGNING <sflight>.
    <sflight>-price =
      <sflight>-price * ( 1 - percent / 100 ).
  ENDLOOP.
ENDIF.
<b>UPDATE sflight FROM TABLE sflight_tab.</b>
Thanks
Vijay
PLZ reward points if helpful

Similar Messages

  • How to update Records from Internal table to u2018Zu2019 table?

    Hi Friends,
    How to update Records from Internal table to u2018Zu2019 table.
    I have records in Internal table , that records want to update on u2018Zmarau2019 Table.
    ( my internal table & u2018 Zu2019 table structures are same.)
    Thanking you.
    Regards,
    Subash

    Hi,
    loop at internal table.
    modify <Z- table > from values < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    endloop.
    or
    UPDATE <Z- table > from table < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    Prabhudas

  • Update databse from internal table statement not using index

    Hi Guys,
    We are updating a databse table from a file. The file has a couple of fields which have data different from what the database has (non-primary fields :). We upload the file data into an internal table and then update the database table from internal table. At a time, internal table is supposed to have 10,000 records. I did SQL trace and found that the update statement is not making use of the databse index.
    Should not the update statement here be using the table index (for primary key)?
    Regards,
    Munish

    ... as often there are recommendations in this forum which makes me wonder, how people overestimate their knowledge!!!
    Updates and Deletes do of course use indexes, as can be seen in the SQL Trace (use explain).
    Inserts don't use indexes, because in many databases inserts are just done somewhere, But also with the INSERT, the primary key is the constraint for the uniqueness condition, duplicate keys are not allowed.
    Coming to the original question, what is you actually coding for the update?
    What is the table, which fields are in the internal table and what are the indexes?
    Siegfried

  • Update ztable from database table directly

    hi all,
    can u tell me the possible ways to update a ztable from database table directly.
    i mean is there anyway to update ztable whenever entry is created in database table .
    i dont want to update using insert,modify statements.
    points will be rewarded to all hlpful answers.

    A slightly dirty solution:
    Use SAP functions for reading from CDHEADER and CDPOS tables [with enough filters such that you extract minimum records possible] to read changes to MARA table fields since last run of your program. Use this information to update your ZTABLE. I would recommend having a table maintainance generator on ZTABLE. The actual update should be by a BDC by calling transaction SM30 for ZTABLE maintainance. Now the program may be set up as a batch job running 1ce an hour. You get updates to the extent of 1 hour latency.
    Alternatively, you may look if an opportunistic BADI / user Exit is there alongside MM01/02 transactions - assuming the latter are the only ones updating MARA. In this BADI you may write the code to update ZTABLE- again, look to do it by BDC call transaction sm30 to maintain ZTable. To lighten up the code -load on BADI you may simply raise a custom event and move on. You will configure a job that runs your program when that particular event is raised. This will need the 'burden' of figuring out the changes, though.
    An elegant way would be to fire a MATMAS fIDOC for every change to Material, capture that and turn back the changes to ZTABLE. This will facilitate the delta load.

  • I need insert /update/modify  ztable from  internal table or work area

    I have one simple problem.
    TYPES: BEGIN OF t_account,
            acc_no          LIKE zztaccountheader-acc_no,
            cust_id         LIKE zztaccountheader-cust_id,
            acc_type        LIKE zztaccountheader-acc_type,
            od_option       LIKE zztaccountheader-od_option,
            od_limit        LIKE zztaccountheader-od_limit,
            od_issue_date   LIKE zztaccountheader-od_issue_date,
            END OF t_account.
    data: lwa_account TYPE  t_account,
         li_account TYPE STANDARD TABLE OF t_account,
    bu scerrin i am inputing data :
    i want modify updare or insert record into ztable by work area  i put following thing
    MOVE : zztaccountheader-acc_no        TO lwa_account-acc_no,
               zztcustomer-cust_id            TO lwa_account-cust_id,
               zztaccountheader-acc_type      TO lwa_account-acc_type,
               zztaccountheader-od_option     TO lwa_account-od_option,
               zztaccountheader-od_limit      TO lwa_account-od_limit,
               zztaccountheader-od_issue_date TO lwa_account-od_issue_date.
        INSERT   zztaccountheader CLIENT SPECIFIED FROM lwa_account .
        CLEAR lwa_account.
      ENDIF.
    i am etting error
    The type of the database table and work area (or internal table)
    "LWA_ACCOUNT" are not Unicode convertible.
    please solve it

    hi,
    decalre like this.
    tables : zztaccountheader.
    data : t_account like zztaccountheader occurs 0 with header line.
    data: lwa_account TYPE t_account,
    li_account TYPE STANDARD TABLE OF t_account,
    MOVE : zztaccountheader-acc_no TO lwa_account-acc_no,
    zztcustomer-cust_id TO lwa_account-cust_id,
    zztaccountheader-acc_type TO lwa_account-acc_type,
    zztaccountheader-od_option TO lwa_account-od_option,
    zztaccountheader-od_limit TO lwa_account-od_limit,
    zztaccountheader-od_issue_date TO lwa_account-od_issue_date.
    INSERT zztaccountheader CLIENT SPECIFIED FROM lwa_account .
    CLEAR lwa_account.
    ENDIF.
    rgss
    anver
    if hlped mark points

  • Modify ztable from internal table

    Hi,
    I have a Ztable in which i have 4 diff fields....1 2 3 4
       and an internal table in whch i have same number of fields...
    Internal table :
        1 2 3 4
        a w x 9
        a w x 10
        a w x 11
        a w x 13
        a w x 12
    When I am using Modify it only appends last record into ztable as below:
    Ztable :  1 2 3 4
               a w x 12
    Internal table has 6 records and z table should be appended with 6 records too...
      if varid-report  = 'ZFINRR1001' and
        varid-VARIANT = 'CITI - ZBA' or
         varid-VARIANT = 'WACHOVIA - ZBA'.
      Modify ZV12_SWEEP from t_data_new.
    endif.
    Any suggestions will be aprreciated!
    Regards,
    Kittu

    >
    Kittu wrote:
    >  When I am using Modify it only appends last record into ztable 

    >   Modify ZV12_SWEEP from t_data_new.
    Hi,
    You only get last record appended because your MODIFY statement uses t_data_new as a working area and not as a table.
    To append the content of your internal table, use the FROM TABLE option as below :
    MODIFY zv12_sweep FROM TABLE t_data_new.
    Regards.
    Nicolas

  • Update value from internal table into table control

    hi friends,
    i have two text field and a button in a screen.if give the value and click the button it should get updated in the table control which is in the next screen.plz
    help me with some sample coding.

    hi Karthik ,
    Here you go with the sample coding of moving internal table values to table control on module pool programs :
    in screen painter flow-logic ............
    process before output.
    module status_3000.
    loop at g_tab_con_01_itab
         into g_tab_con_01_wa
         with control tab_con
         cursor tab_con-current_line.
    module tab_con_move.
    endloop.
    process after input.
    module exit at exit-command.
    module user_command_3000.
    module clear_ok_code.
    loop at g_tab_con_01_itab.
    module read_tab_con.
    endloop.
    in your program .............
    include z_tab_ctrl_top                          .    " global Data
    program  z_tab_ctrl.
    tables : sflight,sbook,zsflight.
    types:begin of t_tab_con_01 ,
            carrid like sflight-carrid,
            connid like sflight-connid,
            sel type c,
           end of t_tab_con_01.
    data: g_tab_con_01_itab type  t_tab_con_01 occurs 0 with header line,
          g_tab_con_01_wa type t_tab_con_01,
          g_tab_con_01_copied ,
          g_tab_con_01_lines like sy-loopc,
          ok_code like sy-ucomm,
          lines type i,
          init ,
          fill type i.
    controls: tab_con type tableview using screen 3000.
    module status_3000 output.
      set pf-status 'ST100'.
      set titlebar 'T100'.
    endmodule. 
    module update_table_control input.
      describe table g_tab_con_01_itab lines tab_con-lines.
    endmodule.  
    module exit input.
      ok_code = sy-ucomm.
      if ok_code eq 'BACK' or ok_code eq 'EXIT' or ok_code eq 'CANCEL'.
        leave program .
      endif.
    endmodule.        
    module clear_ok_code input.
    clear ok_code.
    endmodule.      
    module fill_tab_con output.
    read table g_tab_con_01_itab into zsflight index tab_con-current_line.
    endmodule.                 " fill_tab_con  OUTPUT
    module read_tab_con input.
    *lines = sy-loopc.
    read table g_tab_con_01_itab into g_tab_con_01_wa index tab_con-current_line.
    if sy-subrc eq 0.
    move-corresponding sflight to g_tab_con_01_wa.
    modify g_tab_con_01_itab from g_tab_con_01_wa index tab_con-current_line.
    else.
    move-corresponding sflight to g_tab_con_01_wa.
    append g_tab_con_01_wa to g_tab_con_01_itab.
    endif.
    module tab_con_move output.
    move-corresponding g_tab_con_01_wa to sflight.
    endmodule.                 " tab_con_move  OUTPUT
    module tab_con_get_lines output.
    g_tab_con_01_lines = sy-loopc.
    endmodule.                 " tab_con_get_lines  OUTPUT
    module tab_con_modify input.
    move-corresponding sflight to g_tab_con_01_wa.
      modify g_tab_con_01_itab
          from g_tab_con_01_wa
          index tab_con-current_line.
    endmodule.                 " tab_con_modify  INPUT
    module populate_tab_ctrl input.
    if sy-subrc eq 0.
    endif.
    endmodule.
    Look at the following modules in the above program ....
    fill_tab_con
    tab_con_modify
    tab_con_get_lines
    update_table_control
    This will definately solve your problem or give an idea for solution ....
    reward if helpful,
    Regards,
    Ranjita

  • Updating ztable from the table maintenance

    hi,
           I want to knw how and where to check , whether the records which user has entered in the table control of new entries screen exists in the ztable table or not . if the same record exists then that record should not go for saving it shd be deleted when it is detected that it exists in the ztable . can any one tell me how . where and what code to be written . so that the duplicate entries are deleted and others entries get appended in the database.
    thank you.

    Hi
    if you have declared some Primary key fields then by default when you enter the records in the Table maintenance using SM30 it will not allow duplicate records with the same key fields
    You can check the Table entries in SE16 Tcode
    go to Se16 enter table name execute and see the table records
    Reward points for useful Answers
    Regards
    Anji

  • Need to update Ztable from final internal table

    Hi,
    ITAB   = Final internal table has 9 fields : 1 2 3 4 5 6 7 8 9
    Ztable = Ztable has 6 fields ex : 1 3 4 6 7 8
    Structure of both Itab and Ztable are different.
    I have data in the Final Internal table and needs to update data into a ztable.
    If condition is true...
      Modify ztable from itab
    endif.
    Any suggestions how I can update Ztable from the INternal table
    Regards,
    Kittu

    Hello,
    First keep the loop to the final internal table then move all the records to the work area after moving to workarea then create another workarea for the Ztable then move only the field values which are there in Ztable then use modify keyword.
    example
    move:
    y_wa_final_itab-kdauf to y_wa_zhr_item-vbeln,
    y_wa_final_itab-kdpos to y_wa_zhr_item-posnr,
    y_wa_final_itab-receiptno to y_wa_zhr_item-receiptno
    modify zhr_item from y_wa_zhr_item

  • How to update whole external table(in ABAP dictionary) from internal table at once

    Hi,
    How can I update the content of the external table (in ABAP dictionary) from the content of internal table data at once. I created the internal tables with out the header line, with the work area. I tried UPDATE TARGET_EXTERNAL_TABLE FROM TABLE INTERNAL_TABLE. But it returns 4 for sy-subrc and did not work.
    Thank you
    Regards.
    CHINTHAKA

    Hi Feiyun Wu,
    Thank you very much. Your code worked. Is there any way to replace the whole content of the external table from internal table data ?
    Regards,
    Chinthaka

  • 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

  • Can not insert or update [TABLE] from internal table in method

    I've faced a problem with OO abap. I've tried to insert into [ TABLE ] from internal table, but i've got error msg after i compiled.
    "An explicit work area is necessary in the OO context. Use "INSERT wa INTO [TABLE] itab""
    After  i changed to loop in work area and INSERT INTO  [TABLE] VALUES gw_data., everything is fine, can compile and run.
    This is error code.
      METHOD set_data_to_table.
        REFRESH gi_data.
        CLEAR gi_data.
        IF gi_file[] IS NOT INITIAL.
    * Set data for modify table
          LOOP AT gi_file INTO gw_file.
            MOVE-CORRESPONDING gw_file TO gw_data.
            me->conversion_input( EXPORTING im_vendor = gw_data-vendor
                                  CHANGING  ch_vendor = gw_data-vendor ).
            APPEND gw_data TO gi_data.
          ENDLOOP.
          INSERT [TABLE] FROM TABLE gi_data.
    *      LOOP AT gi_data INTO gw_data.
    *        INSERT INTO  [TABLE] VALUES gw_data.
    *        IF sy-subrc = 0.
    *          COMMIT WORK.
    *        ELSE.
    *          ROLLBACK WORK.
    *        ENDIF.
    *      ENDLOOP.
        ELSE.
          MESSAGE 'No data found' TYPE 'I'.
        ENDIF.
      ENDMETHOD.                    "set_data_to_table

    Hi Matthew,
    I think there is no difference in database insert between OO and non-OO.
    The correct syntax according to ECC600 online documentation is
    [Inserting Several Lines|http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm]
    To insert several lines into a database table, use the following:
    INSERT target FROM TABLE itab \[ACCEPTING DUPLICATE KEYS].
    This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
    Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.
    I think the syntax
    INSERT my_dbtable FROM TABLE gi_data.
    should work, your suggestion may lead to syntax error.
    Regards,
    Clemens

  • How to update Ztable from Excel file and how to check conditions ,

    HI this uday,
    pls help me how can i update Ztable from Excel file and how to check conditions .
    regards
    uday
    Moderator message: please (re)search yourself before asking.
    Edited by: Thomas Zloch on Jul 13, 2010 12:00 PM

    Hi
    Use Fm : ALSM_EXCEL_TO_INTERNAL_TABLE.
    L_INTERN : internal table with your fields .
    make sure that the fields in the Excel should be formatted (as numeric , characher ) depending upon the data types .
    LOOP AT L_INTERN INTO WA_LINTERN .
            MOVE WA_LINTERN-COL TO L_INDEX.
            ASSIGN COMPONENT  L_INDEX OF STRUCTURE WA_INREC TO <FS> .
            IF SY-SUBRC = 0.
              MOVE WA_LINTERN-VALUE TO <FS>.
            ENDIF.
            AT END OF  ROW .                                    "#EC *
              APPEND WA_INREC TO IT_DATA.  "
              CLEAR WA_INREC.
            ENDAT.
         ENDLOOP.
    Regards
    Swapnil

  • To get recent timestamp records from internal table

    hi all,
      i have one requirment
      i'm storing error messages in one table  while creating a sales order basing on timestamp
      which is of this format yyyy-mm-dd hh:mm:ss (random Number) 
      if i want to see the error messages left i'm getting all the error messages displayed
      for example i have created a sales order
    i got 10 errors displayed
    i have rectified 5 errors ... if i again display error messages the 10 errors + the 5 errors is getting displayed
    i want to display the 5 error messages only not the previous messages from internal table
    basing on timestamp current one has to displayed remaining has to deleted from internal table.

    I thought we used Sales Order Incompletion process for this....  but, if you're recreating the errors list every time you save with a create or change transaction then, at save, delete all rows in your error table for this document.   Then get your errors and update your db table from your current errors table.   From this viewpoint, the timestamp is not relevant.

  • 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

Maybe you are looking for