Regarding sort at table control

Hay guys,
In table control i want to click particular column header and sort it.
could you tell me what setings i have to make in table control
and where i have to write code for sorting.
I am using table control wizard.
suggestion please.
thanks,
ambichan

Hi Ambi Chan,
   this is a sample program to sort:
For this purpose we have to use the type-pools: cxtab.
see the sample code and try.
REPORT ZTEST_TX .
TYPE-POOLS: CXTAB .
DATA : BEGIN OF ITAB OCCURS 0.
          INCLUDE STRUCTURE MARA.
DATA : END OF ITAB.
DATA COL TYPE CXTAB_COLUMN.
CONTROLS : TC TYPE TABLEVIEW USING SCREEN 100.
START-OF-SELECTION.
SELECT * FROM MARA INTO TABLE ITAB.
IF SY-SUBRC = 0 .
ENDIF.
END-OF-SELECTION.
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ZTEST'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& ModulE E INPUT
tExt
MODULE E INPUT.
LEAVE PROGRAM.
ENDMODULE. " E INPUT
*& Module read INPUT
text
MODULE READ INPUT.
READ TABLE ITAB INDEX TC-CURRENT_LINE.
ENDMODULE. " read INPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
DATA: FLDNAME(100),HELP(100).
DATA : T LIKE SY-TABIX.
READ TABLE TC-COLS INTO COL WITH KEY SELECTED = 'X'.
IF SY-SUBRC = 0 .
CLEAR T.
T = SY-TABIX.
ENDIF.
SPLIT COL-SCREEN-NAME AT '-' INTO HELP FLDNAME.
CASE SY-UCOMM .
WHEN 'S+'.
SORT ITAB BY (FLDNAME) ASCENDING.
WHEN 'S-'.
SORT itab BY (FLDNAME) descending.
COL-INVISIBLE = 'X'.
MODIFY TC-COLS FROM COL INDEX T.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Pls reward points if helpful.
- Selvapandian Arunachalam

