WD table get Line selection

Hello all,
how can'i get the selected line in a Table UI element ( not ALV UIelement), which  can methode in which class trigger this line selection? and olso the ction that cant trigger it.
Thank you all

Hi,
Up to now we are discussing about table ui element. your requirement is ALV Table.
Go to veiw->select methods->create one method say onselect, make it event handler(method type ) and in event click
f4 you get all options there you can select onleadselect select that write your code in your new method.
Cehckk this..
Get selected rows in ALV
WEB DYNPRO ALV GRID  GET SELECTED ROWS...
selected row in alv web dynpro
Cheers,
Kris.
Edited by: kissnas on May 30, 2011 1:10 PM

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

  • 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.

  • 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

  • HGrid and view link ancestors /get lines selected

    Hello,
    I want to get selected the lines out of a HGrid component which uses Viewlinks in IExpense. I extended the Controller of the HGrid <b> AllocationsHGridCO </b>. The except of the HGrid RN structure as follows:
    <oa:tree usage="hGrid" id="HeaderNodeRN" text="Line">
    <members>
    <oa:nodeDef id="HeaderLine" viewName="AllocationsHeaderVO" viewAttr="Line" shortDesc="Additional Text"/>
    <oa:childNode id="LineNodeRN" viewLink="" viewLinkAccessorName="LinesAccessor">
    <members>
    <oa:nodeDef id="LineLine" viewName="AllocationsLinesVO" viewAttr="Line"/>
    <oa:childNode id="DistributionNodeRN" viewLinkAccessorName="">
    <members>
    <oa:nodeDef id="DistributionLine" viewName="ExpenseAllocationsVO" viewAttr="Line"/>
    </members>
    </oa:childNode>
    </members>
    </oa:childNode>
    </members>
    </oa:tree>
    The code within the Controller:
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
                             super.processRequest(oapagecontext, oawebbean);
    OAApplicationModule oam = oapagecontext.getApplicationModule(oawebbean);
    OAViewObject oavAllocHeader = (OAViewObject)oam.findViewObject("AllocationsHeaderVO");
    OAViewObject oavAllocLines = (OAViewObject)oam.findViewObject("AllocationsLinesVO");
    if (oavAllocHeader != null && oavAllocLines != null)
    System.out.println( "AllocationsHeaderVO and AllocationsLinesVO are available!");
    int fetchedRowCountHeader = oavAllocHeader.getFetchedRowCount();
    RowSetIterator selectIterHeader = oavAllocHeader.createRowSetIterator("selectIter");
    System.out.println( "Ausgabe fetchedRowCountHeader:"+fetchedRowCountHeader);
    selectIterHeader.setRangeStart(0);
    selectIterHeader.setRangeSize(fetchedRowCountHeader);
    for (int i = 0; i < fetchedRowCountHeader; i++)
    AllocationsHeaderVORowImpl rowHeaderInd = (AllocationsHeaderVORowImpl)selectIterHeader.getRowAtRangeIndex(i);
    Number xxmiExpRepHeaderId = rowHeaderInd.getReportHeaderId();
    String xxmiLineNumber = rowHeaderInd.getLine();
    int fetchedRowCountLines = oavAllocLines.getFetchedRowCount();
    RowSetIterator selectIterLines = oavAllocLines.createRowSetIterator("selectIter");
    System.out.println( "Ausgabe fetchedRowCountLines:"+fetchedRowCountLines);
    output in Jdev-console:
    output fetchedRowCountHeader:1
    output fetchedRowCountLines:0
    Meanwhile no link is set because I stuck in doing this. How can I achieve the goal to receive all the line concerning to the Header
    Thanks a lot
    Robert

    Hello,
    I want to get selected the lines out of a HGrid component which uses Viewlinks in IExpense. I extended the Controller of the HGrid <b> AllocationsHGridCO </b>. The except of the HGrid RN structure as follows:
    <oa:tree usage="hGrid" id="HeaderNodeRN" text="Line">
    <members>
    <oa:nodeDef id="HeaderLine" viewName="AllocationsHeaderVO" viewAttr="Line" shortDesc="Additional Text"/>
    <oa:childNode id="LineNodeRN" viewLink="" viewLinkAccessorName="LinesAccessor">
    <members>
    <oa:nodeDef id="LineLine" viewName="AllocationsLinesVO" viewAttr="Line"/>
    <oa:childNode id="DistributionNodeRN" viewLinkAccessorName="">
    <members>
    <oa:nodeDef id="DistributionLine" viewName="ExpenseAllocationsVO" viewAttr="Line"/>
    </members>
    </oa:childNode>
    </members>
    </oa:childNode>
    </members>
    </oa:tree>
    The code within the Controller:
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
                             super.processRequest(oapagecontext, oawebbean);
    OAApplicationModule oam = oapagecontext.getApplicationModule(oawebbean);
    OAViewObject oavAllocHeader = (OAViewObject)oam.findViewObject("AllocationsHeaderVO");
    OAViewObject oavAllocLines = (OAViewObject)oam.findViewObject("AllocationsLinesVO");
    if (oavAllocHeader != null && oavAllocLines != null)
    System.out.println( "AllocationsHeaderVO and AllocationsLinesVO are available!");
    int fetchedRowCountHeader = oavAllocHeader.getFetchedRowCount();
    RowSetIterator selectIterHeader = oavAllocHeader.createRowSetIterator("selectIter");
    System.out.println( "Ausgabe fetchedRowCountHeader:"+fetchedRowCountHeader);
    selectIterHeader.setRangeStart(0);
    selectIterHeader.setRangeSize(fetchedRowCountHeader);
    for (int i = 0; i < fetchedRowCountHeader; i++)
    AllocationsHeaderVORowImpl rowHeaderInd = (AllocationsHeaderVORowImpl)selectIterHeader.getRowAtRangeIndex(i);
    Number xxmiExpRepHeaderId = rowHeaderInd.getReportHeaderId();
    String xxmiLineNumber = rowHeaderInd.getLine();
    int fetchedRowCountLines = oavAllocLines.getFetchedRowCount();
    RowSetIterator selectIterLines = oavAllocLines.createRowSetIterator("selectIter");
    System.out.println( "Ausgabe fetchedRowCountLines:"+fetchedRowCountLines);
    output in Jdev-console:
    output fetchedRowCountHeader:1
    output fetchedRowCountLines:0
    Meanwhile no link is set because I stuck in doing this. How can I achieve the goal to receive all the line concerning to the Header
    Thanks a lot
    Robert

  • How to implement line selectability for a table control using table Wizard?

    Hello SDN Community,
    I have created a table control using the Table Wizard.  I found my exact question in this forum, but unfortunately it had not been andsered.  While I cannot paste a screen-print into this plane-text area, here are the steps I followed...
    1) SE51
    2) Create new screen 0100
    3) Click Layout button
    4) Clidk Table Control (with Wizard) and draw box on canvas.
    5) Step is "Start" - click Continue
    6) Step is "Name of Table Control" - provided name
    7) Step is "Table Name" - provided name of dictionary table (AUFK)
    8) Step is "Definition of Columns" - selected order numver and order text
    9) Step is "Table Control Attributes" - Line Selectability is in display mode - cannot set it.
    I would like to have a selectability column for my table.  Would appreciate any insight into how to do this.
    Thank you,
    Dean Atteberry.

    This is a puzzling...
    For the table control wizard, in the Table Control Attributes step, I was able to get line selectability to open up by declaring a char01 data element at the beginning of my type.
    The puzzling is in regards to the "Selection col. fld" entry field.
    If I leave it blank and try to go to the next step, I get message "Enter the name of the selection column if you are using a program table"
    So it looked like it wanted to know the name of my selection column.  So I type in "CHAR1".  and got the message "The field "CHAR1" for the selection column is already contained in the table."
    Hmmmmm.... don't understand............
    Dean Atteberry.

  • Getting error of Defining an internal table with header line, SELECT-OPTIO

    Hi all,
    i have a coding for my smart form,In this coding i have define an structure which being used,but when i execute it it give me
    error of Defining an internal table with header line, SELECT-OPTIONS, and RANGES is not allowed within a structure.Even tough you can see that in  my coding im not using SELECT-OPTION or RANGES,but can't understand why it gives me this error.
    Following are the code:
      DATA: BEGIN OF traptab OCCURS 50.
            INCLUDE STRUCTURE mseg.
      DATA: vgart LIKE mkpf-vgart,
            blart LIKE mkpf-blart,
            blaum LIKE mkpf-blaum,
            bldat LIKE mkpf-bldat,
            budat LIKE mkpf-budat,
            cpudt LIKE mkpf-cpudt,
            cputm LIKE mkpf-cputm,
            aedat LIKE mkpf-aedat,
            usnam LIKE mkpf-usnam,
            tcode LIKE mkpf-tcode,
            xblnr LIKE mkpf-xblnr,
            bktxt LIKE mkpf-bktxt,
            frath LIKE mkpf-frath,
            frbnr LIKE mkpf-frbnr,
            wever LIKE mkpf-wever,
          END OF traptab. 
    Thanks & Regards,
    sappk25

    thanks

  • How to process Line Selection on ALV Table in ABAP WebDynpro

    Hi there,
    I have a view with an ALV table whose context node retrieves its data from a Service Call for a method.
    The method provides certain data of a database table which the ALV displays.
    Now I would like to be able to select one row of that ALV table and after pressing a button or doubleclicking on the row or whatever a different view (as for me it is also ok on the same view) should appear to display the details of that selection.
    I only need to know how to retrieve the selected data.
    Or its index within the internal table.
    I am already looking for hours for a useful thread and actually there is one which obviously is about a similar issue apart from the multiple selection part: 
    How to process multiple row selection in ALV table in Wendynpro ABAP? Help!
    but i am afraid that i don't understand it. Or at least I misunderstand it since it does not work with me.
    The system example mentioned in the thread does not help me either because it somehow does not correspond to my needs, does it?
    It would be GREAT if somebody could help me with that. Please keep it simple for I am not an expert in webdynpro yet (obviously ^^) and also please explain in detail what I have to do with the context nodes since I am not sure whether the selection is stored in my already existing node or whether I need a special one for that.
    Thanks!!
    christina

    Hi Christina,
    If you just want to get one column data of the line that user clicked, use the Web Dynpro Code Wizard to Read Context of attibute you needed, then you will get code as follow:
    * Define data for read attribute
        node_alv TYPE REF TO if_wd_context_node,
        elem_alv TYPE REF TO if_wd_context_element,
        stru_alv TYPE if_view_display=>element_alv ,
        item_column_name  LIKE stru_alv-column_name.
    * navigate from <CONTEXT> to <ALV> via lead selection
      node_alv = wd_context->get_child_node( name = if_view_display=>wdctx_alv ).
    * get element via lead selection
      elem_alv = node_alv->get_element(  ).
    * get single attribute
      elem_alv->get_attribute(
        EXPORTING
          name =  `COLUMN_NAME'
        IMPORTING
          value = item_column_name ).
    The value of column_name is stored in item_column_name.
    If you need the index that the user clicked, try this:
    * Definition of field symbol for index
      FIELD-SYMBOLS : <fs_index> TYPE data.
    * Get the selected index
      ASSIGN r_param->index->* TO <fs_index>.
    The index of clicked line is stored in field symbol <fs_index>.
    Hope it will help.
    Best Regards,
    Stephanie

  • Problem with table cell editors - Dropdown by Index, getting lead selection

    Hi experts,
    I have a table editor with 5 columns
    1st column is a Drop Down byIndex.
    My contex looks like this
    AS_DATA(Parent Node cardinality 1.1, selection 0-1)
          HEADER (NODE)
          DETAILS(NODE cardinality 0..n, selection 0-1)
             ACTIVITY_TYPES (NODE cardinality 0..n selection 0-1 ) "node for drop down
             description - attribute
             unit
             quantity
    i have bound details node to table data source.
    i have a tool bar button 'Add Line item' which will add a new line item to the table.
    (i am adding a blank line to the table that is bound to table )
    Its working fine. but when ever i add more than one row, the selection made in the previous rows drop down is lost.
    its initializing. where could be the problem.
    My code
    data LO_ND_INV_TYPE type ref to IF_WD_CONTEXT_NODE.
      data LO_EL_INV_TYPE type ref to IF_WD_CONTEXT_ELEMENT.
      data LS_INV_TYPE type WD_THIS->ELEMENT_INV_TYPE.
      data LV_INV_TYPE type WD_THIS->ELEMENT_INV_TYPE-INV_TYPE.
      data LO_ND_DETAILS type ref to IF_WD_CONTEXT_NODE.
      data LT_DETAILS type WD_THIS->ELEMENTS_DETAILS.
      data LS_DETAILS like line of LT_DETAILS.
      data:  WD_NODE type ref to IF_WD_CONTEXT_NODE,
            LR_ELEMENT type ref to IF_WD_CONTEXT_ELEMENT.
      data LO_ND_INV_PATTERN type ref to IF_WD_CONTEXT_NODE.
      data LO_EL_INV_PATTERN type ref to IF_WD_CONTEXT_ELEMENT.
      data LS_INV_PATTERN type WD_THIS->ELEMENT_INV_PATTERN.
      data LV_INV_PAT type WD_THIS->ELEMENT_INV_PATTERN-INV_TYPE.
      data LO_ND_ACTIVITY_TYPES type ref to IF_WD_CONTEXT_NODE.
      data LT_ACTIVITY_TYPES type WD_THIS->ELEMENTS_ACTIVITY_TYPES.
      data LW_ACTIVITY_TYPES type WD_THIS->ELEMENT_ACTIVITY_TYPES.
        data LO_EL_ACTIVITY_TYPES type ref to IF_WD_CONTEXT_ELEMENT.
    *     navigate from <CONTEXT> to <DETAILS> via lead selection
        LO_ND_DETAILS = WD_CONTEXT->PATH_GET_NODE( PATH = `AS_DATA.DETAILS` ).
        LO_ND_DETAILS->GET_STATIC_ATTRIBUTES_TABLE(
          importing TABLE = LT_DETAILS ).
    * Append an empty row to lt_details
        append LS_DETAILS to LT_DETAILS.
        LO_ND_DETAILS->BIND_TABLE(
        NEW_ITEMS = LT_DETAILS ).
    * Get values for dropdown
    call method WD_ASSIST->GET_ACTIVITY_TYPE
          exporting
            I_INV_CAT_ID     = LV_INV_PAT
          importing
            ET_ACTIVITY_TYPE = LT_ACTIVITY_TYPES.
        LW_ACTIVITY_TYPES-ID = 'Select a Activity type'.
        LW_ACTIVITY_TYPES-TEXT = 'Select a Activity type'.
        insert LW_ACTIVITY_TYPES into LT_ACTIVITY_TYPES index 1.
        loop at LT_DETAILS into LS_DETAILS.
          LV_TABIX = SY-TABIX.
          LR_ELEMENT = LO_ND_DETAILS->GET_ELEMENT( LV_TABIX ).
          WD_NODE = LR_ELEMENT->GET_CHILD_NODE( 'ACTIVITY_TYPES' ).
    *lv_index = wd_node->get_lead_selection_index( ). " it is dumping at this statement when i try to get lead selection
          WD_NODE->BIND_TABLE( NEW_ITEMS =  LT_ACTIVITY_TYPES ). " data for dropdown
        endloop.
    any clue on what am i missing will be appreciated.
    I am getting dump when i try to get the lead selection
    Ajay

    You only have only one option in the DDI to display in the example. when you have multiple values
    i assume that by adding an empty row like this will lose the SELECTION MADE in DDI. (Correct me If i am wrong)
    somehow i believe that we need to bind the DD values using  SET LEAD SELECTION INDEX METHOD FOR THE DDI when they are already selected and trying to BIND.
    *LO_ND_DETAILS->GET_STATIC_ATTRIBUTES_TABLE(*
          *importing TABLE = LT_DETAILS ).*
    ** Append an empty row to lt_details*
        *append LS_DETAILS to LT_DETAILS.*
        *LO_ND_DETAILS->BIND_TABLE(*
        *NEW_ITEMS = LT_DETAILS ).*
    even though the above code will have the selected value, the SELECTIONS MADE will be initialize.
    you need to bind it explicitly.
    you have to create an element and bind the DDI values for adding an row as SARAVANAN said.
    or i guess you can continue with you code but need to use SET LEAD to display the correct SELECTIONS MADE
    loop at LT_DETAILS into LS_DETAILS.
          LV_TABIX = SY-TABIX.
          LR_ELEMENT = LO_ND_DETAILS->GET_ELEMENT( LV_TABIX ).
          WD_NODE = LR_ELEMENT->GET_CHILD_NODE( 'ACTIVITY_TYPES' ).
          WD_NODE->BIND_TABLE( NEW_ITEMS =  LT_ACTIVITY_TYPES ). " data for dropdown
    *" try to set the desired value in the DDI when you have multiple values using SET LEAD*
        endloop.

  • CL_GUI_ALV_GRID: Line selection and backend table

    Dear community,
    is there a way to propagate line selection of ALV GRID GUI automagically to the backend data table?
    This is my scenario:
    1) A table containing several records with one column 'SELECTED' for selection status
    2) ALV_GRID to display the table with layout info for line selection
    alv_layo-sel_mode   = 'A'.
    alv_layo-box_fname  = 'SELECTED'.
    3) At PBO methods set_table_for_first_display and refresh_table_display are called with the table containing some records marked as 'SELECTED'.
    First problem here: 'SELECTED' entries are not propagated to the ALV grid (the lines in the GUI are not marked). I know I could use set_selected_rows to force the selection, but is this really necessary?
    4) Then, at PAI method check_changed_data is called (and yes, event mc_evt_modified is registered).
    Second problem: Changes in selection are not propagated automagically to the underlying table. I also know I could use get_selected_rows to force this update manually, but again: is this really necessary?
    Can anyone explain the behavior why sorting etc. is propagated automatically to the underlying table, but not the selection of rows? Am I missing something?
    Hint: Removing box_fname = 'SELECTED' and setting the fieldcatalog to display the column 'SELECTED' as editable checkbox works also. But our users are familiar with the rowmark, so this is no option.
    Any suggestions are welcome.
    Thanks,
    Torsten.
    Here an (almost) complete listing of the code:
    PROCESS BEFORE OUTPUT.
      MODULE SET_STATUS_TITLE_0100.
      MODULE INIT_ALV_GRID_0100.
      MODULE DISPLAY_DATA_0100.
      MODULE SET_GRID_SELECTION_0100.
    PROCESS AFTER INPUT.
      MODULE EXIT_COMMAND_0100 AT EXIT-COMMAND.
      MODULE UPDATE_TABLE_DATA_0100.
      MODULE USER_COMMAND_0100.
    MODULE init_alv_grid_0100 OUTPUT.
      IF NOT gr_container IS BOUND.
    *   Container erzeugen
        CREATE OBJECT gr_container ...
    *   ALV Grid erstellen
        CREATE OBJECT gr_alv_grid ...
    *   ALV für die erste Anzeige vorbereiten
        gs_alv_layo-zebra      = on.         " Gestreifte Anzeige
        gs_alv_layo-no_toolbar = on.         " Keine Toolbar
        gs_alv_layo-no_rowmark = off.        " Keine Zeilenmarkierung
        gs_alv_layo-edit       = off.        " Editieren ermöglichen
        gs_alv_layo-sel_mode   = 'A'.        " Selektionsmodus
        gs_alv_layo-cwidth_opt = off.        " Optimierte Spaltenbreite!
        gs_alv_layo-info_fname = 'LCOLOR'.   " ALV-Control: Feldname mit
                                             " einfacher Farbcodierung für
                                             " Zeile
        gs_alv_layo-ctab_fname = 'CCOLOR'.   " ALV-Control: Feldname mit
                                             " komplexer Farbcodierung
                                             " für Zellen
        gs_alv_layo-box_fname  = 'SELECTED'. " Markierte Zeilen
    *   Feldkatalog für die Anzeige vorbereiten
    *    CLEAR gs_fcat.                       " Mehrfachsel. ermöglichen
    *    gs_fcat-fieldname = 'SELECTED'.      " Dazu muss das Feld für die
    *    gs_fcat-edit      = on.              " Selektion editierbar sein.
    *    gs_fcat-checkbox  = on.              " Ausserdem muss die
    **   gs_fcat-outputlen = '3'.             " Zeilenmark. eingeschaltet
    *    APPEND gs_fcat TO gt_fcat.           " und box_fname gesetzt sein.
    *   Ereignisbehandlung
        SET HANDLER
          lcl_event_handler=>on_click
          lcl_event_handler=>on_hotspot
          lcl_event_handler=>on_double_click
          lcl_event_handler=>on_user_command
          lcl_event_handler=>on_data_changed
        FOR gr_alv_grid.
        CALL METHOD gr_alv_grid->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_modified
          EXCEPTIONS
            error      = 1
            OTHERS     = 2.
      ENDIF.
    ENDMODULE.                 " INIT_ALV_GRID_0100  OUTPUT
    MODULE display_data_0100 OUTPUT.
    * PBO Modul für alle weiteren Anzeigezyklen.
      IF gr_alv_grid IS BOUND.
        CALL METHOD gr_alv_grid->set_table_for_first_display ...
      ENDIF.
    ENDMODULE.                 " DISPLAY_DATA_0100  OUTPUT
    MODULE set_grid_selection_0100 OUTPUT.
      IF gr_alv_grid IS BOUND.
        CALL METHOD gr_alv_grid->refresh_table_display.
      ENDIF.
    * Alterative: Set selected rows manually
    *    CALL METHOD gr_alv_grid->set_selected_rows
    ENDMODULE.                 " SET_GRID_SELECTION_0100 OUTPUT
    MODULE update_table_data_0100 INPUT.
        CALL METHOD gr_alv_grid->check_changed_data.
    * Alternative: Get selected rows and update table manually
    *    CALL METHOD gr_alv_grid->get_selected_rows ...
    ENDMODULE.                 " UPDATE_TABLE_DATA_0100  INPUT

    Hello Torsten
    I may be wrong but I think the field LVC_S_LAYO-BOX_FNAME is a relict from the stone-age SLIS-based ALV programming.
    Using modern OO-based ALV we do not need any kind of "MARK" row but we have the appropriate methods available.
    Regards
      Uwe

  • 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.

  • Getting the selected index of a table (CL_WD_TABLE) without lead-selection

    Hi
    When I click in a table-UI (not alv-table) on a f4-help, I can search with se11-searchhelp on a field. After I choose something, I should also fill some other fields in the same row.
    In the table I have no lead-selection. So, I am searching for a method that gets me the selected index. The element-class for the table-UI is CL_WD_TABLE.
    Once I have the selected index, I could change the fields in the same row inside the WDDOMODIFYVIEW.
    With activated node-selection it can be, that the user selects one row, but he starts the f4-help on another row (the lead-selection doesn't change).
    I have seen this article, but i hope that for the table-UI it is different than with alv:
    [ON_CELL_ACTION triggered only by ENTER ?]

    Hi Lorenzo,
    I'm trying to do the same thing and came up with this solution. In WDDOMODIFYVIEW, since we cannot know in which table row the user clicked the search help, I simply loop through all the rows of the table. For each row, I delegate to a method in the Component Controller which sets the specified index as the table's lead selection then reads the selected table row from the context. I can then populate fields in the selected row as needed.
    METHOD wddomodifyview .
       DATA lo_componentcontroller TYPE REF TO ig_componentcontroller.
       DATA lo_nd_items TYPE REF TO if_wd_context_node.
       DATA lt_items TYPE wd_this->elements_items.
    * -- Upon return from the search help, populate table row details
       lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
       lo_nd_items = wd_context->get_child_node( name = wd_this->wdctx_items ).
       lo_nd_items->get_static_attributes_table( IMPORTING table = lt_items ).
    * Since we cannot know in which table row the user requested the search help,
    * loop through all table rows, populating table row details as needed.
       DESCRIBE TABLE lt_items LINES sy-tfill.
       DO sy-tfill TIMES.
    *   Delegate to the Component Controller
         lo_componentcontroller->get_table_row_detail( sy-index ).
       ENDDO.
    ENDMETHOD.

  • At line Selection & get cursor field

    Hi friends,
    Could any one of u please explain about<b> at line selection</b> and <b>GET CURSOR FIELD</b> ( GET CURSOR FIELD FNAM VALUE FVAL) with sample program.
    Jai.

    Hello,
    AT - Events in lists
    Variants:
    1. AT LINE-SELECTION.
    2. AT USER-COMMAND.
    3. AT PFn.
    Variant 1
    AT LINE-SELECTION.
    Effect
    Event in interactive reporting
    This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE,ULINE, or SKIP) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2, because it has the same effect as double-clicking the mouse, or clicking once in the case of a hotspot.
    The processing for the event AT LINE-SELECTION usually generates further list output (the details list) which completely covers the current list display. If you want the current list display to remain visible (to aid user orientation), you can do this with the key word WINDOW.
    In most cases, the information from the selected line is used to retrieve more comprehensive information by direct reading. When displaying the original list, you store the key terms needed for this in the HIDE area of the output line.
    Note
    You can choose a line and start new processing even in the details lists.
    The following system fields are useful for orientation purposes, since their values change with each interactive event executed.
    SY-LSIND
    Index of list created by current event (basic list = 0, 1st details list = 1, ...)
    SY-PFKEY
    Status of displayed list (SET PF-STATUS)
    SY-LISEL
    Contents of selected line
    SY-LILLI
    Absolute number of this line in the displayed list
    SY-LISTI
    Index of this list - usually SY-LSIND - 1 (READ LINE)
    SY-CUROW
    Last cursor position: Line in window
    SY-CUCOL
    Last cursor position: Column in window (GET CURSOR)
    SY-CPAGE
    1st displayed page of displayed list
    SY-STARO
    1st displayed line of this page of displayed list
    SY-STACO
    1st displayed column of displayed list (SCROLL LIST)
    The system field SY-LSIND defines the line selection level (basic list: SY-LSIND = 0).
    System field for interactive reporting are also contained in the System Fields for Lists documentation.
    Example
    DATA TEXT(20).
    START-OF-SELECTION.
      PERFORM WRITE_AND_HIDE USING SPACE SPACE.
    AT LINE-SELECTION.
      CASE TEXT.
        WHEN 'List index'.
          PERFORM WRITE_AND_HIDE USING 'X' SPACE.
        WHEN 'User command'.
          PERFORM WRITE_AND_HIDE USING SPACE 'X'.
        WHEN OTHERS.
          SUBTRACT 2 FROM SY-LSIND.
          PERFORM WRITE_AND_HIDE USING SPACE SPACE.
      ENDCASE.
      CLEAR TEXT.
    FORM WRITE_AND_HIDE USING P_FLAG_LSIND P_FLAG_UCOMM.
      WRITE / 'SY-LSIND:'.
      PERFORM WRITE_WITH_COLOR USING SY-LSIND P_FLAG_LSIND.
      TEXT = 'List index'.
      HIDE TEXT.
      WRITE / 'SY-UCOMM:'.
      PERFORM WRITE_WITH_COLOR USING SY-UCOMM P_FLAG_UCOMM.
      TEXT = 'User command'.
      HIDE TEXT.
      IF SY-LSIND > 0.
        WRITE / 'PICK here to go back one list level'.
      ENDIF.
    ENDFORM.
    FORM WRITE_WITH_COLOR USING P_VALUE
                                P_FLAG_POSITIVE.
      IF P_FLAG_POSITIVE = SPACE.
        WRITE P_VALUE COLOR COL_NORMAL.
      ELSE.
        WRITE P_VALUE COLOR COL_POSITIVE.
      ENDIF.
    ENDFORM.
    Depending on whether you choose the line at SY-LSIND or SY-UCOMM, the next details list contains the corresponding value with the color "positive". If the line is chosen without HIDE information, the list level is reduced.
    Variant 2
    AT USER-COMMAND.
    Effect
    Event in interactive reporting
    This event is executed whenever the user presses a function key in the list or makes an entry in the command field.
    Some functions are executed directly by the system and thus cannot be processed by programs. These include:
    PICK
    See variant AT LINE-SELECTION
    PFn
    See variant AT PFn
    System command
    System command
    PRI
    Print
    BACK
    Back
    RW
    Cancel
    P...
    Scroll function (e.g.: P+ , P- , PP+3, PS-- etc.)
    Instead of this functions, you can use the SCROLL statement in programs.
    Since many of these system functions begin with "P", you should avoid using this letter to start your own function codes.
    Otherwise, the effect is as for AT LINE-SELECTION; also, the current function code is stored in the system field SY-UCOMM.
    Example
    DATA: NUMBER1 TYPE I VALUE 20,
          NUMBER2 TYPE I VALUE  5,
          RESULT  TYPE I.
    START-OF-SELECTION.
      WRITE: / NUMBER1, '?', NUMBER2.
    AT USER-COMMAND.
      CASE SY-UCOMM.
        WHEN 'ADD'.
          RESULT = NUMBER1 + NUMBER2.
        WHEN 'SUBT'.
          RESULT = NUMBER1 - NUMBER2.
        WHEN 'MULT'.
          RESULT = NUMBER1 * NUMBER2.
        WHEN 'DIVI'.
          RESULT = NUMBER1 / NUMBER2.
        WHEN OTHERS.
          WRITE 'Unknown function code'.
          EXIT.
      ENDCASE.
      WRITE: / 'Result:', RESULT.
    After entry of a function code, the appropriate processing is performed under the event AT USER-COMMAND and the result is displayed in the details list.
    Variant 3
    AT PFn.
    Effect
    Event in interactive reporting
    Here, n stands for a numeric value between 0 and 99.
    This event is executed whenever the user presses a function key that contains the function code PFn in the interface definition. The default status for lists contains some of these functions.
    Otherwise, the effect is as for the variant AT LINE-SELECTION. The cursor can be on any line.
    Notes
    To ensure that the chosen function is executed only for valid lines, you can check the current HIDE information.
    This variant should be used only for test or prototyping purposes, since the default status is not normally used. Instead, you should set a program-specific status with SET PF-STATUS. This should not contain any function codes beginning with "PF".
    Example
    DATA NUMBER LIKE SY-INDEX.
    START-OF-SELECTION.
      DO 9 TIMES.
        WRITE: / 'Row', (2) SY-INDEX.
        NUMBER = SY-INDEX.
        HIDE NUMBER.
      ENDDO.
    AT PF8.
      CHECK NOT NUMBER IS INITIAL.
      WRITE: / 'Cursor was in row', (2) NUMBER.
      CLEAR NUMBER.
    Additional help
    User Action on Detail Lists
    GET
    Basic form 2 GET CURSOR. ...
    Variants:
    1. GET CURSOR FIELD f.
    2. GET CURSOR LINE line.
    Variant 1
    GET CURSOR FIELD f.
    Additions:
    1. ... OFFSET off
    2. ... LINE line
    3. ... VALUE g
    4. ... LENGTH len
    5. ... AREA
    Effect
    Transfers the name of the field at the cursor position to the field f.
    The return code is set as follows:
    SY-SUBRC = 0:
    Cursor was positioned on a field.
    SY-SUBRC = 4:
    Cursor was not positioned on a field.
    Note
    Unlike screen processing, list processing allows you to output literals, field symbols, parameters and local variables of subroutines. Literals, local variables and VALUE parameters of subroutines are treated like fields without names (field name SPACE, return value 0).
    Otherwise, GET CURSOR FIELD returns only names of global fields, regardless of whether they are addressed directly (i.e. by "WRITE"), by field symbols or by reference parameters.
    Example
    DATA: CURSORFIELD(20),
          GLOB_FIELD(20)    VALUE 'global field',
          REF_PARAMETER(30) VALUE 'parameter by reference',
          VAL_PARAMETER(30) VALUE 'parameter by value',
          FIELD_SYMBOL(20)  VALUE 'field symbol'.
    FIELD-SYMBOLS: <F> TYPE ANY.
    PERFORM WRITE_LIST USING REF_PARAMETER VAL_PARAMETER.
    ASSIGN GLOB_FIELD TO <F>.
    AT LINE-SELECTION.
      GET CURSOR FIELD CURSORFIELD.
      WRITE: /   CURSORFIELD, SY-SUBRC.
    FORM WRITE_LIST USING RP VALUE(VP).
      DATA: LOK_FIELD(20)  VALUE 'local field'.
      ASSIGN FIELD_SYMBOL TO <F>.
      WRITE: /  GLOB_FIELD,  /  LOC_FIELD,
             /  RP,          /  VP,
             /  'literal',   /  FIELD_SYMBOL.
    ENDFORM.
    When you double-click the word " global field", CURSORFIELD contains the field name GLOB_FIELD, on "parameter by reference" the field name REF_PARAMETER, on " field symbol" the field name FIELD_SYMBOL, and on "local field", "parameter by value" and "literal" the value SPACE.
    Addition 1
    ... OFFSET off
    Effect
    Copies the position of the cursor within the field to the field off (1st column = 0).
    If the cursor is not somewhere within a field (SY-SUBRC = 4), the offset value is set to 0.
    Addition 2
    ... LINE line
    Effect
    With step loops, lin contains the number of the loop line where the cursor stands. In list processing, this is the absolute line number (as stored in the system field SY-LILLI).
    Addition 3
    ... VALUE g
    Effect
    g contains the value of the field where the cursor stands, always in output format (character display).
    Addition 4
    ... LENGTH len
    Effect
    len contains the output length of the field where the cursor stands.
    Addition 5
    ... AREA a
    Effect
    If the cursor is positioned on the field of a table view control, the name of the control is placed in the field a.
    Variant 2
    GET CURSOR LINE line.
    Additions:
    1. ... OFFSET off
    2. ... VALUE  g
    3. ... LENGTH len
    Effect
    As for variant 1 with addition LINE, except that there are differences with the return code and the effect of the additions.
    The return code is set as follows:
    SY-SUBRC = 0:
    The cursor is on one of the list lines (list processing) or on a loop line (step loop).
    SY-SUBRC = 4:
    The cursor is not on one of the list or loop lines.
    Addition 1
    ... OFFSET off
    Effect
    Applies to list processing only. The field off contains the position of the cursor relative to the beginning of the list line (1st column = 0). With horizontally shifted lists, the offset value can thus be greater than 0, even if the cursor is positioned on the extreme left of the window.
    Addition 2
    ... VALUE g
    Effect
    List processing only. The field g contains the list line where the cursor is positioned.
    Addition 3
    ... LENGTH len
    Effect
    List processing only. len contains the length of the line (LINE-SIZE).
    Related
    SET CURSOR
    Additional help
    Setting the Cursor Position
    Reading Lists at the Cursor Position
    Vasanth

  • How to get the selected rows & columns in the table?

    hi everybody,
                         In my application the table is kept inside the event structure.I select the cells  in the table (using mouse) on running time.How to get the selected number of rows & columns in that table?

    Hello,
    You can fill selected values of the table by writing to it or the corresponding property using a property node - the table is just a 2D array of strings.  I think for your "disable" question you are referring to the shortcut menu (when you right click).  If you are using LabVIEW 8.x, you can edit or disable that shortcut menu - just right click on your table at edit time and choose Advanced >> Run-Time Shortcut Menu.
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • 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.

Maybe you are looking for