Update database table through table control

Dear friends
i have to update entered data in table control to data base table please suggest some modification in my coding for the same
following is my coding
report  zrb_ins_data.
data wa_tmp_rebset type zrb_hed.
data wa_tmp_rebset1 type zrebate_items.
types:begin of st_hdr,
          bukrs            type zrb_hed-bukrs,
          sch_typ          type  zrb_hed-sch_typ,
          sch_desc         type  zrb_hed-sch_desc,
          sch_no           type  zrb_hed-sch_no,
          vtweg            type  zrb_hed-vtweg,
          vkorg                type  zrb_hed-vkorg,
          vkbur            type  zrb_hed-vkbur,
          vkgrp                type  zrb_hed-vkgrp,
          spart            type  zrb_hed-spart,
          regio            type  zrb_hed-regio,
          ort02            type  zrb_hed-ort02,
          ort01            type  zrb_hed-ort01,
          kunnr                type  zrb_hed-kunnr,
          konzs            type  zrb_hed-konzs,
          matkl            type  zrb_hed-matkl,
          matnr            type  zrb_hed-matnr,
          lifsk            type  zrb_hed-lifsk,
          shtyp            type  zrb_hed-shtyp,
          from_date        type  zrb_hed-from_date,
          to_date          type  zrb_hed-to_date,
          hkont            type  zrb_hed-hkont,
          aufnr            type  zrb_hed-aufnr,
end of st_hdr.
types : begin of st_itm,
          item_id          type zrebate_items-sch_no,
          sch_no           type zrebate_items-sch_no,
          from_dat         type zrebate_items-from_dat,
          to_dat           type zrebate_items-to_dat,
          type             type zrebate_items-type,
          qty_per_rate     type zrebate_items-qty_per_rate,
          key1             type zrebate_items-key1,
          curr_com         type zrebate_items-curr_com,
          key2             type zrebate_items-key2,
          qty_per_rate1    type zrebate_items-qty_per_rate1,
          curr_com1        type zrebate_items-curr_com1,
        end of st_itm.
data:it_hdr type table of st_hdr with header line,
     wa_hdr type st_hdr,
     it_itm  type table of st_itm with header line,
     wa_itm type st_itm.
controls ztbl type tableview using screen 1000.
*CALL SCREEN 1000.
*&      Module  STATUS_1000  OUTPUT
      text
module status_1000 output.
  set pf-status 'SYMBOL'.
  set titlebar 'xxx'.
endmodule.                 " STATUS_1000  OUTPUT
*&      Module  USER_COMMAND_1000  INPUT
      text
*module USER_COMMAND_1000 input.
*&      Module  get_data  OUTPUT
      text
*&      Module  user_command_1000  INPUT
      text
module user_command_1000 input.
  case sy-ucomm.
    when 'EXEC'.
perform get_data.
endcase.
endmodule
*&      Form  GET_DATA
      text
-->  p1        text
<--  p2        text
form get_data .
  move-corresponding wa_hdr to wa_tmp_rebset.
      modify zrb_hed  from wa_tmp_rebset.
  move-corresponding wa_itm to wa_tmp_rebset1.
  wa_tmp_rebset1-item_id = 'TS1234'.
  wa_tmp_rebset1-sch_no =   wa_hdr-sch_no.
  wa_tmp_rebset1-from_dat = wa_itm-from_dat.
  wa_tmp_rebset1-to_dat = wa_itm-to_dat.
  append wa_itm to it_itm.
modify zrebate_items from wa_tmp_rebset1.
endform.

hi,
Refer to this link...you'll get the idea..
how to update dbtab from table control?
Re: How to update a DB from a table control.
Edited by: avinash kodarapu on Dec 27, 2008 12:36 PM

