Updating table control

Hai
     I am saving the datas from table control into ztable. Its saving fine.
If i give the entries exists in ztable it is not inserting. Only new entries is inserting in z table. everything is fine but
my requirement is,
In my table control if it is an existing entry it should come in edit mode and new entries should be inserted and it should remove from table control.
Please help me.

If you don't post code, we can't help you. Nethertheless. You must use MODIFY (dbtab) abap statement if you want to insert if it doesn't exist, or update if it exists. Please read the abap reference documentation.

Similar Messages

  • DYNP_VALUES_UPDATE to update table control cell

    How can I update a cell (e.g. in line n) value in a table control using the function DYNP_VALUES_UPDATE? Can someone give me an example?
    Thanks in advance.
    Adhimas S.

    Hi,
    Check this sample code
    REPORT ZVV.
    tables tcurt.
    DATA   DYFIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.
    PARAMETERS: P_WAERS LIKE TCURT-WAERS,        "Currency
                P_LTEXT LIKE TCURT-LTEXT,        "Long Text
                P_KTEXT LIKE TCURT-KTEXT.        "Short Text
    *--- Example of updating value of another field on the screen -
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_WAERS.
      CLEAR: DYFIELDS[], DYFIELDS.
    *--- select currency
      CALL FUNCTION 'HELP_VALUES_GET'
           EXPORTING
                fieldname        =  'WAERS'
                tabname          =  'TCURT'
           IMPORTING
                SELECT_VALUE     =   P_WAERS.
    *--- get long text for the selected currency
      SELECT SINGLE LTEXT FROM TCURT
        INTO DYFIELDS-FIELDVALUE
        WHERE SPRAS = SY-LANGU
        AND   WAERS = P_WAERS.
      IF SY-SUBRC <> 0.
        CLEAR DYFIELDS-FIELDVALUE.
      ENDIF.
    *--- update another field
      DYFIELDS-FIELDNAME = 'P_LTEXT'.
      APPEND DYFIELDS.
      CALL FUNCTION 'DYNP_VALUES_UPDATE'
           EXPORTING
                DYNAME               = SY-CPROG
                DYNUMB               = SY-DYNNR
           tables
                dynpfields           = DYFIELDS .
    *--- Example of reading value of another field -
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_KTEXT.
    *--- read another field
      CLEAR: DYFIELDS[], DYFIELDS.
      DYFIELDS-FIELDNAME = 'P_WAERS'.
      APPEND DYFIELDS.
      CALL FUNCTION 'DYNP_VALUES_READ'
           EXPORTING
                DYNAME                   = SY-CPROG
                DYNUMB                   = SY-DYNNR
           TABLES
                DYNPFIELDS               = DYFIELDS .
      READ TABLE DYFIELDS INDEX 1.
    *--- get short text and update current field
      SELECT SINGLE KTEXT FROM TCURT
        INTO P_KTEXT
        WHERE SPRAS EQ SY-LANGU
        AND   WAERS EQ DYFIELDS-FIELDVALUE.
    Thanks & Regards,
    Judith.

  • How to edit and update table control into database?

    I am doing table control. Here are my codes:
    *& Report  ZHERA_TABLE2
    REPORT  ZHERA_TABLE2.
    ***&SPWIZARD: DATA DECLARATION FOR TABLECONTROL 'ZTABLE_CONTROL'
    *&SPWIZARD: DEFINITION OF DDIC-TABLE
    TABLES:   ZHERA.
    *&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'ZTABLE_CONTROL'
    TYPES: BEGIN OF T_ZTABLE_CONTROL,
             NAME LIKE ZHERA-NAME,
             AGE LIKE ZHERA-AGE,
           END OF T_ZTABLE_CONTROL.
    *&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'ZTABLE_CONTROL'
    DATA:     G_ZTABLE_CONTROL_ITAB   TYPE T_ZTABLE_CONTROL OCCURS 0,
              G_ZTABLE_CONTROL_WA     TYPE T_ZTABLE_CONTROL. "work area
    DATA:     G_ZTABLE_CONTROL_COPIED.           "copy flag
    *&SPWIZARD: DECLARATION OF TABLECONTROL 'ZTABLE_CONTROL' ITSELF
    CONTROLS: ZTABLE_CONTROL TYPE TABLEVIEW USING SCREEN 1000.
    START-OF-SELECTION.
    CALL SCREEN 1000.
    *&SPWIZARD: OUTPUT MODULE FOR TC 'ZTABLE_CONTROL'. DO NOT CHANGE THIS LI
    *&SPWIZARD: COPY DDIC-TABLE TO ITAB
    MODULE ZTABLE_CONTROL_INIT OUTPUT.
      IF G_ZTABLE_CONTROL_COPIED IS INITIAL.
    *&SPWIZARD: COPY DDIC-TABLE 'ZHERA'
    *&SPWIZARD: INTO INTERNAL TABLE 'g_ZTABLE_CONTROL_itab'
        SELECT * FROM ZHERA
           INTO CORRESPONDING FIELDS
           OF TABLE G_ZTABLE_CONTROL_ITAB.
        G_ZTABLE_CONTROL_COPIED = 'X'.
        REFRESH CONTROL 'ZTABLE_CONTROL' FROM SCREEN '1000'.
      ENDIF.
    ENDMODULE.
    *&SPWIZARD: OUTPUT MODULE FOR TC 'ZTABLE_CONTROL'. DO NOT CHANGE THIS LI
    *&SPWIZARD: MOVE ITAB TO DYNPRO
    MODULE ZTABLE_CONTROL_MOVE OUTPUT.
      MOVE-CORRESPONDING G_ZTABLE_CONTROL_WA TO ZHERA.
    ENDMODULE.
    Screen 1000 codes:
    PROCESS BEFORE OUTPUT.
    *&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'ZTABLE_CONTROL'
      MODULE ZTABLE_CONTROL_INIT.
    *&SPWIZARD: MODULE ZTABLE_CONTROL_CHANGE_TC_ATTR.
    *&SPWIZARD: MODULE ZTABLE_CONTROL_CHANGE_COL_ATTR.
      LOOP AT   G_ZTABLE_CONTROL_ITAB
           INTO G_ZTABLE_CONTROL_WA
           WITH CONTROL ZTABLE_CONTROL
           CURSOR ZTABLE_CONTROL-CURRENT_LINE.
    *&SPWIZARD:   MODULE ZTABLE_CONTROL_CHANGE_FIELD_ATTR
        MODULE ZTABLE_CONTROL_MOVE.
      ENDLOOP.
    MODULE STATUS_1000.
    PROCESS AFTER INPUT.
    *&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'ZTABLE_CONTROL'
      LOOP AT G_ZTABLE_CONTROL_ITAB.
        CHAIN.
          FIELD ZHERA-NAME.
          FIELD ZHERA-AGE.
        ENDCHAIN.
      ENDLOOP.
    *&SPWIZARD: MODULE ZTABLE_CONTROL_CHANGE_TC_ATTR.
    *&SPWIZARD: MODULE ZTABLE_CONTROL_CHANGE_COL_ATTR.
    MODULE USER_COMMAND_1000.
    Please show me where to put my codes to edit(edit directly on table control fields) and update my table control(using the 'save' button)?

    Hi,
    You have to put the following code in the PBO of screen 1000.This code would make the fields editable to make changes in the table control fields directly.
    Here there are 3 transactions.For create and change transactions, the fields will be in editable mode and for display transaction,they will be non editable mode.
    DESCRIBE TABLE tb_line LINES lin.    " tb_line is the name of the internal table for the table control
      tcl_item-lines = lin.                             '' lin hold the number of lines of the internal table
    CASE sy-tcode.
        WHEN 'ZCREATE09' OR 'ZCHANGE09'.
    ***Checking if the table control is empty or not***
          IF lin NE 0.       
            LOOP AT SCREEN.
    ***To make the screen editable****
              screen-input = 1.
            ENDLOOP.
          ELSE.
            LOOP AT SCREEN.
              IF screen-name CS 'TB_LINE'.
    ****To make the screen non-editable if no values are present in the
    ***table control****
                screen-input = 0.
                MODIFY SCREEN.
              ENDIF.
            ENDLOOP.
          ENDIF.
    Once the fields are edited and the save button is pressed,the entered values have to be populated into the Z tables.The code has to written in the PAI of the screen 1000.Here the values from the work area of the internal table are moved into the Z Table. The code will be.
    LOOP AT tb_line.
        ztm09_ekpo-ebeln = ztm09_ekko-ebeln.  "ztm09_ekko and ztm09_ekpo are the names of the Z Tables.
        ztm09_ekpo-ebelp = tb_line-ebelp.   
        ztm09_ekpo-matnr = tb_line-matnr.
        ztm09_ekpo-menge = tb_line-menge.
        ztm09_ekpo-meins = tb_line-meins.
        ztm09_ekpo-netpr = tb_line-netpr.
        ztm09_ekpo-waers = tb_line-waers.
    *****Update the entries into item table*****
        MODIFY ztm09_ekpo.
      ENDLOOP.
    Reward if helpfull
    Thanks,
    Kashyap

  • Update table control dynamically

    Dear gurus,
    I have created a table control of my internal table "i_main" using Screen Painter's table control wizard. I have made all fields editable via double clicking the field, clicking Program, then Input = Possible.
    My i_main table and table control contains the following fields:
    hunit TYPE vekp-vpobjkey.
    printno TYPE i.
    groupno TYPE i.
    batch TYPE mseg-charg.
    qtyTYPE mseg-menge.
    After my program has populated i_main table control, I now want to manually override the contained values in i_main and my table control z_init. When I type in a new value for my quantity column, for example I change 22 to 5. It goes back to 22, and nothing happens.
    Any advice on what should I do to update fields of my table control, as well as i_main?
    Thank you very much!

    in pai event.
    loop at iternaltable.
    module move_to_table ON CHAIN-REQUEST.
    endloop.
    module move_TO_TABLE.
    MODIFY IT FROM WA_ZTBCTRL INDEX ZTBCTRL-CURRENT_LINE.
    ENDMODULE.

  • Using function module DYNP_VALUES_UPDATE to update table control

    Hello all
          i am using FM "DYNP_VALUES_UPDATE" to update values from search help to dynpro. there are more than 1000 records to be updated, but in table control only visible area values only getting updated. Can any one please help regarding this?
    Thanks
    Neelima

    Look at FM DYNP_GET_STEPL which provides  povstepl  index to be able to update field values in correct row of table control with  DYNP_VALUES_UPDATE (and to read correct value with DYNP_VALUES_READ  too)
    NB: If you need to update multiple rows, I'm not sure that can be done in POV, you may be required to modify the internal table and trigger PAI/PBO cycle with a suppress dialog, or method/FM to trigger ok_code.
    Regards,
    Raymond

  • Making a field visible for a particular row in table control.

    Hi Experts,
    I have a scenario where in there are 7 columns in table control wherein last column I have made invisible. Now I got to make that column visible only for the selected row and this column for the rest of the rows should be invisible.
    How can I achieve this. Tried a lot playing with table control current line and cols structure but no fruit.
    Please help. <removed by moderator>
    Thanks,
    Edited by: Thomas Zloch on Oct 19, 2010 2:38 PM

    Hi All,
    Sorry for late response. I was out of station for a while.
    I tried a lot after going through the link provided by Robert and also tried what Anmol has suggested but its not working,
    The column becomes invisible but it is not becoming visible again for the selected row.
    The code I have written is as follows.
    process before output.
    module status_9000.
      module tc_details_change_tc_attr.
      loop at   it_test
           into wa_test
           with control tc_details
           cursor tc_details-current_line.
        module tc_details_get_lines.
         module customize.  " Module to update table control dynamically
      endloop.
    module CUSTOMIZE output.
    LOOP AT TC_DETAILS-cols INTO cols.
               if  cols-screen-name = 'WA_TEST-REMARKS'. " and wa_test-sel = 'X' ).
           IF WA_TEST-SEL = 'X'.
             COLS-SCREEN-ACTIVE = '1'.
             COLS-INVISIBLE = '0'.
             MODIFY TC_DETAILS-COLS FROM COLS INDEX SY-TABIX.
             ELSE.
              COLS-SCREEN-ACTIVE = '0'.
             COLS-INVISIBLE = '1'.
             MODIFY TC_DETAILS-COLS FROM COLS INDEX SY-TABIX.
             ENDIF..
             ENDIF.
              ENDLOOP.
    endmodule.  
    Please help.

  • Update internal table data from table control

    Hi GURUS,
    I need help regarding one of my requirement.
    I need to display data from the internal table on the screen and when the user selects a record/multiple records from screen and clicks on approve button i need to update one of the field from N to Y in the corresponding Ztable. Once the record is updated from Ztable , that should no longer be visible for the user on the screen.
    I am using table control wizard to display data. I am able to update the Ztable, but that record is not refreshing from the user screen. Any suggestions would be approved.
    Also please let me know if table control is the best way to do this/ alv grid control??

    hi
       REFRESH CONTROL Control-Name FROM SCREEN '0100'  -> use this command to refresh the table control
    to know more, read into
    https://forums.sdn.sap.com/click.jspa?searchID=2934287&messageID=673474
    Re: URGENT HELP REQ IN TABLE CONTROL WIZARD
    if helpful, reward
    Sathish. R

  • Module pool - table control - update ztable

    hello , i doing a module pool that will have few screens , now i have one screen with a table control that fetch the data from a ztable when screen is call the table control is showing the data and is in grey and no editable i add a pf-status for change that mode i can delete the row from the table control but i don't figure out how update to the ztable when i press save , i wan't too another button for add a new row ( and remain the already in grey ) for add new entrie in the table and update the ztable
    pd: sorry for my bad english
    this is my code:
    TOP:
    PROGRAM  z_pp_lote_etiquetas MESSAGE-ID zz.
    TABLES:zc2p_lote_etique,
           zc2p_lider_modul.
    DATA: ok_code LIKE sy-ucomm.
    DATA save_ok LIKE sy-ucomm.
    * internal table
    DATA: it_zc2p_lote_etique LIKE STANDARD TABLE OF zc2p_lote_etique.
    DATA: it_zc2p_lider_modul TYPE STANDARD TABLE OF zc2p_lider_modul WITH HEADER LINE.
    DATA: it_zc2p_lider_modul_del TYPE STANDARD TABLE OF zc2p_lider_modul WITH HEADER LINE.
    **************Workarea
    DATA: wa_c2p_lote_etique TYPE zc2p_lote_etique.
    DATA: wa_c2p_lider_modul TYPE zc2p_lider_modul.
    DATA: wa_c2p_lider_modul_del TYPE zc2p_lider_modul.
    DATA: sel.
    DATA: MARK.
    DATA: init.
    DATA:  col TYPE scxtab_column.
    DATA: lines TYPE i.
    * Variable Declaration
    DATA : flg, "Flag to set the change mode
    ln TYPE i. "No. of records
    * Table Control Declartion.
    CONTROLS: zc2p_lider_crtl TYPE TABLEVIEW USING SCREEN '101'.
    **PROCESS BEFORE OUTPUT INCLUDE **
    *&  Include           Z_PP_LOTE_ETIQUETAS_O01
    *& Module set_status OUTPUT
    * Setting the GUI status
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'Z_PP_LOT_ETIQ_MENU'.
      SET TITLEBAR 'Z_PP_LOT_ETIQ'.
    ENDMODULE. " set_status OUTPUT screen 100
    *  MODULE status_0101 OUTPUT
    * Setting the GUI status
    MODULE status_0101 OUTPUT.
      SET PF-STATUS 'Z_PP_LOT_ETIQ_ME_101'.
      SET TITLEBAR 'Z_PP_LOT_ETIQ'.
    * Data retreving
      if init is INITIAL.
      select * from zc2p_lider_modul into CORRESPONDING FIELDS OF TABLE it_zc2p_lider_modul.
        DESCRIBE TABLE it_zc2p_lider_modul LINES ln.
        zc2p_lider_crtl-lines = ln + 10.
        init = 'X'.
    endif.
    ENDMODULE.                    "status_0101 OUTPUT
    module change_sdyn_conn output.
    * you can change the content of current table control line via
    * sdyn_conn
      READ TABLE it_zc2p_lider_modul INTO zc2p_lider_modul INDEX zc2p_lider_crtl-current_line.
    endmodule.                             " FILL_TABLE_CONTROL  OUTPUT
    MODULE set_screen_fields OUTPUT.
    LOOP AT SCREEN.
    IF flg IS INITIAL.
    screen-input = 0.
    ELSE.
    screen-input = 1.
    ENDIF.
    *ENDIF.
    * Modifying the screen after making changes
    MODIFY SCREEN.
    ENDLOOP.
    ENDMODULE. " set_screen_fields OUTPUT
    PROCESS AFTER INPUT INCLUDE.
    *  MODULE USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'LIDM'.
          CALL SCREEN 101.
        WHEN 'CANC'.
          LEAVE PROGRAM.
        WHEN 'BACK'.
          LEAVE PROGRAM.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                    "USER_COMMAND_0100 INPUT
    *  MODULE USER_COMMAND_0101 INPUT
    MODULE user_command_0101 INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      CASE save_ok.
        WHEN 'SORT'.
          DATA: fldname(100),help(100).
          READ TABLE zc2p_lider_crtl-cols INTO col WITH KEY selected = 'X'.
          SPLIT col-screen-name AT '-' INTO help fldname.
          SORT it_zc2p_lider_modul BY (fldname).
        WHEN 'CHANGE'.
    * Setting the flag to make the table control in editable mode[excluding
    * primary key].
          flg = 'Y'.
        WHEN 'BACK'.
          CALL SCREEN 100.
          LEAVE SCREEN.
        WHEN 'CANCEL'.
          LEAVE PROGRAM.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'SAVE'.
          MODIFY  zc2p_lider_modul FROM it_zc2p_lider_modul.
          COMMIT WORK.
      ENDCASE.
    ENDMODULE.                    "USER_COMMAND_0101 INPUT
    *  MODULE read_table_control INPUT
    MODULE read_table_control INPUT.
    * Check input values
      IF mark = 'X' AND save_ok = 'DELETE'.
        DELETE TABLE it_zc2p_lider_modul FROM zc2p_lider_modul.
        DESCRIBE TABLE it_zc2p_lider_modul LINES zc2p_lider_crtl-lines.
      ENDIF.
    ENDMODULE.                             " READ_TABLE_CONTROL  INPUT
    Screen Flow Logic 100
    PROCESS BEFORE OUTPUT.
    MODULE status_0100.
    PROCESS AFTER INPUT.
    MODULE user_command_0100.
    Screen Flow Logic 101.
    PROCESS BEFORE OUTPUT.
      MODULE status_0101.
      LOOP AT it_zc2p_lider_modul INTO zc2p_lider_modul WITH CONTROL
    zc2p_lider_crtl.
    * Dynamic screen modifications
        MODULE set_screen_fields.
        MODULE change_sdyn_conn.
      ENDLOOP.
    PROCESS AFTER INPUT.
      MODULE user_command_0101.
      LOOP AT it_zc2p_lider_modul.
        MODULE read_table_control.
      ENDLOOP.
    i hope somebody can help for what i missing here  thanks

    >
    Sanjeev Kumar wrote:
    > Hello Edgar,
    >
    > Problem seems to be there in the flow logic of 101
    >
    >
    > PROCESS BEFORE OUTPUT.
    >   MODULE status_0101.
    >   LOOP AT it_zc2p_lider_modul INTO zc2p_lider_modul WITH CONTROL
    > zc2p_lider_crtl. " no need to have 'INTO zc2p_lider_modul' above
    > * Dynamic screen modifications
    >     MODULE set_screen_fields.
    >     MODULE change_sdyn_conn.
    >   ENDLOOP.
    > *
    > PROCESS AFTER INPUT.
    >   MODULE user_command_0101. "this should be shifted after the following LOOP...ENDLOOP.

    >   LOOP AT it_zc2p_lider_modul. "need to have 'WITH CONTROL zc2p_lider_crtl' here
    >     MODULE read_table_control.
    >   ENDLOOP.
    >
    >
    >
    > With MODULE user_command_0101 call before the LOOP calls the MODIFY statement (under case save_ok 'SAVE') first and Z-table is updated with the old values as the changes are transferred from screen into the internal table it_zc2p_lider_modul in the LOOP...ENDLOOP later.
    >
    > Try these changes and I hope it will work.
    >
    > Thanks
    > Sanjeev
    i do the firts advice but the second one i get syntax error :
    my code :
    PROCESS AFTER INPUT.
      LOOP  at it_zc2p_lider_modul WITH CONTROL zc2p_lider_crtl.
        MODULE read_table_control.
      ENDLOOP.
       MODULE user_command_0101.
    error :
    In the event PROCESS AFTER INPUT, no additions are allowed with "LOOP     
    AT".

  • 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

  • How to update and retrieve the table control entries and field entries.

    Hello everyone,
    i have a requirement,
    i have    company code , plant, fiscal year, posting period  fields in the selection screen and then below that i have a  table control which contains 4 fields  invoice no., check number, check date and amount.
    i have to enter the values and when i press  SAVE button , these values have to update in a custom table which i had created.
    please send me the coding how to do this object.
    will be rewarded.
    thanks in advance.

    Hi Suresh
      this is actual requirement
    in the CAT2.
    1. Add a new column for WBS description and derive the value as per the FS
    2. Retrieve project number and description and update in the column specified
    3. When a service order is selected it should do the same for 2.
    4. Finally repeat for the worklist view (which is the section above)
       here i am able to display values at data entry area
    for service order and network but not worklist area ?
        updation is not coming, can u plz go throw it..
    Thanks
    Chinna

  • Regd updation of one record in table control

    hai all
    i have a table control with 100 fields with 200
    records in the table control.
    i want to change one particular record in the 17th
    field.
    how to update that record,,please ,
    awaiting replies

    Please check the code.
    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 if *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.
    MODIFY int_factor INDEX tab_control-current_line.
    IF sy-subrc NE 0.
    APPEND int_factor.
    CLEAR int_factor.
    ENDIF.
    ENDIF.
    ENDMODULE. " move_data_from_table INPUT
    Regards

  • Unable to Update data in Ztable (dbase) through Table Control.

    Hi Experts.
    I am able to pull dta from Ztable into table control and also able to insert a new line and delete a row from table control. But after trying a lot I am unbale to pass the same from Table control to Ztable.
    Any ideas. Seems like here Update of Ztable needs some different treatment.
    PLZ LOOK into the code in red only. rest are for reference.
    The code on the Flow Logic Screen:
    PROCESS BEFORE OUTPUT.
      module init_100.
      LOOP At it_auftrag1 with CONTROL tctrl1 cursor tctrl1-current_line.
      ENDLOOP.
    PROCESS AFTER INPUT.
    LOOP AT it_auftrag1.
       Module modify_it_auftrag1.
    ENDLOOP.
    MODULE fcode_100.
    MODULE USER_COMMAND_9000.
    The code on main Screen (Mod. Pool Screen ) follows:
    PROGRAM  SAPMZDEMO_MPOOL_06.
    TABLES: ZLT_Auftrag1, ZLT_Kunde.
    DATA: fcode2(4), fcode(4).    "OK_Code.
    CONTROLS : tctrl1 type TABLEVIEW USING SCREEN '9000'.
    DATA: col TYPE cxtab_column.
    DATA: demo_cprop, demo_tprop.
    DATA:  Begin Of it_Auftrag1 occurs 20,
            marked.
            include structure ZLT_auftrag1.
    DATA:  END OF it_Auftrag1.
    DATA: linno TYPE i.
    DATA: fld(20).
    DATA: off TYPE i.
    module fcode_100 input.
    endmodule.                 " fcode_100  INPUT
    module modify_it_auftrag1 input.
      modify it_Auftrag1 index tctrl1-current_line.
    endmodule.                 " modify_it_auftrag1  INPUT
    module init_100 output.
      set pf-status 'ZSTATUS01'.
      Describe Table it_auftrag1  lines  tctrl1-lines.   "TO add Scroll Bar to Table Control1
      UPDATE ZLT_Auftrag1 From it_auftrag1.
    endmodule.                 " init_100  OUTPUT
    module USER_COMMAND_9000 input.
       CASE sy-ucomm.
    *To Populate Data into Kunde through Pushbuttons
        When 'OK_GETK'.
            IF ZLT_Kunde-K1 is NOT INITIAL.
                SELECT SINGLE *
                FROM  ZLT_Kunde
                Where K1 = ZLT_KUNDE-K1.
               IF ZLT_Kunde-K1 is NOT initial.
                  Select *
                  From ZLT_Auftrag1
                  INTO Corresponding fields of TABLE it_auftrag1
                  Where A3 = ZLT_Kunde-K2.
               ENDIF.
            ELSE.
                MESSAGE S000(8i) With 'Enter Kunde Name'.
            ENDIF.
      when 'DELL'.
    * remove marked lines
           delete it_auftrag1.
          loop at it_auftrag1 where marked = 'X'.
          UPDATE ZLT_Auftrag1 From it_auftrag1.
          endloop.
          if sy-subrc <> 0.
            get cursor field fld line linno offset off.
            set cursor field fld line linno offset off.
            if fld cp 'IT_auftrag1*' and sy-subrc = 0.
              linno = linno + tctrl1-top_line - 1.
              delete it_auftrag1 index linno.
              tctrl1-lines = tctrl1-lines - 1.
            endif.
          endif.
       When 'INSL'.
    * insert line above cursor position
          get cursor field fld line linno offset off.
          set cursor field fld line linno offset off.
          if fld cp 'IT_auftrag1*' and sy-subrc = 0.
            if linno >= 1.
              linno = linno + tctrl1-top_line - 1.
              clear it_auftrag1.
              insert it_auftrag1 index linno.
              tctrl1-lines = tctrl1-lines + 1.
            else.
              clear it_auftrag1.
              append it_auftrag1.
              tctrl1-lines = tctrl1-lines + 1.
            endif.
          endif.
         When 'SAVE'.
         loop at it_auftrag1 where marked = 'X'.
    *        Modify it_Auftrag1.
            Modify ZLT_Auftrag1 From it_Auftrag1.
          Endloop.
            IF sy-subrc = 0.
             MESSAGE s000(8i) With 'Data Saved'.
           ENDIF.
       When 'BACK'.
           Leave Program.
        When 'OK_CLEAR'.
          Clear : ZLT_KUNDE, ZLT_AUFTRAG1, it_auftrag1.
    ENDCASE.
    endmodule.                 " USER_COMMAND_9000  INPUT
    Looking forward for your advice,
    Regards
    Chandan

    Hi Venkat,
    Thanks again. I will try ur suggestion too. In the meanwhile I did the following changes in the code:
    Purpose: After data is getting pulled from dbase table (ZLT_Auftrag1) into internal table it_auftrag1 then and just after I press the button delete ( i.e. When the user command starts: When 'DELL' )
    then I delete all the contents reflecting in it_auftrag1 from ZLT_Auftrag1, Now the Ztable is empty but it_auftrag1 holds all values. futher when loop starts then the Marked line gets deleted. Now at this stage the it_Auftrag1 contains all data of ZLT_auftrag1 except the line that I want to delete. If I am able to MODIFY  the ZLT_auftrag1 from it_Auftrag1 at this stage then ZLT_Auftrag1 will again be populated with all those data except the line that I want to delete.
    Here goes the code that I modified ( ref the code in my 1st post in red to compare)
       WHEN 'DELL'.
    * remove marked lines
    *      If it_Auftrag1-Marked = 'X'.
            DELETE from ZLT_Auftrag1 where A3 = ZLT_kunde-K2.
    *      ENDIF.
          IF sy-subrc = 0.
                loop at it_auftrag1 where marked = 'X'.
                 DELETE it_auftrag1.
    *             INSERT ZLT_Auftrag1 From TABLE it_auftrag1 accepting duplicate keys.
    *             UPDATE ZLt_auftrag1 from TABLE it_auftrag1.
    *             MODIFY ZLT_Auftrag1 From TABLE it_auftrag1.
                endloop.
    *            INSERT ZLT_Auftrag1 From TABLE it_auftrag1.
    *             UPDATE ZLt_auftrag1 from TABLE it_auftrag1.
    *             MODIFY ZLT_Auftrag1 From TABLE it_auftrag1.
    *        If sy-subrc = 0.
    *          MESSAGE S000(8i) With 'Data Deleted from Database'.
    *        ENDIF.
          ENDIF.
            MODIFY  ZLT_Auftrag1 from it_Auftrag1.  ==> This modification doesn't works.
             If sy-subrc = 0.
              MESSAGE S000(8i) With 'Data Deleted from Database'.
            ENDIF.
          if sy-subrc <> 0.
            get cursor field fld line linno offset off.
            set cursor field fld line linno offset off.
            if fld cp 'IT_auftrag1*' and sy-subrc = 0.
              linno = linno + tctrl1-top_line - 1.
              delete it_auftrag1 index linno.
              tctrl1-lines = tctrl1-lines - 1.
            endif.
          endif.
    Looking forward for your suggestions.
    Regards
    Chandan

  • Update value of internal table in 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,
    As I can understand, you want
    1. To enter details in two fields. You want to enter data there and then press an enter Button.
    2. This two fields are part of table control in the next screen and it has some data present there. You want to add data of this two fields in the Internal table.
    THere are few options.
    1. Define a Global internal Table.
    2. Fetch Data in that internal Table in your 1st Screen Say 100 with the 2 text fields.
    3. On click of the button. In PAI append data of the fields in the Global Internal Table.
    4. Display internal table by looping on it in the next screen say 200.
    Hope this is the answer you are looking for.
    Try to solve, if you can't then send me message or email.
    Cheers.
    Darshan
    <b><i>** Please reward points if this helps u. It motivates us to write more answer and put more efforts.</i></b>

  • ME51N update MPN Material field in the table control

    Hi Gurus,
    My requirement is to update the field MPN Material in the table control of tcode ME51N as soon as i enter the material this field should get updated.
    Please give me suggestions.
    Regards,
    Milind

    please see the link ...in this the   datefields also included in the table control  of the 
    Screen  program  ....  how the  fields are  populated in the table  using wizard ..
    <a href="http://">http://www.sapdevelopment.co.uk/dialog/tabcontrol/tc_basic.htm</a>
    reward points if it is usefull ....
    Girish

  • How to update DBtable in table control (MPP) for selected lines.

    Hi Folks,
    I need to update DBtable from the table control after modification of  only multiple selected rows.
    But my issue. any row if edited is being modified in DBtable.
    Client does not want me to use Check box so im using Selcolumn in module pool table control.
    Please help me in resolving the issue. Let me know if you have any queries
    Thanks
    Reddy

    Hi Reddy,
    Hope it helps.
    For  Sel column.
    Declare:
    Data : SEL  TYPES XFELD in Structure.
    Double click on the sel  field     give the structure name and field name as below in screen shoot.
    In Flow logic.
    PROCESS AFTER INPUT.
    loop at it_tab.
        FIELD YTBLCTRL-SEL.
    MODULE update.
    ENDLOOP.
    MODULE Updatedb.
    In Editor.
    MODULE UPDATE INPUT.
       MODIFY it_tab FROM YTBLCTRL INDEX tbc1-current_line.
       if ytblctrl-sel IS NOT INITIAL.
       lv_cnt = lv_cnt + 1.
       endif.
    ENDMODULE.
    MODULE UPDATEDB INPUT.
    Case sy-ucomm.
    WHEN 'SAVE'.
    if lv_cnt is NE '1'.
    Message 'select more than one item.
    else.
    Update DB.
    endif.
    Endcase.
    Regards,
    Venkat.

Maybe you are looking for