Table control: Line selection single issue

Hi experts,
I have created a table control and in the screen painter I have defined the line selection as "Single" for table control.
The table control can display upto 20 lines in a screen and i can select a single record only which pertains to my requirement. if I try to select two records it will not allow.
Issue: consider  i select a single record from the first 20 lines displayed in screen, then i scroll the records in the table control so that it displays the records from 21 to 40. if I select a single record now from line 21 to 40, the first record that i selected is not getting deselected. That is, totally two lines are getting selected.
How to overcome this issue
Thanks in advance
Regards
Anand

Ok
The "problem" is here:
Types: Begin of ty_ic,
  ic(20),
  desc(20),
  sel(1)                                 <--------------------------------
End of ty_ic.
You've ha a field for selected line and that field is used in table control definition as you've written:
"Note: wa_ic is the structure used in table control and wa_ic-sel is the mark field defined the table control attributes"
So you're using the structure WA_IC as header line of internal table IT_IC and also as input/put field of your table control (I mean the screen fields of table control are based on WA_IC).
You don't need any code in PBO to move the data from internal table to table control, because the headerline of IT_IC and field of table control are the same, infact you've implemented only the code in PAI to save the data from table control to IT_IC:
Loop at it_ic.
Modify it_ic from wa_ic index tc_ic-current_line
Endloop
t's a good solution if it needs to transfer all data to table control automatically: it doesn't need any code in PBO
but, of course, there'll be a problem when you don't need to display something, in this case you have to think a solution, I mean you have to write a code in order to avoid to display those data.
It's the case of the selected line: in your situation all selected lines keep the selection, because the code to clear IT_IC-SEL is missing: only the user can deselect a line, but if he doesn't do it, the line will remain selected after navigation.
So you make to be sure to clear all selected lines are not displayed.
You need to create a code in PAI out of the loop of table control where you clear the flag SEL, in order to do it you need to consider:
- The index of the first record displayed in table control is stored in field TC_IC-TOP_LINE
- The index of the last record displayed in table control can be calculated: the variable SY-LOOPC indicates how many rows can be displayed in table control, so the last record will be: TC_IC-TOP_LINE + SY-LOOPC.
So you need to clear the field SEL for all records not displayed, a code like this:
PROCESS PAI.
  LOOP AT IT_IC.
     MODULE GET_LOOPC.
  ENDLOOP.
  MODULE CLEAR_SEL.
  MODULE GET_LOOPC..
      TOT_LINE_DISPLAYED = SY-LOOPC.
  ENDMODULE
  MODULE CLEAR_SEL.
* Here you need to clear the selection of the records before of TOP_LINE
       IF TC_IC-TOP_LINE > 1.
          LOOP AT IT_IC INTO WA_IC  TO TC_IC-TOP_LINE.
             CLEAR WA_IC-SEL.
             MODIFY IT_IC FROM WA_IC.
          ENDLOOP.
     ENDIF.
* Here you need to clear the selection of the records after the last one:
      LAST_INDEX = TOT_LINE_DISPLAYED + TC_IC-TOP_LINE.
     DESCRIBE TABLE IT_IC LINES SY-TABIX,
     IF SY-TABIX > LAST_INDEX.
          LOOP AT IT_IC INTO WA_IC  FROM LAST_INDEX.
             CLEAR WA_IC-SEL.
             MODIFY IT_IC FROM WA_IC.
          ENDLOOP.
     ENDIF.
  ENDMODULE.