Similar Messages

  • Update database table

    I have 1 million records in application server and I want to update database table from that.
    Is UPDATE statement the best technique to do it.
    Just wanted to know if there is any other better tehcniques.
    Also i want to write the errors to job log. How can we do that?
    Regards,
    DNP

    If they are all new records or all changes, it would be best to use INSERT or UPDATE. You will also want to do mass inserts/changes using an internal table. Since you have so many records, you will probably have to do this in chunks in order to avoid dumping on the rollback area.
    Rob

  • How to update database table !!!

    hi all,
    Please advice how to update database table with certain cndition needs to be checked.
    Please consider below scenario.
    have used enqueu and dequeue function to lock entries  and also i have used BAPI so considering that return parameter . i want to update table
    /tdk/st0027.
    1. I want to update database table
    2. there are certain condition needs to be checked like ,
       loop at it_final into wa_final.
    th_return-type = 'S'.
               if th_final-vbeln = /tdk/st0027-vbeln and
                  th_final-posnr = /tdk/st0027-posnr and
                  th_final-etenr = /tdk/st0027-sdslno.
    above condition which i need to check .and need to append below system fields need to be appended in table.
              th_final-prstsind = '20'.
              th_final-chgdate  = g_date.
              th_final-chgtime  = g_uzeit.
              th_final-chgprog  = g_cprog.
              th_final-chguser  = g_uname.
              append th_final to td_final.
              update /tdk/st0027 FROM th_final.
              endif.
    endloop.
    but i am getting error saying that  "The type od database table and work area (TH_FINAL)  are not unicode convertible"?
    I am not able to understandwhat would be the solution for this ?
    Thanks and regards,
    Prasad K. NAralkar

    The error occurs in the UPDATE statement included in the code. In this statement it is seen that there is a mismatch of structure defined for the DDIC table /tdk/st0027 and that of your work area th_final.
    try to create a structure w.r.t the DDIC table.
    Eg: DATA: wa_temp TYPE /tdk/st0027.
    MOVE-CORRESPONDING th_final TO wa_temp.
    Then try to UPDATE using the temporary work area i.e wa_temp which has structure similar to that of the database table.

  • Enqueue and Dequeue before updating Database table

    Hi all,
    We are updating database tables using INSERT, MODIFY and UPDATE statements. Since many people will be running the application at the same time we need to lock the table before updating database table. So we need to use ENQUEUE and DEQUEUE functionality for this purpose.
    Can any plz explain what are the steps we should follow now?
    Thanks in advance.

    Hi,
    Any Database access should carefully handled as multiple applications may be accessing the database at the same time. To read a record from the database you don't need to implement a lock, but to write you need not only locks but also ideally should use the Update Function Modules to comply SAP "All or Nothing" Principle. This will prevent data inconsistency of the database and the data will be proper state. You need to use the COMMIT WORK and ROLLBACK WORK in you code to handle the consistency part of the database.
    The best design approach would be seperate the Database Layer completely from the business layers. This will make your code robust and easy to maintain.
    As, for the Locking Concepts, you will get multiple resources from SDN as how to create Locks and implement the Locking modules in your code. But more than that what matters is why and how to implement the SAP Locking concepts to make your application run better.
    Have a look at the following link
    http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    Hope this helps.
    Thanks,
    Samantak.

  • Doubt in updating database table

    hi all
    i want to modify values ztable from a internal table ....
    for eg : the ztable contains matnr and accept_qty
    matnr   qty
    mat01   
    mat02
    i need to modify qty of the table .. i am using where condition (ie modify where matnr = ) but where condition is not working for database tables .... how to proceed with this ..
    thanks
    lokesh

    hi,
    before that :- modify statemnt will modify a record if there is record having the same key like that of record in work area.
    if there is no record in itab with key of work area record, it will insert a new record in itab.
    look this sample code.
    *modify internal table
    loop at itab into wa.
    wa-field1 = data1.
    wa-field2 = data2.
    wa-field 3= data3.
    modify itab from wa transporting field1 field2 field3 where key_field = wa-keyfield. "there shuld not be any chang in key field.
    endloop.
    *now update database table
    *work area and data base structure shuld be same type
    if itab[] is not initial.
    modify ztable from table itab.
    endif.
    rgds
    anver
    if hlped pls mark points

  • Table control program for updating database table

    Does anybody have a sample code for a table control program which can insert/delete/update a database table?
    I mean like on the output on table control, if the user insert/delete/update the records, the corresponding records will be updated in database table also.
    Appreciate your input.
    Thanks.

    hi nuren,
    TABLES: kna1,knbk.
    DATA: v_kunnr LIKE kna1-kunnr.
    DATA: v_check TYPE c.
    DATA: BEGIN OF it_knbk OCCURS 0,
          banks LIKE knbk-banks,
          bankl LIKE knbk-bankl,
          bankn LIKE knbk-bankn,
          bkont LIKE knbk-bkont,
          koinh LIKE knbk-koinh,
          chk TYPE c,
          END OF it_knbk.
    DATA: v_ucomm TYPE sy-ucomm,
          v_dynnr TYPE sy-dynnr.
    DATA: l_index TYPE sy-index.
    data: count type i.
    CONTROLS: tc1 TYPE TABLEVIEW USING SCREEN 0200.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ABC'.
    SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      v_ucomm = sy-ucomm.
      CASE v_ucomm.
        WHEN 'DISP' OR 'CHNG'.
          IF v_kunnr <> space.
            SELECT banks
                   bankl
                   bankn
                   bkont
                   koinh
                   FROM knbk
                   INTO TABLE it_knbk
                   WHERE kunnr = v_kunnr.
            LEAVE TO SCREEN '0200'.
          ENDIF.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  MOD_KUNNR  INPUT
          text
    MODULE mod_kunnr INPUT.
      IF NOT v_kunnr IS INITIAL.
        SELECT SINGLE
               kunnr
               FROM kna1
               INTO v_kunnr
               WHERE kunnr = v_kunnr.
        IF sy-subrc <> 0.
          MESSAGE e000(zz) WITH 'INCORRECT CUSTOMER NUMBER'.
        ENDIF.
      ENDIF.
      IF v_kunnr IS INITIAL.
        MESSAGE e000(zz) WITH 'PLEASE ENTER A VALUE'.
      ENDIF.
    ENDMODULE.                 " MOD_KUNNR  INPUT
    *&      Module  STATUS_0200  OUTPUT
          text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'ABC1'.
    SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0200  OUTPUT
    *&      Module  SCREENMOD  OUTPUT
          text
    MODULE screenmod OUTPUT.
      IF v_ucomm = 'DISP'.
        LOOP AT SCREEN.
          screen-input = 0.
          MODIFY SCREEN.
        ENDLOOP.
      ELSE."if v_UCOMM = 'CHNG'.
        LOOP AT SCREEN.
            IF screen-group1 = 'G1'.
              screen-input = 0.
            ELSE.
              screen-input = 1.
            ENDIF.
         MODIFY SCREEN.
        ENDLOOP.
    endif.
    if sy-ucomm = 'INSE'.
    loop at screen.
    IF ( tc1-current_line <> tc1-lines ).
      screen-input = 0.
    else.
    screen-input = 1.
    modify screen.
    endif.
    endloop.
    endif.
    ENDMODULE.                 " SCREENMOD  OUTPUT
    *&      Module  EXIT2  INPUT
          text
    MODULE exit2 INPUT.
      LEAVE TO SCREEN 0.
    ENDMODULE.                 " EXIT2  INPUT
    *&      Module  modify  INPUT
          text
    MODULE modify INPUT.
          IF v_check =  'X'.
            it_knbk-chk =  'X'.
            MODIFY it_knbk index tc1-current_line.
          ELSE.
            CLEAR it_knbk-chk .
         ENDIF.
    ENDMODULE.                 " modify  INPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    MODULE user_command_0200 INPUT.
    v_ucomm = sy-ucomm.
      CASE v_ucomm.
        WHEN 'DELE'.
            DELETE it_knbk where chk eq 'X'.
            DESCRIBE TABLE it_knbk LINES tc1-lines.
        WHEN 'INSE'.
          CLEAR it_knbk.
          APPEND it_knbk.
          DESCRIBE TABLE it_knbk LINES tc1-lines.
        WHEN 'LIST'.
          LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN '0200'.
          WRITE 'Report'.
        WHEN 'BACK'.
          LEAVE TO SCREEN '0100'.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0200  INPUT
    *&      Module  validate  INPUT
          text
    module validate input.
    IF IT_KNBK IS INITIAL.
    MESSAGE E000(ZZ) WITH 'A BLANK LINE CANNOT BE SAVED'.
    ENDIF.
    endmodule.                 " validate  INPUT

  • Multiple record update in TABLE Control.

    Hi All,
    I m developing dialog program with table control.
    I want to know how to update multiple records through the table control if user selects more than one.
    Also depending on some condition i want to change the status of one reocrd and not the column as a display field and won't be editable. I have tried with loop at screen and modify screen, but it is showing the whole column as display only.
    ANy solution let me know

    Hi,
    pls chk this standard pgms.
    for examples on table control
    demo_dynpro_tabcont_loop
    demo_dynpro_tabcont_loop_at
    RSDEMO_TABLE_CONTROL
    chk a sample code.
    DATA :BEGIN OF int_table OCCURS 0,
           fld1 TYPE ztable-fld1,
            fld2 TYPE ztable-fld2,
            fld3 TYPE ztable-fld3,
            chk(1),
          END OF int_factor.
    *write the blow code in PAI
    LOOP AT int_table WHERE chk = 'X'.
    *modify the data base table
    MODIFY ztable FROM  int_table. "from header
    clear int_table
    ENDLOOP.
    regards
    Anver

  • Not updating database table after editing using theADFapplicationJdev10.1.3

    Hi
    I created the Sample Browse and Edit JSF JSP page oracle ADF application as explained in the cuecards in Jdev10.1.3.
    After editing the department table rows in browser i am checking the database tables for the changes.
    But my table are still with the old data.they are not updating with the values i changed in the browser.
    i followed the steps correctly as explained in cuecards.
    where i am going wrong.
    What i have to do to commit the changes in to database in my ADFApplication.Did i need anything to add my code.

    In Jdev 10.1.3,there is no operations folder directly under the Application data module control.
    there is only constructors,merge entity,persist entity,refresh entity,remove entity and findalldepartments(),findallemployeeas() nodes under the application data module control.
    In findalldepartments,findallemplloyees the operations node is there.under that i don't have the commit .i have only create,execute,first,previous,last,next,delete,removerowwithkey,setcurrentRowWithkey,setcurrentRowWithkeyValue under the operation node.
    so how can i commit the operations in database.
    Please help me.

  • CRUD using ADF fails to update database table

    Hi All,
    I am very new to ADF and JDev. I am using JDev 11.1.1.2.0 and oracle 10g DB.
    I have created the required
    1. model, view control, Data control files using JDev for a DB table.
    2. .jspx file that has a 'panel accordin' and a 'panel formLayout' layouts to display the required table fields on the page.
    I am using Panel accordin layout to display the data with navigators buttons and works fine.
    In Panel Form layout, after displaying the fields I have added "Submit" button. I have bound this button with "Commit" operation by simple drag and drop.
    PS: I have added the fields by simple drag drop of the data control file mapped to the table in question.
    On running the page I find things work fine till I want to use the submit button. It just updates the UI front but when I verify in my database table I find that it has not been updated.
    I am clueless. Pls guide.
    A site with step - by - step end to end development will be very great.
    Waiting desparately to get this solved.
    Thanks all
    Edited by: user8925296 on Jan 16, 2010 2:13 AM

    You need to be careful. Submit and committing to the database are two different things.
    Submit on a page (and autoSubmit the property) are only posting the changes you typed into the field, back down to the application server. NOTHING is happening with the database at this point. So the applications's internal "cache" of records (using something like ADF BC) is holding the changes but the database doesn't know anything. So if you quit now, no changes will go to the database.
    These changes onlyget submitted down to the app server when you do some sort of action like press a button. Simply navigating fields will be doing nothing back to the app server. If you add autoSubmit then you will automatically submit the changes on that field down to the app server when you leave the field (but again, this is not touching the database)
    You have to explicitly add a COMMIT operation to save those changes to the database.
    Maybe if you try in a simple EMP example and send us your findings we can help direct you further.
    Regards
    Grant

  • Updating database table for 'CHANGE' and 'ADD' buttons.

    Hi,
    I am working on module pool program. Here i am using table control.Below is my requirement:
    1) I have designed a selection - screen with 'CHANGE' and 'DISPLAY' buttons and in screen 100 i have 'ADD' and 'SAVE' buttons.
    2) when i click on 'CHANGE' , it will move to screen 200 here i need to change quantity field for that particular record which is in table control.once i change the field value and click on 'SAVE'  a message should be populated that "RECORD IS SAVED' and  this record should be updated in database table with new quantity field value and it should return back to my selection screen.
    3) When i click on 'ADD' , it should display already existing records in disable mode and a new line should be added inorder to enter new records. Once i enter the data and click on SAVE, this new record should be saved in the database table along with existing records.
    Kindly suggest me a sample code for this as am new to table control in module pool programming.

    Hi Gaurav,
    I've a similar problem!! any solutions to your problem!!

  • Browse and update database tables

    I'm looking for a tool that will let me connect to an Oracle database, select a table and some fields off the table and build a simple java class to navigate / update the data.
    Essentially, I'm looking for a tool that replicates the way Microsoft Access can build a form for navigation and update of a database table.
    However, I want to use java, not MS Access.
    Any ideas if such a tool is available ?
    Thanks

    http://squirrel-sql.sourceforge.net/

  • How to find out who updated database tables

    Hi
    We are using Oracle Database 10g Release 10.2.0.4.0.
    A user, via pl/sql developer, has been updating data on our database. This resulted in certain reports not balancing. At that time, we did not have database triggers on the tables concerned. We now need to go back at least a month or more to see who had updated these tables. We have a username, is there any script that we can use? How accurate is v$active_session_history? Would it give us all the info we need?

    781424 wrote:
    Hi
    We are using Oracle Database 10g Release 10.2.0.4.0.
    A user, via pl/sql developer, has been updating data on our database. This resulted in certain reports not balancing. At that time, we did not have database triggers on the tables concerned. We now need to go back at least a month or more to see who had updated these tables. We have a username, is there any script that we can use? How accurate is v$active_session_history? Would it give us all the info we need?It is little easy to know with AUDITING, or use Log miner to analyze log files.

  • Updating database table based on BAPI response in case of error

    Dear Experts,
    My scenario includes pulling records from database stagging table, and push one record at a time to BAPI_ALM_NOTIF_CREATE.
    I am using sender JDBC adapter(with select query and update query to mark records as processed).
    My question is : Once XI selects records, immediately status is updated in stagging table for the selected records as processed. what if BAPI could not create document? In this case I need to update status of that record as "Not processed".
    What should I use?
    If BPM, then please tell me the steps.
    Is this possible without BPM?
    What are the chances of failure between XI and BAPI?
    Please provide your inputs.
    Thank you.
    Div

    >
    S.R.Suraj wrote:
    > Hi Divyesh,
    >
    > Your steps are correct..
    >
    > 1. JBDC will read record with code = 0 and make it 1...
    > 2. Once the bapi process is completed all these read records shoudl be made as 2 (if completed successful) else 0 if bapi went into some error.. so that again the jdbc adapter can poll these records and give back to bapi for processing...
    >
    > Now your questions
    > >>So after selection and updation only proxy call will be done right? So for every polling of jdbc adapter ,proxy call will happen?
    > YEs every poll of jdbc will result in a proxy call and every time it will contain next set of records (as the earlier one have already marked as 1)
    >
    > >>How to achieve this?
    > Since this is a synchronous scenario JBDC->XI->Proxy and reverse, I have suggested to use responseonewaybean as a module in sender jdbc adapter (because sender jdbc cannot act synchronously thats why you need to use this module)..
    >
    > >>Do i need to use BPM? please suggest steps.
    > and if this is not working then go for BPM..the steps as i mentioned in my first thread..
    >
    > Regards
    > Suraj
    Hi Suraj,
    Thanks a lot for your support.
    It would be good if you can provide your inputs.
    Stagging table records status:
    Flag = 0 (XI will poll records)
    Flag = 1(XI has polled records and XI will se tthis flag by JDBC adapter)
    Flag =2 (should be done based on response from Proxy Tables parameter) Proxy will set tables parameter which will include info on error message and type.
    (Now based on new requiremets: for error records status should not be reset to 0 so that XI can poll records again, now stagging table should contain error records(for which proxy can not create notification in SAP) with error message and status flag 2)
    Now scenario would be JDBC to Proxy.
    Polling interval for JDBC adapter should be 1 minute.
    So I think status 0 to 1 will be done by XI after immediately selecting records.
    But how about Status 2 that has to be set only for error records only and  with error information.
    I have to update stagging table records with status 2 and error info based on proxy table response. How this can be done?
    This updation will be done in case of error only.
    I was thinking this aproach:
    We can have two interfaces.
    First interface will be jdbc to proxy:
    JDBC adapter select and update records with flag =1 and then send to proxy call and create document in SAP. At SAP side if document can not be created then they will store that error info in some table.
    Second Interfgace:
    Client SAP Proxy will periodically run and send these error records info to XI and XI will update stagging table records accordingly.
    Suraj, What is your sugestion in this solution? Do I need to use Responseonewaybean?
    Thanks Suraj
    Div

  • Updating Database table

    Hi,
    My requirement is to update the table EBAN(Purchase Requisition). Let us suppose that there are 3 items in the purchase requisition. If I make any changes to any of the item, the other two items need to be updated with the same changes. I am using a MODIFY....FROM <Internal Table> statement to update the changes in the database,
    Now the problem is if I am making any changes in the 3rd item and press save, the database gets updated for 2nd and 3rd item only but the 1st item is not modified in the database.
    If I make changes to the 1st item, then the modifications are done to 1st, 2nd and 3rd item and is working fine. The problem is when I make changes to 2nd or 3rd item then the 1st item does not get updated. I tried using update statement, locking table EBAN using ENQUEUE_E_TABLE but nothing worked.
    I tried to use MODIFY...FROM <Workarea> inside a loop but it didn't work.
    Kindly suggest.
    Regards,
    Amit Behera

    Hi
    After modifying u append that values work area to internal table.

  • Need help in updating database table from screen fields

    Hi,
    Can anyone tell me how to update the database table with the entries given in the fields of a screen ?...a procedure-wise explanation would be very helpful.
    Thank you.
    Moderator message: sorry, no beginner forums here, please search for available information or attend training.
    locked by: Thomas Zloch on Aug 12, 2010 3:16 PM

    Hi,
    Can anyone tell me how to update the database table with the entries given in the fields of a screen ?...a procedure-wise explanation would be very helpful.
    Thank you.
    Moderator message: sorry, no beginner forums here, please search for available information or attend training.
    locked by: Thomas Zloch on Aug 12, 2010 3:16 PM

Maybe you are looking for

  • Attempt to validate an already invalid RegionSite-Error on running ADF Page

    Hi All, I have ADF Application with a single simple jspx page contains only a single region having taskFlow "taskList-task-flow-definition" which will be available in "adflibTaskListTaskFlow.jar" While running the page i am getting the below mentione

  • Links toolbar has disappeared and can't get it back

    My "Links" toolbar has disappeared. I use the xmarks addon and it has not been able to fix it. This has also happenned on Internet Explorer on the same machine. I run the same version of Firefox and IE on another machine and laptop and the toolbar is

  • Image sequence only opens 1 image in QT pro

    Hi, I have 1500 numbered jpeg images and every time i go to do an image sequence it only adds the first frame into the image sequence!! Help!!!

  • Need to play video inside forms applet window

    Hi, I need to call a video inside oracle forms (10g), This can be acheived through Client_host() or by web.show_document. But the problem is that both methods opens the video in new browser window. Where as my target is to play the video inside speci

  • PowerBook 800 Audio Issue

    Hello. I have a PowerBook 800 DVI. I have owned this computer for several years and have recently noticed that when I press on the bottom case or slightly move the PB the audio usually goes out completely, input and output. However, it does not hinde