Append a record to internal table

hello:
when i execute the code below,there is a runtime error." In die sortierte interne Tabelle (Typ SORTED_TABLE)
  "PROGRAM=ZJOIN_INTER_TABLEDATA=T_ITAB1" sollte an
Position 1 eine Zeile eingefügt bzw. geändert werden.
Dadurch wurde die für die Tabelle durch ihren Schlüssel festgelegte
Sortierreihenfolge zerstört."
how can i resolve it?which one can tell me?Thanks very much
REPORT  ZJOIN_INTER_TABLE.
DATA:BEGIN OF WA_ITAB,
        COL1 TYPE I,
        COL2(10) TYPE C,
      END OF WA_ITAB.
DATA:T_ITAB1 LIKE SORTED TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
WA_ITAB-COL1 = 10.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
WA_ITAB-COL1 = 9.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.

hi
kindly go thro the lines.
syntax:
DATA itab {TYPE tabkind OF linetype|LIKE tabkind OF lineobj}
          WITH [UNIQUE|NON-UNIQUE] keydef
          [INITIAL SIZE n] [WITH HEADER LINE].
The system creates an internal table with table type tabkind. Since there is no generic field definition, you cannot use the table types ANY TABLE or SORTED TABLE.
The construction of the table lines is defined by linetype (if you are using a TYPE reference) or by the type of the referred object lineobj (if you are using a LIKE reference). If you specify the line type, you can also use REF TO to refer to a reference type.
The same rules apply to UNIQUE and NON-UNIQUE as apply to the TYPES definition. You may only omit this specification with standard tables.
If you do not specify an INITIAL SIZE, the system assumes a default value of INITIAL SIZE 0.
i think now u r clear... now yr code will work.
DATA:BEGIN OF WA_ITAB,
COL1 TYPE I,
COL2(10) TYPE C,
END OF WA_ITAB.
DATA:T_ITAB1 like TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
WA_ITAB-COL1 = 10.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
WA_ITAB-COL1 = 9.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.

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

  • Inserting records from internal table to database table

    Hi all,
    i want to insert records from internal table to zDatabase table, can u plz guide me which statement is better in performance to insert the records.
    1) insert one by one record from internal table
    loop at itab.
    insert ztable from wa.
    endloop.
    2) insert total records at a time
    INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or let me know if any other statement is there with high performance.
    i internal table contains nearly 40000 records.
    thanks.

    Hi,
    Insert the entire table at atime rather than a record so as to increase the performance.
    you can use INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or
    MODIFY ZPRODUCT FROM TABLE GI_AFPO.
    Regards,
    Raj.

  • To delete duplicate records from internal table

    hi friends,
    i have to delete records from internal table based on following criterion.
    total fields are 7.
    out of which  if 4 fields are same and 5th field is different,then both records must be deleted.
    in case all five fields are same,the program should do nothing.
    for example.
    if there are 3 records as follows
    a1 b1 c1 d1 e1 f g
    a1 b1 c1 d1 e2 w r
    a1 b1 c1 d1 e1 j l
    then first two records should be deleted as four fields are same but fifth(e) field differs.
    but third record should remain as it is evenif first five fields are same for first and third record.
    values of last two fields need not to be consider for deleting the records.

    LOOP AT ITAB.
      V_FILED5 = ITAB-F5. "to compare later
      V_TABIX = SY-TABIX. "used to delete if condition not matches
      READ TABLE ITAB WITH KEY F1 = ITAB-F1
                               F2 = ITAB-F2
                               F3 = ITAB-F3
                               F4 = ITAB-F4.
      IF SY-SUBRC = 0.
        IF ITAB-F5 <> V_FIELD5.
    *--both the records to be deleted,as Field5 is different.
          DELETE ITAB INDEX SY-TABIX. "deletes that record
          DELETE ITAB INDEX V_TABIX. "deletes the current record
        ENDIF.
      ENDIF.
    ENDLOOP.
    Message was edited by: Srikanth Kidambi
    added comments
    Message was edited by: Srikanth Kidambi

  • How to fetch previous record from internal table?

    Hi,
    My final internal table (it_final) has all the data month wise year wise.(opening and closing qty)
    but if
    Material   Batch    Month   Year        opening_qty         closing_qty
    FC5431   abc        08        2008        100                       50
    FC5431   ABC       09        2009         0                          100
    Suppose I want to take PREVIOUS record(closing_qty = 50  in my 09/2009  openin_qty = 50)  how will Ido this?
    Any solution????????? BTW i m using S033 for opening an closing qt monthwise.
    Plz reply soon if anyone knows.
    Thanks and Regards,
    Archana

    Hi,
    Test the following Sample code hope will solve out your problem,
    TYPES:  BEGIN OF ty_test,
            m(3),
            open_qty TYPE i,
            close_qty TYPE i,
            END OF ty_test.
    DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE,
          wa_test LIKE LINE OF it_test,
          ctabix LIKE sy-tabix,
          ptabix LIKE sy-tabix.
    it_test-m = 'AAA'. it_test-open_qty = 100. it_test-close_qty = 50. append it_test.
    it_test-m = 'AAA'. it_test-open_qty =  0. it_test-close_qty = 100. append it_test.
    LOOP AT it_test.
      ctabix = sy-tabix.
      IF sy-tabix > 1.
        ptabix = sy-tabix - 1.
        READ TABLE it_test into wa_test INDEX ptabix.
        IF sy-subrc = 0.
          it_test-open_qty = wa_test-close_qty.
        ENDIF.
        MODIFY it_test INDEX ctabix.
      ENDIF.
    ENDLOOP.
    LOOP AT it_test.
      WRITE: it_test-m, it_test-open_qty, it_test-close_qty, /.
    ENDLOOP.
    Regards,
    Faisal

  • Delete records from internal table

    hi all,
    i want to delete records from intenal table which are starting with a particular starting number .
    eg internal table
    10000
    20000
    90000
    91000
    92000
    88880
    i want delete the records starting with 9 i.e. 90000 91000 92000.
    Thanks in Adv
            RAJ

    You can test this piece of code.
    DATA:
    i_tab TYPE STANDARD TABLE OF mara,
    wa_tab TYPE mara.
    wa_tab-matnr = '1000'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1002'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1003'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '2001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '3001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '4010'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Aug 8, 2008 4:49 PM

  • To find the duplicate record in internal table

    Hi,
    i have a requirement to fine the duplicate record with 3 fields.
    i am getting a flat file with 15 fields  .
    i need to check the duplaicate records of  3 fields . if i get any 2nd same record of 3 fields , the records will go to other internal table.
    for ex :
    1. aaa  bbb ccc ddd  eee  fff  ggg   hhh
    2. aaa  bbb ccf  dde edd  ffg ggh   hhj
    3. aaa  bbb cce ddd  ees ffh  ggu  hhk
    in that 1st record and 3rd record are same (aaa bbb ddd)
    i need to find 3rd record
    please help me
    regrards
    srinivasu

    hi,
    itab2[] = itab1[].
    sort itab1 by f1 f2 f3.
    sort itab2 by f1 f2 f3.
    delete itab2 index 1.   "to delete the first record in itab2.
    loop at itab1 into ws_itab1.
      loop at itab2 into ws_itab2.
       if ws_itab1-f1 = ws_itab2-f1 and
         ws_itab1-f2 = ws_itab2-f2 and
        ws_itab1-f3 = ws_itab2-f3.
         ws_itab3 = ws_itab2.
         append ws_itab3 into itab3.   "Third internal table.
       endif.
    endloop.
    delete itab2 index 1.   
    endloop.
    ITAB3 will have all the duplicate records.
    Regards,
    Subramanian

  • Question reg. modifying latest record in internal table

    Can you tell me if it is possible to modify the last appended record to the internal table?
    I just want to modify the record in the internal table which is appended at the latest. Please tell me the logic for this.
    Thanks a lot,
    Krishen

    Hi try with this:
    DATA line TYPE I.
    DATA wa_itab TYPE LINE OF it_itab.
    DESCRIBE TABLE IT_TABLE LINE line.
    READ TABLE IT_TABLE INTO wa_itab INDEX line.
    WA_TABLE-FIELD = 'new value'.
    MODIFY TABLE IT_TABLE FROM wa_itab
           TRANSPORTING field.
    Best regards.

  • Only first record in internal table in output

    Hi,
    I have a requirement.
    I loop at an internal table and that tabl (list_selected_records) records.
    Loop at list_of_selected_nodes into wa_selected_nodes.
    node = wa_selected_nodes-node_id.
    node_level = wa_selected_nodes-node_level.
    read table ex_list_of_texts
    into wa_list_of_texts
    with key node_id = node
    binary search.
    IF sy-subrc eq 0.
    node_text = wa_list_of_texts-text.
    ENDIF.
    node_level = node_level - 1.
    Selecting Text for Node selected (Business Scenario)
    READ TABLE list_of_all_nodes into wa_all_nodes WITH KEY NODE_LEVEL = node_level
    BINARY SEARCH.
    if sy-subrc = 0.
    SELECT SINGLE TEXT FROM TTREET into texts WHERE ID EQ wa_all_nodes-tree_id
    AND SPRAS EQ 'EN '.
    IF NOT TEXTS IS INITIAL.
    wa_final-texts = texts.
    append wa_final to it_final.
    CLEAR WA_FINAL.
    endif.
    endif.
    endloop.
    This is my code.
    Now from the select single stmt i fetch a text and add it to be internal table . Once i fetch a one record the loop should be ended and a new iteration for for a second guid should start.
    Once one record , first record is fetched for texts, only that shd appear in alv output but not other. but the loop should contnue for other fields. Please help
    Thanks in Advance.
    SS

    Hi Swarna,
    Use control event AT-NEW inside the loop. This event will triger only once for every new node_id.
    Loop at list_of_selected_nodes into wa_selected_nodes.
    AT-NEW node_id.
    node = wa_selected_nodes-node_id.
    node_level = wa_selected_nodes-node_level.
    read table ex_list_of_texts
    into wa_list_of_texts
    with key node_id = node
    binary search.
    IF sy-subrc eq 0.
    node_text = wa_list_of_texts-text.
    ENDIF.
    node_level = node_level - 1.
    Selecting Text for Node selected (Business Scenario)
    READ TABLE list_of_all_nodes into wa_all_nodes WITH KEY NODE_LEVEL = node_level
    BINARY SEARCH.
    if sy-subrc = 0.
    SELECT SINGLE TEXT FROM TTREET into texts WHERE ID EQ wa_all_nodes-tree_id
    AND SPRAS EQ 'EN '.
    IF NOT TEXTS IS INITIAL.
    wa_final-texts = texts.
    append wa_final to it_final.
    CLEAR WA_FINAL.
    endif.
    endif.
    ENDAT.
    endloop.
    Thanks & Regards,
    Parameswaran.K

  • Calling record in internal table

    Hi,
    I have an internal table itab of this type:
    types: begin of tdat
      fld1(10) type c,
      fld2(10) type c,
      fld3(10) type c,
      end of tdat.
    All I want to do is assign the second field of the second record of the internal table to a variable.  How do I do so?
    thanks!

    Not sure what you requirement is......but you can do this too.
    report zrich_0001.
    data: begin of itab occurs 0,
          fld1(10)  type c,
          fld2(10)  type c,
          fld3(10)  type c,
          end of itab.
    field-symbols: <fs>.
    data: some_variable(10).
    itab-fld1 = '1'.
    itab-fld2 = '2'.
    itab-fld3 = '3'.
    append itab.
    itab-fld1 = '4'.
    itab-fld2 = '5'.
    itab-fld3 = '6'.
    append itab.
    itab-fld1 = '7'.
    itab-fld2 = '8'.
    itab-fld3 = '9'.
    append itab.
    assign itab-fld2 to <fs>.
    read table itab index 2.
    check sy-subrc = 0.
    some_variable = <fs>.
    Regards,
    Rich Heilman

  • Want last record in internal table

    Hi All,
    I have two internal table. in one internal table all data are available. now i want last record on first internal table and store in second internal table.... so give me some logic or sample code......
    Thanks
    zeni

    get the latest record from an internal table.
    if you are using function module RH_READ_INFTY_1001 then <itab
     > will always contain all the records betweebn specified period (taken from selection screen), but to retrieve the latest, sort the records by ENDDA and you will get it on top, then use INDEX 1 for that record only, and store the record in a <work_area>, finally get that record from <work_area> to <itab> it self. thats way your <itab> will hold only latest record.  
    (you can store <work_area> in <work_area_2> and then pass the record in to <itab>
    or, you can store the <work_area> to a different <itab_2>).
       call function RH_READ_INFTY_1001
       tables
          i1001         = it_hrp1001
      sort  it_hrp1001 by endda descending.
      read table it_hrp1001 into wa_hrp1001 INDEX 1.
      refresh it_hrp1001.
      append wa_hrp1001 to it_hrp1001.

  • Identifying the maximum length of a record in internal table

    Hi,
    Im using an internal table for a string for some requirement.
    Now, at later point of time i need to use for CHAR variable to copy the data from the above internal table.
    I need to identify the max length of the record stored in this internal table so that i can assign that much length to this CHAR variable.
    Is there any standard fm or any abap stmts.
    Thanks
    rohith

    You have to Loop the entire Itab to find the Maximum length of the record stored.
    Just like this:
    data: begin of itab occurs 0,
            v_str1 type string,
          end of itab.
    data: v_len type i.
    data: v_len1 type i.
    itab-v_str1 = 'mahesh sap abap'.
    append itab. clear itab.
    itab-v_str1 = 'mahesh'.
    append itab. clear itab.
    itab-v_str1 = 'mahesh sap'.
    append itab. clear itab.
    loop at itab.
      v_len = strlen( itab-v_str1 ).
      if v_len > v_len1.
        v_len1 = v_len.
      else.
        continue.
      endif.
      clear: v_len.
    endloop.
    write:/ 'Max Length', v_len1.

  • Number of records in internal table

    Hi
    How can I tjeck an internal table for the number of records it contains (even if it contains 0).
    Thanks in advance, regards
    Torben

    Hi,
    DESCRIBE TABLE itab.
    Effect
    Returns the attributes of the internal table itab. You must use at least one of the additions listed below:
    Note
    The DESCRIBE statement cannot be used for all ABAP types. In connection with ABAP Objects, SAP has introduced a RTTI concept based on system classes to determine type attributes at runtime. This concept applies to all ABAP types and as such covers all the functions of the DESCRIBE TABLE statement.
    Extras:
    1. ... LINES n
    2. ... OCCURS n
    3. ... KIND   k
    Addition 1
    ... LINES n
    Effect
    Places the number of filled lines of the table t in the field lin. The value returned to lin has type I.
    Note
    The number of filled lines of the table itab can also be ascertained using the predefined function lines( itab ).
    Example
    DATA: N    TYPE I,
          ITAB TYPE TABLE OF I.
    CLEAR ITAB.
    APPEND 36 TO ITAB.
    DESCRIBE TABLE ITAB LINES N.
    Result: N contains the value 1.
    Addition 2
    ... OCCURS n
    Effect
    Passes the size of the OCCURS parameter from the table definition (as defined with DATA) to the variable n. The value returned to n has type I.
    Example
    DATA: N1    TYPE I,
          N2    TYPE I,
          ITAB1 TYPE TABLE OF I INITIAL SIZE 10,
          ITAB2 TYPE I OCCURS 5.
    DESCRIBE TABLE ITAB1 OCCURS N1.
    DESCRIBE TABLE ITAB2 OCCURS N2.
    Result: OCC contains the value 10 and N2 the value 5.
    Addition 3
    ... KIND k
    Effect
    Writes the table type from itab to the variables n. The value returned to k is of type C. The constants SYDES_KIND-STANDARD, SYDES_KIND-SORTED and SYDES_KIND-HASHED are defined in the type group SYDES for the return values.
    Example
    Generic FORM routine any table type
    TYPE-POOLS: SYDES.
    FORM GENERIC_FORM USING ITAB TYPE ANY TABLE.
      DATA: K TYPE C.
      DESCRIBE TABLE ITAB KIND K.
      CASE K.
        WHEN SYDES_KIND-STANDARD.
        WHEN SYDES_KIND-SORTED.
        WHEN SYDES_KIND-HASHED.
      ENDCASE.
    ENDFORM.
    Notes
    Performance: The runtime for executing the DESCRIBE TABLE statement is approximately 4 msn (standardized microseconds).
    The DESCRIBE TABLE statement also passes values to the SY-TFILL and SY-TLENG System fields
    Additional help
    Determining the Attributesof Internal Tables
    Thanks,
    Sankar M

  • Duplicate records in Internal table

    Hi All,
    I want to find out the duplicate entry in the internal table. I have used,
    Delete Adjacent duplicates from itab.
    It is straight away deleting the record.
    I want the user to correct that duplicate record.
    May be some error message.
    I have tried, with read,
    Read table itab with key bzirk = itab-bzirk vkorg = itab-vkorg kunnr = itab-kunnr
    matnr = itab-matnr comparing bzirk vkorg kunnr matnr.
    But it's giving sy-subrc = 0 for the first record also.
    Even, I have tried like, but it's giving syntax error.
    Loop at itab where bzirk = itab-bzirk vkorg = itab-vkorg kunnr = itab-kunnr
    matnr = itab-matnr.
    Endloop.
    Any method in case on Table control entries.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP Consultant

    Hi,
    Create a new internal table and assign the all the records of itab1 to itab2.
    1.Sort Itab2.
    2.delete adjacent duplicates.
    3. loop at itab2.
         loop at itab1 where <conditon you want....>
         count = count + 1.
         endloop.
          if count GT 1.
            append the iatb2 records for user correction....
          endif.
       endloop.
    If the hint is useful… Say thanks by reward….
    Regards,
    Prabhu Rajesh

  • Update all alv (grid) displayed records to internal table

    Hi all,
    i want to update the records into the internal table which are changed by the user in the edit field.
    after he select save button.
    i  have to save the ALV grid displayed records in the internal table.
    hw can i do this ?

    ALV with EDIT and SAVE functionality
    Code:REPORT z_demo_alv_jg.*******************************************************************
    TYPE-POOLS                                                      *
    TYPE-POOLS: slis. *******************************************************************
    INTERNAL TABLES/WORK AREAS/VARIABLES     *
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
          w_field TYPE slis_fieldcat_alv,
          p_table LIKE dd02l-tabname,
          dy_table TYPE REF TO data,
          dy_tab TYPE REF TO data,
          dy_line TYPE REF TO data.*******************************************************************
    FIELD-SYMBOLS                                                   *
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa> TYPE ANY,
                   <dyn_field> TYPE ANY,
                   <dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
    SELECTION SCREEN                                                *
    PARAMETERS: tabname(30) TYPE c,
                lines(5)  TYPE n.*******************************************************************
    START-OF-SELECTION                                              *
    START-OF-SELECTION.* Storing table name
      p_table = tabname.* Create internal table dynamically with the stucture of table name
    entered in the selection screen
      CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_table->* TO <dyn_table>.
      IF sy-subrc <> 0.
        MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.    LEAVE TO LIST-PROCESSING.
      ENDIF.
    Create workarea for the table
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
      CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_tab->* TO <dyn_tab_temp>.  SORT i_fieldcat BY col_pos.* Select data from table
      SELECT * FROM (p_table)
      INTO TABLE <dyn_table>
      UP TO lines ROWS.  REFRESH <dyn_tab_temp>.* Display report
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_structure_name         = p_table
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
        TABLES
          t_outtab                 = <dyn_table>
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.  IF sy-subrc <> 0.  ENDIF.&----
    *&      Form  SET_PF_STATUS
          Setting custom PF-Status
         -->RT_EXTAB   Excluding table
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.  SET PF-STATUS 'Z_STANDARD'.ENDFORM.                    "SET_PF_STATUS&----
    *&      Form  user_command
          Handling custom function codes
         -->R_UCOMM      Function code value
         -->RS_SELFIELD  Info. of cursor position in ALV
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                               rs_selfield TYPE slis_selfield.* Local data declaration
      DATA: li_tab TYPE REF TO data,
            l_line TYPE REF TO data.* Local field-symbols
      FIELD-SYMBOLS:<l_tab> TYPE table,
                    <l_wa>  TYPE ANY.* Create table
      CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN li_tab->* TO <l_tab>.* Create workarea
      CREATE DATA l_line LIKE LINE OF <l_tab>.
      ASSIGN l_line->* TO <l_wa>.  CASE r_ucomm.*   When a record is selected
        WHEN '&IC1'.*     Read the selected record
          READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
          rs_selfield-tabindex.      IF sy-subrc = 0.*       Store the record in an internal table
            APPEND <dyn_wa> TO <l_tab>.*       Fetch the field catalog info
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
              EXPORTING
                i_program_name         = 'Z_DEMO_PDF_JG'
                i_structure_name       = p_table
              CHANGING
                ct_fieldcat            = i_fieldcat
              EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
            IF sy-subrc = 0.*         Make all the fields input enabled except key fields
              w_field-input = 'X'.          MODIFY i_fieldcat FROM w_field TRANSPORTING input
              WHERE key IS INITIAL.        ENDIF.*       Display the record for editing purpose
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
              EXPORTING
                i_callback_program    = sy-repid
                i_structure_name      = p_table
                it_fieldcat           = i_fieldcat
                i_screen_start_column = 10
                i_screen_start_line   = 15
                i_screen_end_column   = 200
                i_screen_end_line     = 20
              TABLES
                t_outtab              = <l_tab>
              EXCEPTIONS
                program_error         = 1
                OTHERS                = 2.        IF sy-subrc = 0.*         Read the modified data
              READ TABLE <l_tab> INDEX 1 INTO <l_wa>.*         If the record is changed then track its index no.
            and populate it in an internal table for future
            action
              IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
                <dyn_wa> = <l_wa>.
                i_index = rs_selfield-tabindex.
                APPEND i_index.
              ENDIF.
            ENDIF.      ENDIF.*   When save button is pressed
        WHEN 'SAVE'.*     Sort the index table
          SORT i_index.*     Delete all duplicate records
          DELETE ADJACENT DUPLICATES FROM i_index.      LOOP AT i_index.*       Find out the changes in the internal table
          and populate these changes in another internal table
            READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
            IF sy-subrc = 0.
              APPEND <dyn_wa> TO <dyn_tab_temp>.
            ENDIF.      ENDLOOP.*     Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = p_table
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.      IF sy-subrc = 0.*       Modify the database table with these changes
            MODIFY (p_table) FROM TABLE <dyn_tab_temp>.        REFRESH <dyn_tab_temp>.*       Unlock the table
            CALL FUNCTION 'DEQUEUE_E_TABLE'
              EXPORTING
                mode_rstable = 'E'
                tabname      = p_table.      ENDIF.
      ENDCASE.  rs_selfield-refresh = 'X'.ENDFORM.                    "user_command

Maybe you are looking for