Similar Messages

  • Table control line selection issue

    HI im facing a problem in table control.
    I have a table control with selection column ( single ).
    First time when i select a row its is marked X in the internal table,
    Now again when i select another row .. The old row still holds the value X and the new row is gettign marked as X.
    The problem here is the old selection is not getting cleared in the internal table.
    This is the statement used in PAI
    MODIFY gt_header INDEX tbl_header-current_line FROM wa_header .
    Here the previous value is not getting cleared.

    KSD,
    During PAI Loop, the screen flow logic loops only through the visible table control lines. In your case, the user has scrolled down and seeing line 30 to 40 (say for example) after selecting a line in first page view. This is very common with any table control.
    Now user is viewing 1 to 10 lines of the TC and have selected 3rd line. User then scrolls down by pressing page-down - now PAI is triggered and the internal table's 3rd line is modified with MARK='X'. User then views lines 30 to 40 and selects 33rd line. Now table control will automatically clear the MARK in 3rd line in the Table Control only. But it is the responsibility of the developer written code to clear the same in the Internal Table.
    So within PAI Table Loop, you have to check the MARK which is coming from Screen to ABAP program every-time and if it is 'X', you have to clear any other line's MARK. Remeber you should not do this for multi-select. There is an attribute of the table control LINE_SEL_MODE. The above logic of clearing other lines' MARK should be implemented only after checking this attribute.
    So incidentally your solution was the appropriate one.
    Cheers,
    Suresh

  • How do I execute some code when a line of a table control is selected?

    Hi,
    I would like to execute some code when a line of a table control is selected.  At the moment I have to select one or multiple rows and then press enter, this forces a screen refresh and my code is executed but I would like the code to be executed as soon as any line is selected.
    I've done something like this using ALV grids and object orientated code but is there a way of doing this in a normal non-OO table control?
    Thanks in advance.
    Gill

    Hi,
    U need to declare a char1 field for marking (mark field).  This will reflect with value 'X' in your tcontrol internal table for all the selected rows. 
    Now u need to handle the okcode for enter in your PAI.
    There u need to loop through the table for all marked fields.
    There after u can do what ever u want.
    Venkat.

  • Table control lines cannot be controlled in Batch Input session ?

    I am using a program which creates Batch Input sessions for the transaction FCHR (Online cashed checks) . The second screen is that of a table control where the check number is entered.
         I observed that while doing SHDB, if we tick the default size then changing the desktop resolution has no effect on the number of lines in table control - we see 14 lines in both cases.However, when the batch input session is processed, the number of table control lines varies according to the resoution(9 lines for 800600 and approx 15 for 1024768). Selecting the 'Dynpro standard size' option while processing the session has no effect.
      I know call transaction with 'default' parameter in optparam will take care of this problem. But I want to know whether Batch Input Session is known to have a problem with different resolutions.

    HI..
    i had the same problem once.... i dealt in the following way
    while entering values in table control
    1) enter value in the first line
    2) look for button on application toolbar using which you can increment line
    3) you will not find difference for first line but you will find it when you insert second line and go for next line.
    4) now for every increment you will get table conrol as (02) if you are going for recording.
    this will surely solve all issue related to table control as it solved for me
    regards
    Edited by: Mohit Kumar on Feb 19, 2009 12:04 PM

  • TX BDLS - Syntax error in program SBDLS21020100127145818 line SELECT SINGLE

    Hi All,
    I am in the process of configuring a QAS system taken from a copy of th production system, I am going into TX BDLS and getting the following error message Syntax error in program SBDLS21020100127145818 line SELECT SINGLE AWSYS FROM DFKKKO has anyone got any ideas about this issue?
    Thanks
    Jay

    Force manual activation in se11 this tables: (SE11 -> display -> menu 'table' -> actívate)
    DFKKKO
    DFKKCOLFILE_P_W
    DFKKMKO
    DFKKREP06
    DFKKREP06_S
    DFKKREP07
    DFKKREV06
    DFKKREV07
    Try again the BDLS.
    Regards.

  • Need Table Control in Selection Screen

    I have a selection screen with some fields. Now, below these fields, I need a table control in which i will have input parameter along with some check boxes so that i can enter data and use the same while executing the report.
    paste the code for the requirement how to add a table control on the selection screen.

    hi ramesh,
    i have a very same requirement as u did. pleae send me the code which u used.
    Till now, i have been able to display table control on selection screen. but, how to write or display the output or how to call the output screen. i have to display alv output.
    Please help on above issue.
    Thanks,
    Rajesh

  • TABLE CONTRL-LINES SELECTED

    Hi All.
    I have one table control and I want to find out how many line (rows) are selected .
    Can any one help me how to calculate total rows of table control are selected.
    Thanks in advance
    Dhanu

    HI,
    If you want to find the no. of rows selected,you have to use a field of length 1 in database[say pick],and update the internal table everytime a field is selected in PAI.Kindly reward points by clicking the star on the left of reply,if it helps.
    PROCESS AFTER INPUT.
      LOOP AT i_makt.
        FIELD i_makt-pick MODULE check.
      ENDLOOP.
    Here is the complete sample code on table control.
    In the flow logic of the screen 9000, write the following code.
    PROCESS BEFORE OUTPUT.
      MODULE set_status.
      MODULE get_t_ctrl_lines.
      LOOP AT i_makt WITH CONTROL t_ctrl CURSOR t_ctrl-current_line.
    Dynamic screen modifications
        MODULE set_screen_fields.
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP AT i_makt.
        FIELD i_makt-pick MODULE check.
        FIELD i_makt-zmatnr MODULE zmatnr .
      ENDLOOP.
      MODULE user_command_9000.
    In the program, write the following code.
    PROGRAM SAPMZTC MESSAGE-ID zz.
    Tables Declaration
    TABLES: zzz_makt.
    Internal table Declaration
    DATA : i_makt TYPE STANDARD TABLE OF zzz_makt WITH HEADER LINE.
    Table control Declaration
    CONTROLS: t_ctrl TYPE TABLEVIEW USING SCREEN '9000'.
    Variable Declaration
    DATA : flg,           "Flag to set the change mode
           ln TYPE i.     "No. of records
    *&      Module  get_T_CTRL_lines  OUTPUT
    Populating data
    MODULE get_t_ctrl_lines OUTPUT.
      SELECT zmatnr zmaktx
             INTO CORRESPONDING FIELDS OF TABLE i_makt
             FROM zzz_makt.
      DESCRIBE TABLE i_makt LINES ln.
    To make the vertical scroll bar to come on runtime
      t_ctrl-lines = ln + 100.
    ENDMODULE.                 " get_T_CTRL_lines  OUTPUT
    *&      Module  USER_COMMAND_9000  INPUT
    Triggering event according to the user command
    MODULE user_command_9000 INPUT.
      DATA :lv_fcode LIKE sy-ucomm,    "Function Code
            lv_answer(1) type c.       "Storing the answer
      lv_fcode = sy-ucomm.
      CASE lv_fcode.
        WHEN 'CHANGE'.
    Setting the flag to make the table control in editable mode[excluding
    primary key].
          flg = 'Y'.
        WHEN 'DELETE'.
    Setting the flag to make the table control in editable mode after
    deleting the selected line
          flg = 'Y'.
    Confirmation of delete
          CALL FUNCTION 'POPUP_TO_CONFIRM'
            EXPORTING
             TITLEBAR       = 'Confirm'
             text_question  = 'Are you sure to delete from database?'
             TEXT_BUTTON_1  = 'Yes'(001)
             TEXT_BUTTON_2  = 'No'(002)
            IMPORTING
             ANSWER         =  lv_answer.
          if lv_answer eq '1'.
    Updating the database table from the internal table
            UPDATE zzz_makt FROM TABLE i_makt.
    Deleting the selected row from the internal table
            DELETE i_makt WHERE pick = 'X'.
    Deleting the selected row from the database table
            DELETE FROM zzz_makt WHERE pick = 'X'.
            MESSAGE s005 WITH 'Deleted Successfully'.
          ENDIF.
        WHEN 'SAVE'.
    Inserting new record or updating existing record in database table
    from the internal table
          MODIFY zzz_makt FROM TABLE i_makt.
          MESSAGE s005 WITH 'Saved Successfully'.
        WHEN 'BACK'.
          SET SCREEN '0'.
        WHEN 'EXIT' OR 'CANCEL'.
    Leaving the program
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9000  INPUT
    *&      Module  set_screen_fields  OUTPUT
    Setting the screen fields
    MODULE set_screen_fields OUTPUT.
      LOOP AT SCREEN.
        IF flg IS INITIAL.
          screen-input = 0.
        ELSEIF ( flg EQ 'Y' ).
          IF ( ( screen-name = 'I_MAKT-ZMAKTX'
                 OR screen-name = 'I_MAKT-CHECK1' )
                AND t_ctrl-current_line LE ln ) .
    Making the screen fields as editable
            screen-input = 1.
          ELSEIF ( ( screen-name = 'I_MAKT-ZMATNR' )
                     AND t_ctrl-current_line LE ln ).
    Making the screen field as uneditable
            screen-input = 0.
          ENDIF.
        ENDIF.
    Modifying the screen after making changes
        MODIFY SCREEN.
      ENDLOOP.
    ENDMODULE.                 " set_screen_fields  OUTPUT
    *&      Module  zmatnr  INPUT
    Appending records to the internal table
    MODULE zmatnr INPUT.
      MODIFY i_makt INDEX t_ctrl-current_line.
      IF t_ctrl-current_line GT ln.
        READ TABLE i_makt WITH KEY zmatnr = i_makt-zmatnr.
        IF sy-subrc NE 0.
    Inserting record if it does not exist in database
          APPEND i_makt.
        ELSE.
         MESSAGE i005 WITH 'Material Number' i_makt-zmatnr 'already exists'.
        ENDIF.
      ENDIF.
    ENDMODULE.                 " zmatnr  INPUT
    *&      Module  set_status  OUTPUT
    Setting the GUI status
    MODULE set_status OUTPUT.
      SET PF-STATUS 'ZSTATUS'.
      SET TITLEBAR  'ZTITLE'.
    ENDMODULE.                 " set_status  OUTPUT
    *&      Module  CHECK  INPUT
    Modify the internal table using the current line in table control
    MODULE check INPUT.
      MODIFY i_makt INDEX t_ctrl-current_line.
    ENDMODULE.                 " CHECK  INPUT

  • Problem with Table control lines

    Hi Friends,
    This is the problem with table control lines:
    I have screen with table control and I would like change the table control lines dynamicaly.
    Exp:
    In my PBO the Internal table which I am using to loop the TC is havig 7 records and its displayed with 7 records, now I have added one more record into my ITAB and now ITAB is having 8 records, when I am looping this ITAB with TC its taking the TC lines 7 only.
    here is the code:
    Initial values in gt_scr400 = 8
    Initial values in tc_scr400 = 8
    Now added one more recor into gt_scr400 , now gt_scr400  = 9.
      LOOP AT   gt_scr400
           INTO wa_scr400
           WITH CONTROL tc_scr400
           CURSOR tc_scr400-current_line.
      ENDLOOP.
    I have used this logic :
      DESCRIBE TABLE gt_scr400 LINES g_rec_300 .
      tc_scr300-lines = g_rec_300.
    but its not modifying the lines in my table control.
    How to change the TC lines based on ITAB total records.
    Thanks,
    Sridhar

    there is a field in TableViewName-xxx
    don't remember the exact field name for (total no of records)
    you can check it in debug.  when you add records in Internal table, u need to modify this field which is set at the first time when table control is populated.

  • How to determine actual table control line

    Hi experts,
    How can I determine the table control line in case of scrollable table control.
    I tried this one, but did not worked correctly:
        GET CURSOR LINE l_line_fc2.
        l_line = l_line_fc2 + ctrl_mod-top_line - 1.
    Everytime I try to catch the top_line of the table control its value is always 1. Is it possible?

    Hi,
    Current table control line will be found in SY-STEPL.
    Regards
    Mohammad Shaik.

  • How can i change the color of table control'  lines?

    Such as the subject. Thanks in advance!

    Hi,
    Please check,
    TABLE CONTROL LINES COLOR CHANGE
    color rows in table control
    Regards,
    Hema.
    Reward points if it is useful.

  • TABLE CONTROL LINES COLOR CHANGE

    <i>Hi Friens.,
    I need small help ie.,
    Let us assume we have table control like this.,
    col1 |  col2  |  group |
    a1   |   b1   |  1
    a2   |   b2   |  1
    a3   |   b3   |  2
    a4   |   b4   |  2
    a5   |   b5   |  3
    a6   |   b6   |  3
    1) User need differentiation between groups to look and feel.,thats why I want to change the Line colors based on Group.,
    2) I am getting this one .,but I made case on Sy-stepl.,  while scrolling it is not showing correct .,
    3) Is there any good way to do this., like in ME21   CONDITIONS TAB at Item level</i>
    If any body have Idea., share with me.,
    <b>Thanks.,</b>
    <i><b>Surendher Reddy.Baddam</b></i>

    Re: TABLE CONTROL LINES COLOR CHANGE
    Posted: Nov 5, 2004 6:47 AM        Reply      E-mail this post 
    PBO >>>like thise.,
    LOOP AT itab WITH CONTROL tc4_400 CURSOR tc4_400-current_line.
    MODULE check_rej_hld_400.
    MODULE radio_checkbox_400.
    ENDLOOP.
    >>>
    MODULE radio_checkbox_400.
    DATA : l_stf TYPE i.
    DATA : l_hyd TYPE i,l_knr TYPE i.
    l_hyd = 1.
    LOOP AT SCREEN.
    IF screen-name = 'ITAB-BATCHNO'.
    IF itab-group = l_hyd. " this is group
    screen-intensified = 1.
    MODIFY SCREEN.
    ELSEIF
    screen-intensified = 0.
    MODIFY SCREEN.
    ENDIF.
    ENDIF.
    ENDLOOP.
    ADD 2 TO l_hyd
    ENDMODULE.
    I made logic like this.,
    Thanks.,
    Surendher Reddy.Baddam

  • Table Controls: - Find selected line index

    HI,
    I have a table control . In tis 4 lines are visible at a time..1 field in this table comntrol is a button.
    when the user clicks on a button, the details of the corresponding line should be used to trigger a new screen. If the no of lines in the table control is less than 4( o of visible lines) , i can use get cursor line, to get the index of the line selected. . but if i scrolled down and selected the button in the 15 th line, then get cursor line cannot be used as it will retrieve the no 3. CAn u please give me a solution.
    thnx.

    declare two variables to get line count and line index
    data: wrk_linecnt(10),
            wrk_lineindx(10).
    get cursor line wrk_linecnt.
    wrk_lineindx = <table control name>-top_line + wrk_linecnt - 1.
    read table <internal table used in table control> index wrk_lineindx.

  • Long text in table control lines

    If i put long text  buttons on the  table control coulum, when the line  is deleted  from the table, the text for tha line  are permenantly deleted before the screen is saved in the user command. how do i correct the problem ?
    regards
    Rendani

    Use the FM for text delete when u press save button and not at table control delete command.
    physically delete the line from table control and put it in internal table which can be used for deletion purpose at time of actual deletion...

  • Checkbox Within Table Control At Selection Screen

    Hello, there.
    In my selection screen (dialog) I'm using a table control which is based on an internal table.
    In that internal table I have a simple Yes/No field (declared as type XNULL for example).
    The problem is that I want it to be displayed as checkbox on the selection screen's table control and not as a simple string with size = 1 like it is..
    I hope it's clear and understood ...
    Thanks in advance,
    Rebeka

    Rebeka,
    Its very simple,
    In that field of table control just drag & drop the  checkbox.
    In Screen modules ,
    loop at itab.
    If Field = 'YES'.
    Checkbox = 'X'.
    else .
    clear checkbox.
    endif.
    endloop.
    Regards,
    TAlwinder

  • Table control in Selection Screen

    Hi,
      Is it possible to keep table control and tabstrip control in selection screen without using dialog programming? I mean , using coding from program itself, have to get table in the selection screen,like how we are keeping checkbox and radio button from program itself . 
    by
    Mohan Ram
    Moderator Message: Search before posting.
    Edited by: kishan P on Sep 16, 2010 11:04 AM

    Hi, Mohan
    Please Always do a little Search Before Posting => [Search Results|http://forums.sdn.sap.com/search.jspa?threadID=&q=TablecontrolinSelectionScreen&objID=&dateRange=all&numResults=30&rankBy=10001]
    Hope you will get the answer from the First Few Threads From Search Result.
    Thanks and Regards,
    Faisal

Maybe you are looking for

  • Cover Browser stopped working

    After using iTunes almost without a hitch since the iTunes 7 upgrade came out, my cover browser stopped working and other odd behaviors have cropped up. For instance, when I try to shift from list view to browser view or grouped view, the iTunes wind

  • How to get the response of a vbscript ran from extended js?

    Hi All, I  want to get the result from a vbscript, how to get that in my jsx? This is what I'm doing- vbscript (this will return me something, i've added just a sample string) Wscript.Echo "Like this?" jsx var a = File("C:\\Users\\Sahil\\AppData\\Roa

  • How do I update Lightroom 4.4 to download canon g16 raw images?

    How do I update Lightroom 4.4 to download canon g16 raw images from my camera?

  • How to poll a table in abap

    Hi all, How would you poll a table in abap. There is a table thats been written by a webservice and when there is a record created in that table I need to be able to start a process. This webservice is a dotnet webservice that writes the weight ino t

  • Windows Server 2008 R2 Crystal Report XI Runtime hosted on IIS 7 32 bit

    Hi all, We have discovered that our software department installed Windows Server 2008 R2 in a production environment. The production environment hosts asp .net applications on IIS 7 that enables 32 bit applicatons to run over it. We still develope on