Help regarding 'table controls' and 'internal table' updation

Hi all.
Basically this is what i have done..... I have created a table control in module pool program. I declared an Internal table and also have populated it from a database table. I have also used insert statement to insert an blank record in the table control view and delete statements to delete any record,  also in the table control view... .
But I am not able to update any new record into an Internal table or  the  original table ..
Any Ideas how to do it ,Gurus
Thanks

HEllo,
Check thsi simple report.
REPORT ZTFH_TABLECONTROL .
TABLES : ZEMPTABLE.
DATA : SELLINE .
DATA : FLD(20).
DATA : LINNO TYPE I , OFF TYPE I.
DATA : ITAB LIKE ZEMPTABLE OCCURS 10 WITH HEADER LINE.
CONTROLS  : CON_TAB TYPE TABLEVIEW USING SCREEN 100.
SELECT * FROM ZEMPTABLE INTO TABLE ITAB.
DESCRIBE TABLE ITAB LINES CON_TAB-LINES.
CALL SCREEN 100.
*&      Module  EXT_COMM  INPUT
*       text
MODULE EXT_COMM INPUT.
LEAVE PROGRAM.
ENDMODULE.                 " EXT_COMM  INPUT
*&      Module  TAB_UPDATE  INPUT
*       text
MODULE TAB_UPDATE INPUT.
CASE SY-UCOMM.
WHEN 'DEL'.
      IF SELLINE = 'X'.
        DELETE ITAB WHERE EMPNO = ITAB-EMPNO.
        MESSAGE I000(ZYF_DEL).
      ENDIF.
WHEN 'UPD'.
    IF SELLINE = 'X'.
         MODIFY ITAB INDEX CON_TAB-CURRENT_LINE.
         MESSAGE I001(ZYF_DEL).
    ENDIF.
WHEN 'INS'.
     IF SELLINE = 'X'.
      GET CURSOR FIELD FLD LINE LINNO OFFSET OFF.
      SET CURSOR FIELD FLD LINE LINNO OFFSET OFF.
      IF FLD CP 'ITAB*' AND SY-SUBRC = 0.
        IF LINNO >= 1.
          LINNO = LINNO + CON_TAB-TOP_LINE - 1.
          CLEAR ITAB.
          INSERT ITAB INDEX LINNO.
          CON_TAB-LINES = CON_TAB-LINES + 1.
        ELSE.
          CLEAR ITAB.
          APPEND ITAB.
          CON_TAB-LINES = CON_TAB-LINES + 1.
        ENDIF.
      ENDIF.
    ENDIF.
WHEN 'SAV'.
  MODIFY ITAB INDEX CON_TAB-CURRENT_LINE.
  MESSAGE I002(ZYF_DEL).
ENDCASE.
ENDMODULE.                 " TAB_UPDATE  INPUT
“ FLOW LOGIC
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
LOOP AT ITAB WITH CONTROL CON_TAB.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
MODULE EXT_COMM AT EXIT-COMMAND.
LOOP AT ITAB.
MODULE TAB_UPDATE.
ENDLOOP.     
REgards,
Vasanth