Similar Messages

  • Dynamic Sort on table control

    Hi friends,
    I am having a problem when sorting the table control dynamically based on the fields selectd.
    sorting is not working, when you select multiple fields ( one numeric field and one character field )  I have written code for handling multiple field sort,gettting field names correctly, everything looks fine but internal table is not getting sorted.
    Is it related unicode issue..?
    Any help will be appreciated.
    Sample code:
    loop at tc_control into lc_cols.
      case lc_cols-selected.
             wehn 'X'.
        split lc_cols-screen-name at '-' into gv_tabname gv_fieldname.
        move gv_fieldname gs_struc+lv_off(20)
        add 20 to lv_off.
      endcase.
    endloop.
    if ok_code = 'ASCE'.
      sort itab by (gs_struc-field1) (gs_struc-field2) ..... ascending
    endif.
    Thanks in advance
    Thiru.p

    Hi
    Try using an internal table for the field names..
    Example
    DATA: BEGIN OF ITAB OCCURS 0,
            MATNR TYPE MATNR,
            WERKS TYPE WERKS_D,
          END OF ITAB.
    DATA: ITAB_FIELD(30) OCCURS 0 WITH HEADER LINE.
    DATA
    ITAB-MATNR = 'ABC'.
    ITAB-WERKS = 'ABCD'.
    APPEND ITAB.
    ITAB-MATNR = 'ABC'.
    ITAB-WERKS = 'ABC'.
    APPEND ITAB.
    SORT INTERNAL TABLE
    ITAB_FIELD = 'MATNR'.
    <b>APPEND ITAB_FIELD.</b>
    ITAB_FIELD = 'WERKS'.
    <b>APPEND ITAB_FIELD.</b>
    <b>SORT ITAB BY (ITAB_FIELD).</b>
    LOOP AT ITAB.
      WRITE: / ITAB-MATNR,ITAB-WERKS.
    ENDLOOP.
    Thanks
    Naren

  • Infotype 80, Maternity leaves: Sort Order of table control

    Hi all,
    I'd like to know if there is a way to sort the table control in Infotype 80 which shows the absences linked to the birth by Date of absence, instead of Code of absence,
    Thanks in advance
    Paolo

    Hi Paolo,
    I dont think it is possible through standard config.
    Use userexit PBAS0001 (funciton module EXIT_SAPFP50M_001 and include ZXPADU01).
    And ask your ABAPer to sort internal table P2001 by date.
    Pradeep.

  • How to refer to a particular field in Table Control.

    Hi,
            How can we refer to a particular field in a table control like 5th row 6th column. The actual requirement of mine is, i have a column with listbox. For each row i need to have different values for the list box. So i need to refer to that particular field in the column and assign the list values. Please kindly help.
    Regards,
    Vinay.

    hi,
    TABLE CONTROL -
    http://www.geekinterview.com/Interview-Questions/SAP-R-3
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbaa4735c111d1829f0000e829fbfe/content.htm
    http://www.sapgenie.com/abap/example_code.htm
    http://help.sap.com/saphelp_46c/helpdata/en/08/bef2dadb5311d1ad10080009b0fb56/content.htm
    http://www.sapgenie.com/links/abap.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c9/5472fc787f11d194c90000e8353423/frameset.htm
    Eg of table Control:
    http://members.aol.com/_ht_a/skarkada/sap/table_control/
    table_control.htm
    http://www.sapdesignguild.org/resources/MiniSG/3_Managing/3_Functions_Table_Control.htm
    Table control in BDC
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/45/adee2396f711d1b46b0000e8a52bed/frameset.htm
    Regards,
    Laxmi

  • How we can use table control

    Table control but without wizard.
    For instance for the table spfli, I want to design and use a table. The necessary steps for a good display and use are what?
    Thanks in advance.

    Hi,
        CHeck this sample code ... if u need more assistance means give ur mail id i will send u a document
    Working with the table control - Example
    Scenario:
    Screen 601 has a table control named CTRL_ANVSTED.
    The table should be filled with records from the table zanvstedm
    For this purpose you use an internal table called TBL_ANVSTED
    Declare the table control
    CONTROLS CTRL_ANVSTED TYPE TABLEVIEW USING SCREEN 601.
    *Internal table used to hold data
    DATA: TBL_ANVSTED LIKE ZANVSTEDM OCCURS 100 WITH HEADER LINE,
    Flag for initial reading
    Data:   FLAG_INITIAL TYPE I VALUE 0.
    PROCESS BEFORE OUTPUT.
    Read data into the table control and the internal table
    PF status etc.
      MODULE INITIALIZE_601.
    Read data from table anvstedm into internal table tbl_anvsted.
      MODULE INIT_TBL_ANVSTED.
    Fill control with data from ythe internal table
      LOOP WITH CONTROL CTRL_ANVSTED.
        MODULE FILL_CTRL_ANVSTED.
      ENDLOOP.
    MODULE INIT_TBL_ANVSTED  OUTPUT.
    Read data from table anvstedm into internal table tbl_anvsted.
      IF FLAG_INITIAL = 0.
        FLAG_INITIAL = 1.
        SELECT * FROM ZANVSTEDM INTO TABLE TBL_ANVSTED.
      ENDIF.
    ENDMODULE.
    MODULE FILL_CTRL_ANVSTED OUTPUT.
    Fill control with data from the internal table
         READ TABLE TBL_ANVSTED INDEX CTRL_ANVSTED-CURRENT_LINE.
         IF SY-SUBRC NE 0.
           EXIT FROM STEP-LOOP.
         ENDIF.
    ENDMODULE.
    PROCESS AFTER INPUT.
    Write changes in table control to internal table
    LOOP WITH CONTROL CTRL_ANVSTED.
      MODULE CTRL_ANVSTED.
    ENDLOOP.
    MODULE CTRL_ANVSTED INPUT.
    Write changes in table control to internal table
       MODIFY TBL_ANVSTED INDEX CTRL_ANVSTED-CURRENT_LINE.
    ENDMODULE.
    Using a Table control with an internal table
    Table control  : TC1
    Internal table : it_zsd00003
    In the attributes of the table control, select w/SelColumn to get a selection
    column on the table control, and give a name (In this example IT_ZSD00003-LINESEL).
    Remember to include the field IT_ZSD00003-LINESEL in the
    internal table ( linesel(1)       type c, ).
    When used with an internal table, remember to program
    the update functionality of the database tables. Update and
    validation can be done when leaving the screen or in PAI using controlname-
    current_line (E.g. TC1-current_line ) to indentify the entry in the internal table.
    process before output.
      module status_0100.
      loop at it_zsd00003 with control tc1 cursor tc1-
    current_line.
        module tc1_set_field_attr.     "Optional
      endloop.
    module status_0100 output.
      set pf-status 'SCREEN0100'.
    OPTIONAL: If it_zsd00003 hasn't allready been filled with
    data, you can do it the first time PBO is called
      module read_data.
    Setting the number of lines of the table control
      describe table it_zsd00003 lines tc1-lines.
    Optional: Place the cursor on line  g_current_line e.g. after a
    validation error has occured
      if not ( g_current_line is initial ).
        tc1-top_line =  g_current_line.
        clear g_current_line.
      endif.
    endmodule.                 " STATUS_0100  OUTPUT
    module read_data.
      if flag is initial.
        perform read_data.
        flag = 1.
      endif.
    endmodule.       
    module tc1_set_field_attr output.
    Optional: Protect some of the columns on the
    table control
        loop at screen.
          if screen-group1 = 'X'.
            screen-input = 0.
            modify screen.
          endif.
        endloop.
      endif.
    endmodule.                 " tc1_set_field_attr  OUTPUT
    process after input.
      loop at it_zsd00003.
         module modify_tc1.
      endloop.
      module user_command_0100.
    module modify_tc1 input.
    Modify an existing entry
      modify it_zsd00003 index tc1-current_line.
    OR
    Appending a new entry
      append it_zsd00003.
    endmodule.                 " modify_tc1  INPUT
    Deleting a single line selected with the selection column:
    form delete_record.
      loop at it_zsd00003.
        if it_zsd00003-linesel = 'X'.
           exit.
        endif.
      endloop.
       delete from zsd00003
           where  zdriftscenter     = it_zsd00003-zdriftscenter
    endform.                                               
    Sorting a table control
    While were on the subject. You may need a sort routine in
    case the user selects a column and desires to sort on
    its contents.  All you need is a sort icon on the
    applications toolbar of the screens GUI  to return the OK-
    code
    of 'SORT'.  You will need to copy this to the PAI of every
    screen and change the name of the module, and the actual
    itab for this screen 
    MODULE SORT_screen100 INPUT.
       CASE SAVE_OK_CODE.
          WHEN 'SORT'.
             LOOP AT T1-COLS INTO WA.
                IF WA-SELECTED = 'X' .
                   SPLIT WA-SCREEN-NAME AT '-' INTO FILE FLD.
                   SORT itab BY (FLD).
                ENDIF.
             ENDLOOP.
       ENDCASE.
    ENDMODULE.                 " SORT_screen100  INPUT
    Tom Quinn
    ESRI, Redlands, CA.  
    Scrolling the table control
    Now let's look at scrolling.
    (assume that the name of your table control is T1)
    In the screen logic you will have:
                    Loop with control T1.
                       module get_Looplines.
                    Endloop.
                        Module get_looplines.
                          Looplines = sy-loopc.
                        Endmodule.
    In the PBO of the screen you will have a module that loads
    the itab and determines the total number of lines read.
                      Module load_itab.
                            .      (select database table and
    append to itab)
                       describe table itab lines linecount.
                     Endmodule.
    We now have all the values necessary to construct a scroll
    module.
    MODULE SCROLL INPUT.
    CASE SAVE_OK_CODE.
    WHEN 'P--'.
       T1-TOP_LINE = 1.
    WHEN 'P-'.
       T1-TOP_LINE = T1-TOP_LINE - LOOPLINES.
         IF T1-TOP_LINE < 1.
            T1-TOP_LINE = 1.
         ENDIF.
    WHEN 'P+'.
       T1-TOP_LINE = T1-TOP_LINE + LOOPLINES.
         IF T1-TOP_LINE > LINECOUNT.
            T1-TOP_LINE = LINECOUNT - LOOPLINES + 1.
         ENDIF.
    WHEN 'P++'.
       T1-TOP_LINE = LINECOUNT - LOOPLINES + 1.
    ENDCASE.
    ENDMODULE.                 " SCROLL  INPUT
    Or else you can use the below code
        WHEN 'P--'.
          CLEAR SY-UCOMM.
          CTR1-TOP_LINE = 1.
        WHEN 'P-'.
          CLEAR SY-UCOMM.
          CTR1-TOP_LINE = CTR1-TOP_LINE - LINECOUNT1.
          IF CTR1-TOP_LINE < 1.
            CTR1-TOP_LINE = 1.
          ENDIF.
        WHEN 'P+'.
          DESCRIBE TABLE ITAB1 LINES N1.
          CTR1-TOP_LINE = CTR1-TOP_LINE + LINECOUNT1.
          IF CTR1-TOP_LINE > N1.
            CTR1-TOP_LINE = N1.
          ENDIF.
          CLEAR SY-UCOMM.
        WHEN 'P++'.
          DESCRIBE TABLE ITAB1 LINES N1.
          CLEAR SY-UCOMM.
          CTR1-TOP_LINE = N1.
    Other hints for using the table contro
    1. Setting the number of lines.
    2. Scrolling to a spcefic line.
    1. Setting the number of lines.
    tc1-lines = 500.
    > The problem is not in module scroll_code but rather the
    lack of module =
    > LINE_COUNT in your PBO. I have found this very reliable
    and absolutely =
    > necessary in getting the scrolling in table function to
    work. This module
    > =
    > has the following code in it:
    >
    > module line_count output.
    >     describe table itab lines tc1-lines.
    > endmodule.
    2. Scrolling to a spcefic line.
    tc1-top_line =  500.

  • What is needed for sorting on two fields in a table control

    Hi Everybody
    I am going to certification in a couple of days. I need some help and was hopeing that you  guys could help.
    What is needed for sorting on two fields in a table control?
         One sorted table and two processing blocks
         Two standard tables and one processing blocks
         Two standard tables and two processing
    Which one is corret??
    //Script

    Hi Kimallan
    I am not sure what is meant by a "processing block". However, it seems the question wants the original table order to be preserved. If so; as far as I understood the problem we need:
    itab_proxy[] = itab_main[] .
    "two standard tables"
    SORT itab_proxy BY field1 field2 .
    If we have a sorted table, then it is always sorted by its keys. So, the question seems to become obsolete for that option.
    Hope I've understood correct...
    Regards
    *--Serdar
    [email protected]

  • Sort up and sort Down push buttons in module pool with table control wizard

    hi,
    i have created 2 buttons for Sort up and sort Down push buttons in module pool with table control wizard
    please any one can help me.
    regards

    Hi
    Following code is to enable and disable the tbl control using two buttons. Just alter the code and for each button write the sort code.
    REPORT  YJAN27_SCREEN                                               .
    TABLES: SFLIGHT, YFLIGHT_28.
    TYPES: BEGIN OF struct1,
          carrid like sflight-carrid,
          connid like sflight-connid,
          fldate like sflight-fldate,
           END OF struct1.
    CONTROLS TBL1 TYPE TABLEVIEW USING SCREEN 2700.
    DATA: OK_CODE LIKE SY-UCOMM,
          CARRID LIKE SFLIGHT-CARRID,                                    "cols in tbl ctrl
          CONNID LIKE SFLIGHT-CONNID,
          FLDATE LIKE SFLIGHT-FLDATE,
          itab TYPE TABLE OF STRUCT1 WITH HEADER LINE,
          cols like line of TBL1-COLS,
          FLAG TYPE I.
    FLAG = 1.
    CALL SCREEN 2700.
    *&      Module  STATUS_2700  OUTPUT
    *       text
    MODULE STATUS_2700 OUTPUT.
      SET PF-STATUS 'BACK'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_2700  OUTPUT
    *&      Module  USER_COMMAND_2700  INPUT
    *       text
    MODULE USER_COMMAND_2700 INPUT.
    OK_CODE = SY-UCOMM.
    CASE OK_CODE.
      WHEN 'BACK'.
        LEAVE PROGRAM.
      WHEN 'DIS'.                                                         "write code for sort up
        loop AT TBL1-COLS INTO COLS.
           COLS-SCREEN-INPUT = 0.
            MODIFY TBL1-COLS FROM COLS.
        ENDLOOP.
        FLAG = 2.
      WHEN 'ENA'.                                                       "write code for sort down
        loop AT TBL1-COLS INTO COLS.
            COLS-SCREEN-INPUT = 1.
            MODIFY TBL1-COLS FROM COLS.
        ENDLOOP.
        FLAG = 1.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_2700  INPUT
    *&      Module  GET_DATA  OUTPUT
    *       text
    MODULE GET_DATA OUTPUT.
      select carrid connid fldate from SFLIGHT into table itab.
    ENDMODULE.                 " GET_DATA  OUTPUT
    *&      Module  POPULATE_TBL  OUTPUT
    *       text
    MODULE POPULATE_TBL OUTPUT.
        MOVE-CORRESPONDING ITAB TO SFLIGHT.
    ENDMODULE.                 " POPULATE_TBL  OUTPUT
    *&      Module  CHANGE_SCREEN  OUTPUT
    *       text
    MODULE CHANGE_SCREEN OUTPUT.    " use this module if you want to hide the other button
    CASE FLAG.
      WHEN 1.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_ENA'.
            SCREEN-INVISIBLE = 1.
             MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_DIS'.
            SCREEN-INVISIBLE = 0.
             MODIFY SCREEN.
          ENDIF.
       ENDLOOP.
      WHEN 2.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_DIS'.
            SCREEN-INVISIBLE = 1.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_ENA'.
            SCREEN-INVISIBLE = 0.
             MODIFY SCREEN.
          ENDIF.
       ENDLOOP.
    ENDCASE.
    ENDMODULE.                 " CHANGE_SCREEN  OUTPUT
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_2700.
    MODULE CHANGE_SCREEN.     " use this if you want to display one button at a time
    MODULE GET_DATA.
    loop at itab WITH control TBL1.
        MODULE POPULATE_TBL.       " populate tbl ctrl
    endloop.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_2700.    " do the sort operations
    loop at itab.
      endloop.
    Hope this helps
    Regards,
    Jayanthi.K

  • Sort table control contents

    hi all,
    i need to sort the contents of a table control dynamically,how can i do this..
    for ex: if user clicks on 'unpack' for a Handling Unit(HU) on table control 1(TC1) , i display the contents of it in TC2.
    and when he clicks on some other HU in TC1 and again clicks 'unpack' i need to sort the previous and present contents so that i can see them in a sorted order in TC2.
    i tried sorting the table on which iam looping but thats leaving balnks in TC2 until my logic finds the contents of the HU to be displayed.(for ex. if HU has posnr 90 and 100, the TC2 has the first 8 rows blank, if i use sort)..
    please suggest
    thanks

    Please make sure that you REFRESH your control before displaying the screen again.
    REFRESH CONTROL 'TC2_CONTROL' from screen '100'.
    Regards,
    Rich Heilman

  • Regarding page down in the table control veritcally

    Hi all,
              I have an issue regarding page down in the Table control in module pool , i.e when i m click the vertical scroll bar and going for page down then , the control is flowing to the next sceen which is not needed , and it shuld just scroll down and up vetically.
    Can anyone help me how to handle the page down event ?
    Thanks & regards,
    satya

    Table Controls: Examples with Scrolling
    The following example processes a table control with LOOP without parallel loop using an internal table. In addition to the scroll bar, the user can also carry out program-controlled scrolling with function codes.
    REPORT demo_dynpro_tabcont_loop.
    CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
    DATA: ok_code TYPE sy-ucomm,
          save_ok TYPE sy-ucomm.
    DATA: itab TYPE TABLE OF demo_conn,
          fill TYPE i.
          TABLES demo_conn.
    DATA: lines TYPE i,
          limit TYPE i.
    SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.
    CALL SCREEN 100.
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
      DESCRIBE TABLE itab LINES fill.
      flights-lines = fill.
    ENDMODULE.
    MODULE fill_table_control OUTPUT.
      READ TABLE itab INTO demo_conn INDEX flights-current_line.
    ENDMODULE.
    MODULE cancel INPUT.
      LEAVE PROGRAM.
    ENDMODULE.
    MODULE read_table_control INPUT.
      lines = sy-loopc.
      MODIFY itab FROM demo_conn INDEX flights-current_line.
    ENDMODULE.
    MODULE user_command_0100 INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      CASE save_ok.
        WHEN 'NEXT_LINE'.
          flights-top_line = flights-top_line + 1.
          limit = fill - lines + 1.
          IF flights-top_line > limit.
            flights-top_line = limit.
          ENDIF.
        WHEN 'PREV_LINE'.
          flights-top_line = flights-top_line - 1.
          IF flights-top_line < 0.
            flights-top_line = 0.
          ENDIF.
        WHEN 'NEXT_PAGE'.
          flights-top_line = flights-top_line + lines.
          limit = fill - lines + 1.
          IF flights-top_line > limit.
            flights-top_line = limit.
          ENDIF.
        WHEN 'PREV_PAGE'.
          flights-top_line = flights-top_line - lines.
          IF flights-top_line < 0.
            flights-top_line = 0.
          ENDIF.
        WHEN 'LAST_PAGE'.
          flights-top_line =  fill - lines + 1.
        WHEN 'FIRST_PAGE'.
          flights-top_line = 0.
      ENDCASE.
    ENDMODULE.
    The layout of screen 100 is:
    A resizable table control called FLIGHTS is defined. The fields of the table control are transferred from the structure DEMO_CONN in the ABAP Dictionary. The first two columns are lead columns. The corresponding fields are output fields. A title bar, column headers, and a selection column are created. The component MARK of type character with length 1 from structure DEMO_CONN is assigned to the selection column. You can select one column and several lines.
    It has the following flow logic:
    PROCESS BEFORE OUTPUT.
      MODULE status_0100.
      LOOP WITH CONTROL flights.
        MODULE fill_table_control.
    ENDLOOP.
    PROCESS AFTER INPUT.
      MODULE cancel AT EXIT-COMMAND.
      LOOP WITH CONTROL flights.
        MODULE read_table_control.
    ENDLOOP.
      MODULE user_command_0100.
    The system executes a loop at PBO and PAI using the table control FLIGHTS. During the PBO loop, a module is called to fill the table control from table ITAB of the ABAP program. During the PAI loop, a module is called to modify table ITAB.
    Before the PBO loop, in the module STATUS_0100 the current number of lines of the internal table ITAB is placed in component LINES of control structure FLIGHTS. This helps the system to correctly install the scroll bar of the table control.
    During the PBO loop, in the module FILL_TABLE_CONTROL the work area DEMO_CONN is filled with values from the internal table, where the row index corresponds to the current row of the table control.
    During the PAI loop, in the module READ_TABLE_CONTROL the current number of the loop SY-LOOPC in the table control is placed an auxiliary variable. The number is dependent on the size of the screen. The rows of the internal table, whose row index corresponds to the current row of the table control, are overwritten with the contents of the work area DEMO_CONN. User input is transferred from the input fields of the control to the internal table. In particular, the internal table also contains a flag in the column MARK to indicate whether the row of the table control is selected or not.
    After the PAI loop, user input is processed in the module USER_COMMAND. The GUI status SCREEN_100 provides the appropriate function codes. You can scroll line by line or page by page, or Goto the first or last page. You can implement scrolling by setting the component TOP_LINE of control structure FLIGHTS. For page-by-page scrolling the auxiliary variable that is filled in the PAI loop by SY-LOOPC is used as the step size.

  • Regarding the table control in bdc

    Hi Abap Gurus,
    my requirement is how to extend the table control in bdc? i have searched in the sdn but not found the proper code.
    i think we have to use the =P+ code .  if possible post the sample code.

    Use the search tool, or go to [How to scroll a table control?|http://wiki.sdn.sap.com/wiki/display/ABAP/BatchInputFAQ#BatchInputFAQ-Howtoscrollatablecontrol%3F] in [Batch Input FAQ |http://wiki.sdn.sap.com/wiki/display/ABAP/BatchInputFAQ] (not every transaction uses the same code)
    Regards,
    Raymond

  • 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

  • Regarding Searh option in table control

    Hello,
    I have one table control in which i have taken only one field of 132 length so that user enter the line wise comments in that table control.
    Now i want a search button for that table control so that user can enter any string to search in the table control.
    How to do that as i haven't seen any thing like this even in standard transaction also.
    Please give me some ideas fro doing that.
    with regards,
    nitin

    Hello,
    Thanx for your reply,
    I code like this.
    I_TXTTAB is my table control internal table.
    MODULE SEARCH. is my module for search
    Codes as follow
      CASE OK_CODE.
        WHEN 'FIND'.
          PERFORM SEARCH.
    TAB_SEARCH-TABNAME = 'TLINE'.
      TAB_SEARCH-VALUE = ROLE_TEXT.
      TAB_SEARCH-FIELDNAME = 'TDLINE'.
      APPEND TAB_SEARCH.
      CALL FUNCTION 'POPUP_GET_VALUES'
        EXPORTING
          POPUP_TITLE     = 'Find Text : Comment'(010)
        IMPORTING
          RETURNCODE      = RETURNCODE
        TABLES
          FIELDS          = TAB_SEARCH
        EXCEPTIONS
          ERROR_IN_FIELDS = 1
          OTHERS          = 2.
      IF RETURNCODE = 'A'. EXIT. ENDIF.
      READ TABLE TAB_SEARCH WITH KEY FIELDNAME = 'TDLINE'.
      ROLE_TEXT = TAB_SEARCH-VALUE.
      CLEAR L_TEXT_INPUT.
      L_TEXT_INPUT = TAB_SEARCH-VALUE.
      IF ROLE_TEXT IS INITIAL .
        EXIT.
      ENDIF.
      IF FILE IS NOT INITIAL AND
         I_TXTTAB IS NOT INITIAL.
        DESCRIBE TABLE I_TXTTAB LINES TXT_LINES.
        L_IND = COMMENT-CURRENT_LINE.
        READ TABLE I_TXTTAB INTO W_TXTTAB INDEX L_IND.
        FIND ALL OCCURRENCES OF L_TEXT_INPUT  IN W_TXTTAB IGNORING CASE RESULTS RESULTS.
        IF SY-SUBRC = 0.
          SET CURSOR FIELD 'W_TXTTAB' LINE L_IND.
          FLAG = 'X'.
        ENDIF.
    This code finds the text string but it is not taking my cursor to that particular line item.
    i write this code like this also, but still not getting to the line item
    PROCESS AFTER INPUT.
      LOOP AT I_TXTTAB.
        CHAIN.
          FIELD W_TXTTAB-TDLINE.
          MODULE G_TEXT_MODIFY ON CHAIN-REQUEST.
        ENDCHAIN.
        MODULE SEARCH.
      ENDLOOP.
    With Regards,
    Nitin Malhotra

  • Faces Read-Only Table control - reset column sorting?

    In an ADF Faces Read-Only Table control at runtime, once the user has clicked on a column to resort the table entries based on the clicked column, is there any way to unclear the sort?
    CM.

    In an ADF Faces Read-Only Table control at runtime, once the user has clicked on a column to resort the table entries based on the clicked column, is there any way to unclear the sort?
    CM.

  • REGARDING  "w/selcolumn" IN table control

    hi experts,
                i m not able to use "w/selcolumn" in table control.
    cud u plz how will i use this to delete the data from database table as per the data showing in the table control.
    plz help me

    Hi,
    <u>Step 1</u>
    In your PAI capture all the seleted rows into an internal table. The following code snippet does that.
    recsel -> value you have given for w/selcolumn
    gt_student_select -> Internal table having the selected rows for deletion
    gt_student
    module select_record input.
    if recsel = 'X'.
    read table gt_student_select with key student_id = gt_student-student_id
    if sy-subrc eq 4.
    gt_student_select-mandt = gt_student-mandt.
    gt_student_select-student_id = gt_student-student_id.
    gt_student_select-student_name = gt_student-student_name.
    gt_student_select-student_address = gt_student-student_address.
    gt_student_select-student_average = gt_student-student_average.
    append gt_student_select.
    endif.
    else.
    delete table gt_student_select from gt_student.
    endif.
    endmodule.
    <u>Step 2</u>
    Perform deletion using the internal table gt_student_select.
    when 'DELETE'.
    clear ok_code.
    "deletes matching record from database table
         DELETE ztrch_stud_kri1 FROM table gt_student_select.
        "deletes the record from the itab
        loop at gt_student_select.
        delete table gt_student from gt_student_select.
        endloop.
        "sets the number of lines displayed in the table control to the
        "number of line in the internal table.
        DESCRIBE TABLE gt_student LINES tabctrl-lines.
        clear gt_student_select[].
    ***********************Reward points if found useful***************
    Regards,
    Kriththika.

  • Regarding duplicate entries in table control

    hi,
       i have created one table control in module pool. while entering values into the table control how can we validate the table control if we enter duplicate values.ie in the first line i entered 200 500 400
    again inthe second line i
    entered 200 500 400.
    validation should tabke place and error msg should be populated. pls help...
    i have used the below code.
    LOOP AT IT_TC2.
        CHAIN.
          FIELD:ZTC_ATMP-BUKRS,
                ZTC_ATMP-LEGACCNO,
                ZTC_ATMP-ZZDESKCODE,
                ZTC_ATMP-SAKNR.
          MODULE READ_TABLE_CONTROL.
         MODULE check_duplicates ON CHAIN-REQUEST.
        ENDCHAIN.
    ENDLOOP.
    but here module check_duplicates is not triggering why? any idea..

    Hi,
    you can try like this...
    LOOP AT IT_TC2.
    CHAIN.
    FIELD ZTC_ATMP-BUKRS module CHK1.
    FIELD ZTC_ATMP-LEGACCNO module CHK1.
    FIELD ZTC_ATMP-ZZDESKCODE module CHK1.
    FIELD ZTC_ATMP-SAKNR module CHK1.
    MODULE READ_TABLE_CONTROL.
    ENDCHAIN.
    ENDLOOP.
    Now write the validations for the corresopnding Fields in there Respective Modules.... for example Validation for  ZTC_ATMP-BUKRS  filed in module CHK1 and so on..
    Reward if helpful.
    Regards,
    Syed

Maybe you are looking for