Similar Messages

  • Table types and internal table

    Hi all,
    What is the relationship between table type in ABAP dictionary and internal table?
    Moderator message : Search for available information OR read ABAP documentation. Thread locked.
    Edited by: Vinod Kumar on Jul 16, 2011 11:16 AM

    You can INCLUDE TYPE.
    Types: begin of itab,
           field1 type string,
           field2 type string,
    *      More Fields in here.
           Field30 type string,
           End of itab.
    Data: lt_itab type table of itab.
    TYPES BEGIN OF new_itab.
           INCLUDE type itab.
    TYPES: field31 type string,
           field32 type string,
    END OF new_itab.
    Regards,
    Rich Heilman

  • Table control from internal table giving problem.

    HI ALL,
    I am creating a table control using wizard from internal table in the program when i give work area it gives this error "The table work area G_TABC_WA does not exist or is not a structure"
    I have declared internal table and work like this.
    TYPES: BEGIN OF T_TABC,
             OPTID LIKE ZHRPMT_TRNSAC-OPTID,
             STGID LIKE ZHRPMT_TRNSAC-STGID,
             TETID LIKE ZHRPMT_TRNSAC-TETID,
             REQSR LIKE ZHRPMT_TRNSAC-REQSR,
             MUNIT LIKE ZHRPMT_TRNSAC-MUNIT,
           END OF T_TABC.
    DATA:     G_TABC_ITAB   TYPE T_TABC OCCURS 0,
                   G_TABC_WA     TYPE T_TABC. "work area
    why it is giving this error and how to correct this.
    thanks.

    Hay
    Hello there is very small mistake
    TYPES: BEGIN OF t_tabc,
    optid TYPE zhrpmt_trnsac-optid,
    stgid TYPE zhrpmt_trnsac-stgid,
    tetid TYPE zhrpmt_trnsac-tetid,
    reqsr TYPE zhrpmt_trnsac-reqsr,
    munit TYPE zhrpmt_trnsac-munit,
    END OF t_tabc.
    DATA: g_tabc_itab TYPE TABLE OF t_tabc ,
    g_tabc_wa LIKE t_tabc. "work area
    **Please reward suitable points***
    With Regards
    Navin Khedikar

  • Sample pgm for moving data from table control to internal table

    Hi Experts,
          I am newbi to ABAP. I don't have good material for Table control . Appreciate if you direct me to some good source of knowledge on Table control.
    The problem at hand : I am trying to move info/data from table control (in screen painter/ input and output mode ) to ITAB but couldn't . Sample pgm if possible.
    <b>Modify ITAB index TC-Current_Line .</b>
    The above statement is not inserting new lines to ITAB . Help me!
    Thanks for your time

    hi,
    do like this...
    <b>PROCESS AFTER INPUT.</b>
    *&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TAB1'
      LOOP AT itab_det.
        CHAIN.
         FIELD itab_det-comp_code.
          FIELD itab_det-bill_no.
          FIELD itab_det-bill_date.
          FIELD itab_det-vend_cust_code.
          FIELD itab_det-bill_amt.
          MODULE <b>tab1_modify</b> ON CHAIN-REQUEST.
        ENDCHAIN.
        FIELD itab_det-mark
          MODULE tab1_mark ON REQUEST.
      ENDLOOP.
    <b>MODULE tab1_modify INPUT.</b>
      APPEND itab_det.
    <b>ENDMODULE.                    "TAB1_MODIFY INPUT</b>

  • Method to transfer data from Table control to Internal table

    hi,
    Hi,
    I´m working with CL_GUI_ALV_GRID and use the following methods:
    - CALL METHOD grid->set_table_for_first_display, to display my ALV;
    - CALL METHOD grid->get_selected_rows, to select the rows.
    But i have some fields that can suffer alterarions in the values...
    How can i recoup this values from the screen? Is there any method to do this?
    thnks.

    HI,
    You neeed to handle the change event.
    Example below...
    Definition.
    Code:
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
              handle_data_changed
            FOR EVENT data_changed
            OF cl_gui_alv_grid
            IMPORTING er_data_changed.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    Implement
    Code:
        CLASS lcl_event_handler IMPLEMENTATION.
      METHOD  handle_data_changed.
        CONSTANTS:
          lc_wa(11) TYPE c VALUE '<LW_SDITM>-'.
        DATA:
          l_subrc TYPE sy-subrc,
          l_variable TYPE string,
          lw_good TYPE lvc_s_modi.
        FIELD-SYMBOLS:
          <lw_sditm> TYPE /powercor/sditm,
          <lw> TYPE ANY. "Generic field symbol
        LOOP AT er_data_changed->mt_good_cells INTO lw_good.
        Update the internal table
          READ TABLE t_item_sel ASSIGNING <lw_sditm> INDEX lw_good-row_id.
          IF sy-subrc EQ 0.
            CONCATENATE lc_wa lw_good-fieldname INTO l_variable.
            ASSIGN (l_variable) TO <lw>.
            IF sy-subrc EQ 0.
              <lw> = lw_good-value.
            ENDIF.
         ENDIF.
         ENDLOOP.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    Set for your grid.
    Code:
      SET HANDLER g_handler->handle_data_changed FOR my_grid.
    Cheers,
    Chandra Sekhar.

  • Table control in internal table

    what will b the sequence to creat module pool
    i.e  topinclude , pbo ,pai , screen-layout, flow logic ,
    i m confused which sequence i follow .

    Hi,
    In the Object Browser, the module pool code belongs to one of the following categories:
    Global fields: data declarations that can be used by all modules in the module pool
    PBO modules: modules that are called before displaying the screen
    PAI modules: modules that are called in response to the user input
    Subroutines: subroutines that can be called from any position within the module pool
    By default, the system divides a module pool into one or several include programs. An include program can contain several modules of the same type (only PBO modules or only PAI modules). The main program then consists of a sequence of INCLUDE statements that link the modules to the module pool:
    *& Module pool      SAPMTZ10
    *& Display data of Table SPFLI
    Global data
    INCLUDE MTZ10TOP.
    PAI modules
    INCLUDE MTZ10I01.
    PBO modules
    INCLUDE MTZ10O01.
    In the ABAP/4 editor, you can display the code hidden behind the INCLUDE statements by choosing Edit ---> More functions ---> EXPAND include. With all INCLUDE statements expanded, the module pool looks like this:
    *& Module pool      SAPMTZ10
    *&           FUNCTION: Display data from Table SPFLI
    INCLUDE MTZ10TOP (This is the TOP include:
    the TOP module contains global data declarations)
    PROGRAM SAPMTZ10.
         TABLES: SPFLI.
         DATA OK_CODE(4).
    INCLUDE MTZ10I01 (This is a PAI include.)
    *& Module USER_COMMAND_0100 INPUT
    Retrieve data from SPFLI or leave transaction
    MODULE USER_COMMAND_0100 INPUT.
    CASE OK_CODE.
         WHEN 'SHOW'.
              CLEAR OK_CODE.
              SELECT SINGLE * FROM SPFLI WHERE CARRID = SPFLI-CARRID
                                                                      AND       CONNID = SPFLI-CONNID.
         WHEN SPACE.
         WHEN OTHERS.
              CLEAR OK_CODE.
              SET SCREEN 0.
              LEAVE SCREEN.
         ENDCASE.
    ENDMODULE.
    INCLUDE MTZ10O01 (This is a PBO include.)
    *& Module STATUS_0100
    Specify GUI status and title for screen 100
    MODULE STATUS_0100.
         SET PF-STATUS 'TZ0100'.
         SET TITLEBAR '100'.
    ENDMODULE.
    You use the ABAP/4 Dictionary to store frequently used data declarations centrally. Objects defined in the Dictionary are known throughout the system. Active Dictionary definitions can be accessed by any application. Data defined in the Dictionary can be included in a screen or used by an ABAP/4 program. You declare global data in the TOP module of the transaction, using the TABLES, STRUCTURE, LIKE statements and others
    Cheers,
    vasu.
    kindly reward if helpful.

  • Table control and a selection screen

    Hi,
    I have a requirement where I am supposed to be designing a screen that has a table control with fields
    w/selection column       label 1(non-editable)          i/o field(from)        i/o field(to)
    w/selection column       label 2(non-editable)          i/o field(from)        i/o field(to)
    On searching the forum threads, I found related threads as to how to implement a selection screen (as the I/O fields are similar to select-options) in module pool programming. But mine requires the use of table control and a kind of selection screen embedded into it. Please guide me through this requirement.

    Hi
    If you need to implement a table control on selection screen u need to use a tabstrip as graphic element supports the table control.
    So
    1 - Step: define a tabstrip with 1 tab only:
    SELECTION-SCREEN BEGIN OF BLOCK 3.
    SELECTION-SCREEN BEGIN OF TABBED BLOCK MAX FOR 22 LINES.
    SELECTION-SCREEN TAB (25) TABS1 USER-COMMAND UCOMM1
             DEFAULT SCREEN 100.
    SELECTION-SCREEN END OF BLOCK MAX.
    SELECTION-SCREEN END OF BLOCK 3.
    2 - Step design the subscreen (in my sample the dynrpo 100) and insert the table control there:
    PROCESS BEFORE OUTPUT.
      MODULE INIT_CTRL.
      LOOP WITH CONTROL T_CTRL.
        MODULE DISPLAY_DATA.
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP WITH CONTROL T_CTRL.
          MODULE UPDATE_DATA.
      ENDLOOP.
    In the module DISPLAY_DATA and UPDATE_DATA u need to implement the code to transfer the data from internal table to table control and from table control to internal table, in order to display and update the data.
    Max

  • How to insert row in table control and save the data in tables

    Hi,
    I have one table control i am displaying data into table control ,
    my problem is : i want to display data into read mode in table control.
    but when i click on insert button on the same screen i want one blank line should inserted into table control , then i want to insert some data into table control on that row , when i click the save button . the new data inserted into the table control is insert that data into ztable ,
    please give me solution
    main problen is  how can know inserted line in table control and pass that data into ztable.

    Hi,
    Follow the below logic,
    PROCESS BEFORE OUTPUT.
      MODULE STATUS_0001.
      MODULE POPULATE_TABLE_CONTROL. --> Get the data from table store in 
                                                                          ITAB
      LOOP AT GT_CTRL_LP_D516 INTO GS_WA_CTRL_LP_D516
           WITH CONTROL CTRL_LP_D516
           CURSOR CTRL_LP_D516-CURRENT_LINE.
      The following module moves data to control
        MODULE MOVE_TO_CONTROL.--> Move data from ITAB to table control
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP AT GT_CTRL_LP_D516.
      ENDLOOP.
      MODULE EXIT AT EXIT-COMMAND.
      MODULE USER_COMMAND_0001.  --> Here you have to take out the values from table control and update database table
    Reward points if helpful.
    Thanks and regards,
    Mallareddy Rayapureddy,
    Munich, Germany.

  • SAP QUERY LOOPS AND INTERNAL TABLE

    Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
    The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
    I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
    POINTS WILL BE REWARDED
    Thanks
    Kind Regards
    Adeel Sarwar

    Hi,
    This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
    Thanks
    TABLES: EKBE.
    DATA: PurO LIKE EKPO-EBELN,
          POLI LIKE EKPO-EBELP.
    *New Table and Vars defined
    DATA:   BEGIN OF IT_EKBE,
              IT_EKBE LIKE EKBE,
            END OF IT_EKBE.
    DATA:  BEGIN OF IT_SUM OCCURS 0,
              EBELN TYPE EBELN,
              EBELP TYPE EBELP,
              DMBTR TYPE DMBTR,
              MENGE TYPE MENGE,
          END OF IT_SUM.
    CLEAR: QTYD.
    MOVE: EKPO-EBELN TO PurO,
          EKPO-EBELP TO POLI.
    SELECT * FROM EKBE INTO IT_EKBE
        WHERE EBELN = PurO
        AND   EBELP = POLI
        AND   BEWTP = 'E'
    LOOP AT IT_EKBE.
      MOVE CORRESPOING IT_EKBE TO IT_SUM.
      IF IT_EKBE-BWART = '102'.
        IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
        IT_SUM-MENGE = IT_SUM-MENGE * -1.
      ENIDF.
      COLLECT IT_SUM.
      CLEAR IT_SUM.
    ENDLOOP.
    ENDSELECT.
    If sy-subrc = 0.
      QTYD = IT_SUM.
    ELSE.
      QTYD = 0.
    ENDIF.

  • Export - Import In ABAP ( for variables and internal table)

    how can we pass value for the variable and internal table using Export and Import?
    data: var type sy-uzeit.
    var = sy-uzeit.
    EXPORT var TO MEMORY ID 'TIME'.
    data: var type sy-uzeit.
    IMPORT var FROM MEMORY ID 'TIME'.
    write:/ var,sy-subrc,sy-uzeit.
    i found var value 0 while importing. 
    what is the right syntax for passing value of variable and internaltable.
    regards,
    dushyant.

    Hi,
    There are two possible solutions.
    Solution1:
    Program1.Should be run before atleast once so that TIME should be filled.
    data: var type sy-uzeit.
    var = sy-uzeit.
    EXPORT var TO MEMORY ID 'TIME'.
    Program2.IF the TIME is filled,then only it will produce the result.
    data: var type sy-uzeit.
    clear var.
    IMPORT var FROM MEMORY ID 'TIME'.
    write:/ var, sy-subrc, sy-uzeit.
    Solution2:
    Single program:
    data: var type sy-uzeit.
    var = sy-uzeit.
    EXPORT var TO MEMORY ID 'TIME'.
    clear var.
    IMPORT var FROM MEMORY ID 'TIME'.
    write:/ var, sy-subrc, sy-uzeit.
    Kindly reward points by clikcing the star on the left of reply,if it helps.

  • DATA BASE TABLE AND INTERNAL TABLE

    Dear Friends,
    please help me out in getting complete information about database table and internal table.
    you can email me at < Removed by moderator - please maintain e-mail iDs in Business Card>
    Message was edited by:
            Arun Varadarajan

    Hi Hazi,
    <b>DATABASE Tables :</b>
    This are the tables which are stored in the database (eg Oracle , informix , DB2 etc..) Physically. u can view it from T-codes SE11 or SE16. here in SE11 u can create ur own Transparent table.
    for more information...
    http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/dictionary_tutorial.html
    <b>Internal Tables.</b>
    While generating reports or other objects we are not modifying the database tables directly first we are selecting the data of the database table into the internal tables... so that we can reduce the database access time and network traffic .. which is highly needed in R/3 system..
    internal tables are not exist phyiscally in the system. its like a array. the existance of the internal tables is upto the program execution in which u r declaring nd using it...
    for more information..
    http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/internaltables_tutorial.html
    Hope it will solve ur problem..
    <b>Reward points if useful..</b>
    Thanks & Regards
    ilesh 24x7

  • Updating database table from an internal table

    Hi All,
    I am updating a database table from an internal table.
    I am changing the non-key fields in that table.
    when I check sy-subrc = 4.
    Record already exists, because I am changing non-key fields of the
    database table.
    Is there any addition like to accept the duplicate keys with update.
    Alternatively, I have used Modify, It is adding new record,
    Again, I have search the old record and use Delete on the database table.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP ABAP Consultant

    Hi,
    You are right, the field which I am trying to change is a part of primary key.
    Because, sy-subrc = 4. says,
    No line with specified primary key exits in the database table.
    I have a Z-tabel, with Kunnr Vkorg Matnr Bzirk Bztxt Split_percentage
    In this table primary key consists of KunnrVkorgMatnr+Bzirk.
    I am able to change the Split_percentage using UPDATE.
    Now, my client want to change Bzirk, Bztxt also in the table.
    How can I Go.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP ABAP Consultant

  • TABLE CONTROL AND SCREEN

    HI Gurus,
    i have to following requirement,
    i have to make a screen  in which there would be four fields
    name          xxx
    age               x
    date          xx.xx.xx
    time          xx xx xx
    the screen fields are to by filled by the user at the run time and this data should be saved in the data base table(say ztable)
    so as far i have understood i need to create a screen with a table control and a database table  to save the data of the table control (after the user press save buttom)
    please help me how to create a table control
    and also
    help me with the logic of calling the screen(this screen with table control)
    also the logic of save butoom too
    please help as soon as possible
    points will be surely awarded ..
    thanks in advance
    anuj

    use this eg to your requirement
    PROGRAM YTABLEDML .
    TABLES : KNA1.
    DATA : ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.
    CONTROLS : VCONTROL TYPE TABLEVIEW USING SCREEN '100'.
    MODULE USER_COMMAND_0100 INPUT.
    CASE SY-UCOMM.
    WHEN 'INSERT'.
    MOVE KNA1 TO ITAB.
    APPEND ITAB.
    INSERT INTO KNA1 VALUES ITAB.
    IF SY-SUBRC = 0.
    MESSAGE I000(0) WITH 'INSERTED'.
    ELSE.
    MESSAGE E001(0) WITH 'NOTINSERTED'.
    ENDIF.
    WHEN 'UPDATE'.
    MOVE KNA1 TO ITAB.
    APPEND ITAB.
    UPDATE KNA1 FROM TABLE ITAB.
    IF SY-SUBRC = 0.
    MESSAGE I000(0) WITH 'UPDATED'.
    ELSE.
    MESSAGE E001(0) WITH 'NOTUPDATED'.
    ENDIF.
    WHEN 'DELETE'.
    MOVE KNA1 TO ITAB.
    APPEND ITAB.
    DELETE FROM KNA1 WHERE KUNNR = ITAB-KUNNR.
    MESSAGE I000(0) WITH 'DELETED'.
    IF SY-SUBRC = 0.
    ELSE.
    MESSAGE E001(0) WITH 'NOTDELETED'.
    ENDIF.
    ENDCASE.
    ENDMODULE.
    MODULE USER_EXIT INPUT.
    CASE SY-UCOMM.
    WHEN 'EXIT'.
    CALL TRANSACTION 'SE38'.
    ENDCASE.
    ENDMODULE.
    *PROCESS BEFORE OUTPUT.
    *LOOP WITH CONTROL VCONTROL.
    *ENDLOOP.
    MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    *LOOP WITH CONTROL VCONTROL.
    MODULE USER_COMMAND_0100.
    ENDLOOP.
    *MODULE USER_EXIT.
    TCODE IS YDMLTAB.

  • Difference between work area and internal tables.

    Hi  I wanna know the difference between work area and internal tables.
    what happend if i give with out header line in internal table.
    also how to assosiate work area to internal table in that scenario.

    Hi Balaji..
    The internal table is an ABAP runtime object which has two parts the Body and the header.
    Whereas a work area cannot have a body.. It is mere a field or group of fields which can hold values at runtime..
    In the SAP higher versions mySAP ERP, the use of tables with header line is made obsolete.. But there is absolutely no problem with the same..
    Just think that when you define an internal table with occurs or with header line statement, the system automatically creates a workarea with this table, using which you can access the contents in the bosy of tyhe table.. You can read a record from the table body to this header or add a record in the header to the internal table body..
    When you work with a table ITAB without a header line, you can not use statements like READ TABLE, APPEND, INSERT etc without giving an explicit work area..
    Suppose i have an internal table like:
    DATA : itab TYPE STANDARD TABLE OF t001.
    This table will not have a header with it.
    If you will use APPEND itab. The compilor will give error.
    Here i will create a work area with same structure of the table.
    DATA : e_wa TYPE t001.
    Now i will write:
    APPEND e_wa TO itab.
    READ TABLE itab INTO e_wa WITH KEY xxxxxx
    LOOP AT itab INTO e_wa...           etc..
    In a better approach we use Field symbols with such tables, instead of structures
    FIELD-SYMBOLS: <fs_itab> TYPE t001.
    So,
    LOOP AT itab ASSIGNING <fs_itab>
    READ TABLE itab ASSIGNING <fs_itab> etc.. However we can not use field symbols in few cases..
    I hope this will help you..
    Thanks and Best Regards,
    Vikas Bittera.
    **Points for usefull answers**

  • What are the uses of table control and tabstrip control

    can anyone tell me the uses of table control and tabstrip control

    Hi,
    table control is more comfortable for customizing.scroll bars all possible in this.where as it is not possible in step loops.
    check this example.
    PROGRAM ZBHTCTRL.
    TABLES: LFA1, EKKO.
    DATA: OKCODE1 LIKE SY-UCOMM,
    OKCODE2 LIKE SY-UCOMM.
    CONTROLS TABC TYPE TABLEVIEW USING SCREEN 1001.
    DATA: BEGIN OF ITAB OCCURS 0,
    MANDT LIKE EKKO-MANDT,
    EBELN LIKE EKKO-EBELN,
    BSTYP LIKE EKKO-BSTYP,
    BSART LIKE EKKO-BSART,
    END OF ITAB.
    MODULE USER_COMMAND_1000 INPUT.
    CASE OKCODE1.
    WHEN 'BACK'.
    SET SCREEN 0.
    WHEN 'NEXT'.
    SET SCREEN 1001.
    SELECT * FROM EKKO INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE
    LIFNR = LFA1-LIFNR.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_1001 INPUT
    MODULE MOVE_DATA OUTPUT.
    EKKO-MANDT = ITAB-MANDT.
    EKKO-EBELN = ITAB-EBELN.
    EKKO-BSTYP = ITAB-BSTYP.
    EKKO-BSART = ITAB-BSART.
    ENDMODULE. " MOVE_DATA OUTPUT
    MODULE USER_COMMAND_1001 INPUT.
    CASE OKCODE2.
    WHEN 'BACK'.
    SET SCREEN 1000.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_1001 OUTPUT
    MODULE STATUS_1001 OUTPUT.
    SET PF-STATUS 'MENU'.
    SET TITLEBAR 'TIT'.
    ENDMODULE. " STATUS_1001 OUTPUT
    MODULE STATUS_1000 OUTPUT.
    SET PF-STATUS 'DMENU'.
    SET TITLEBAR 'xxx'.
    ENDMODULE. " STATUS_1000 OUTPUT
    FORM ON_CTMENU_FORM1 USING CMENU TYPE REF TO CL_CTMENU.
    CALL METHOD CMENU->LOAD_GUI_STATUS
    EXPORTING
    PROGRAM = ' ZBHTCTRL'
    STATUS = 'CMENU'
    MENU = CMENU.
    CALL METHOD CMENU->ADD_FUNCTION
    EXPORTING
    FCODE = 'RX'
    TEXT = 'RECIEVE'.
    ENDFORM.
    FLOW LOGIC:
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_1000.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_1000.
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_1001.
    LOOP AT ITAB WITH CONTROL TABC CURSOR TABC-TOP_LINE.
    MODULE MOVE_DATA.
    ENDLOOP.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_1001.
    LOOP AT ITAB.
    ENDLOOP.
    for more info check this link.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/content.htm
    thanks
    Ashu.

Maybe you are looking for