JList, events - catching the index selected?

Was reading the API Docs for JList, and ListSelectionListener, but i cant seem to understand how it works.
What i "need" to do, is be able to see what index of the JList is selected, hell even the string value associated with the index selected would be usable.
-thanks

myList.getSelectedItem();
or
myList.getSelectedItems();
You don't need any listeners to find what it selected. Use a listener if you want an action to occur when the user clicks on the item.

Similar Messages

  • How to get the current selected value of a combo box or a option button?

    Hello All,
    I want to catch the current selected value of a combo box and also of a option button and want save it into different variables in my code. These option button and combo box are in a SAP business one form which I have created through VB dot.net coding.
    But I don't know how to do that, can any one send any example code for this.
    Regards,
    Sudeshna.

    Hi Sudesha,
    If you want to get the selected values you can do it as follows: The Combo Box value you can get from the combo box. If you want to get it on the change event, you must make sure that you check when BeforeAction = False. If you want to get an Option Button value you should check the value in the data source attached to the option button.
            Dim oForm As SAPbouiCOM.Form
            Dim oCombo As SAPbouiCOM.ComboBox
            Dim oData As SAPbouiCOM.UserDataSource
            oForm = oApplication.Forms.Item("MyForm")
            oCombo = oForm.Items.Item("myComboUID")
            oApplication.MessageBox(oCombo.Selected.Value)
            oData = oForm.DataSources.UserDataSources.Item("MyDataSourceName")
            oApplication.MessageBox(oData.ValueEx)
    Hope it helps,
    Adele

  • How to catch change cell selection in a JTable?

    I'm using a ListSelectionListener with a JTable to catch the list selection changes but it only detects row changes, and if i select a different cell but within the same row it does not trigger the event.
    Do you guys know a way to detect this event?
    Thanks!!!

    I'm using a ListSelectionListener with a JTable to catch the list selection changes but it only detects row changes,Try adding a listener for the columns as well:
    table.getTableHeader().getColumnModel().getSelectionModel().addListSelectionListener(...);

  • Index selectivity

    Hi gems.. good morning..
    I have a table (Order_Table) in which there are 4 indexes.
    Suppose the column names are col1, col2, col3, col4, col5, col6.
    The primary key is on col1, col2, col3, col4.
    There are three indexes on the table:
    index1: col1
    index2: col1, col2, col3, col5
    index3: col1, col2, col3, col6
    Now when I am issuing a select statement with a WHERE clause of col1,col2,col3 then it is using index2.
    Again when I am issuing a select statement with a WHERE clause of col1,col2 then it is using the primary key.
    I am really confused about the index selectivity.
    Can you please make me understand the functionality or point to the documentation link.
    Thanks in advance...

    gogol wrote:
    Hi gems.. good morning..
    I have a table (Order_Table) in which there are 4 indexes.
    Suppose the column names are col1, col2, col3, col4, col5, col6.
    The primary key is on col1, col2, col3, col4.
    There are three indexes on the table:
    index1: col1
    index2: col1, col2, col3, col5
    index3: col1, col2, col3, col6
    Now when I am issuing a select statement with a WHERE clause of col1,col2,col3 then it is using index2.
    Again when I am issuing a select statement with a WHERE clause of col1,col2 then it is using the primary key.
    I am really confused about the index selectivity.
    Can you please make me understand the functionality or point to the documentation link.
    Your best bet is to get a copy of "Cost Based Oracle - Fundamentals". It's about 6 years old now, but still mostly correct, although some of the details have changed.
    As mpreiss pointed out, the basic formula is based on blevell, leaf_blocks, and clustering_factor with the various selectivities applied.
    In the case of choosing which index of pk, index2, and index3, the selectivity for 'col1 = constant1 and col2 = constant2 and col3 = constant3" isn't changed by the choice of index so - assuming that the query wasn't one that could be answered completely from just visiting an index - then the number of leaf_blocks would have a (generally low) impact on the cost each index, and the clustering_factor would have (usually more significant) impact on the cost.
    If your table really is just these six column, by the way, then there's a fair chance it should be an index-organized table - leaving you with just one index structure to maintain, and no table structure. As it is, your table is almost certainly over-indexed and wasting resources.
    Regards
    Jonathan Lewis

  • Personas 2.0: How to catch the selection event of a dropdown list?

    Hi Personas 2.0 experts,
    The use case:
    I want to use a text field to show the "key" of an item that can be selected in a dropdown list.
    The issue:
    After clicking the list and selecting an item, the text field is not automatically updated with the newly selected item content.
    Anyone has an idea to how make such an auto update (pls note I don't want to use an extra button to do the update, just by clicking the list only)?
    Thx.
    Dong

    To display the key (the actual value) that's selected in a dropdown, there is a property called ShowKeys which you could set.
    However if you'd want to show the selected value in another field upon picking an option, this would require an event associated in Personas 2.0 with the selection of a dropdown value. This is currently not available so I'm afraid what you are looking for is not possible.
    Edit: It turns out I was wrong... there is an option (at least it's there in SP3) which allows linking a script button to the dropdown property OnValueChanged, so you can use this to do any script action you need when the user selects a value.
    (thanks, Sushant )
    Message was edited by: Tamas Hoznek

  • How to catch the mouse event from the JTable cell of  the DefaultCellEditor

    Hi, my problem is:
    I have a JTable with the cells of DefaultCellEditor(JComboBox) and added the mouse listener to JTable. I can catch the mouse event from any editor cell when this cell didn't be focused. However, when I click the editor to select one JComboBox element, all the mouse events were intercepted by the editor.
    So, how can I catch the mouse event in this case? In other word, even if I do the operation over the editor, I also need to catch the cursor position.
    Any idea will be highly appreciated!
    Thanks in advance!

    Hi, bbritta,
    Thanks very much for your help. Really, your code could run well, but my case is to catch the JComboBox event. So, when I change the JTextField as JComboBox, it still fail to catch the event. The following is my code. Could you give me any other suggestion?
    Also, any one has a good idea for my problem? I look forward to the right solution to this problem.
    Thanks.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test3
    extends JFrame {
    // JTextField jtf = new JTextField();
    Object[] as = {"aa","bb","cc","dd"};
    JComboBox box = new JComboBox(as);
    public Test3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    String[] head = {
    "One", "Two", "Three"};
    String[][] data = {
    "R1-C1", "R1-C2", "R1-C3"}
    "R2-C1", "R2-C2", "R2-C3"}
    JTable jt = new JTable(data, head);
    box.addMouseListener(new MouseAdapter() {
    // jtf.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JComboBox mouseclick....");
    jt.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JTable mouseclick....");
    // jt.setDefaultEditor(Object.class, new DefaultCellEditor(jtf));
    jt.setDefaultEditor(Object.class, new DefaultCellEditor(box));
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    setSize(300, 300);
    public static void main(String[] args) {
    new Test3().setVisible(true);
    }

  • How to catch the event for change dropdown value in alv

    it has a column output by dropdown in alv. the dropdown type cl_salv_wd_uie_dropdown_by_idx.
    now the problem is if change the dropdown value, i want to catch the event to change another column value.
    how can i do it?

    This part contains other ALV initialization code
    *... init ColumnSettings
      DATA:
            lr_column_settings TYPE REF TO if_salv_wd_column_settings.
      lr_column_settings ?= wd_this->r_table.
      DATA:
            lt_columns TYPE salv_wd_t_column_ref.
      lt_columns = lr_column_settings->get_columns( ).
      DATA:
            ls_column     TYPE salv_wd_s_column_ref,
            lr_col_header TYPE REF TO cl_salv_wd_column_header,
            l_tooltip     TYPE string.
      LOOP AT lt_columns INTO ls_column.
        CASE ls_column-id.
          WHEN 'PLANETYPE'.
            DATA:
                  lr_drdn_by_key TYPE REF TO cl_salv_wd_uie_dropdown_by_key.
            CREATE OBJECT lr_drdn_by_key
              EXPORTING
                selected_key_fieldname = ls_column-id.
            lr_drdn_by_key->set_key_visible( abap_true ).
            ls_column-r_column->set_cell_editor( lr_drdn_by_key ).
          WHEN OTHERS.
        ENDCASE.
    ENDLOOP.
      DATA:
            node_info TYPE REF TO if_wd_context_node_info,
            lt_valueset   TYPE STANDARD TABLE OF wdr_context_attr_value,
            l_value       TYPE wdr_context_attr_value.
      node_info = wd_context->get_node_info( ).
      node_info = node_info->get_child_node( 'FLIGHT_INFO' ).
    data : lt_sflight type STANDARD TABLE OF sflight,
           ls_sflight like LINE OF lt_sflight.
    SELECT * from sflight into TABLE lt_sflight.
    LOOP at lt_sflight into ls_sflight.
      l_value-value = ls_sflight-planetype.
      l_value-text  = ls_sflight-planetype.
      INSERT l_value into TABLE lt_valueset.
      ENDLOOP.
      node_info->set_attribute_value_set(
      name = 'PLANETYPE'
      value_set = lt_valueset ).

  • Where can we catch the event which leads to downloading a report to a local

    Hi frnds,
    can u help me out . actaully ,i  have a classical interactive report. it has many headings.Because of the initial headings ,if i try to download that report to a local file ,the column allignments are disturbed.
    So,one way i feel to get the download correctly ,is that ,some how i can catch the event whcih leads to the download of the report ,and based on the occurence of that event ,i can restrict the page headings to appear in the downloaded spreadsheet ,so that the there are no, unwanted columns getting inserted in between .
    Regards
    Rajesh.

    hi,
    you can have selection screen field : "parameters : p_disvar like disvariant-variant."  and at event selection scree you can call the below function and select the variant create for the report.
    "at selection-screen on value-request for p_disvar.
      call function 'REUSE_ALV_VARIANT_F4'
           exporting
                is_variant          = g_variant
              I_TABNAME_HEADER    =
              I_TABNAME_ITEM      =
              IT_DEFAULT_FIELDCAT =
                i_save              = g_variant_save
           importing
                e_exit              = h_exit
                es_variant          = gx_variant
            exceptions
                not_found           = 1
                program_error       = 2
                others              = 3.
      if sy-subrc is initial and h_exit is initial.
        g_variant-variant = gx_variant-variant.
        p_disvar          = gx_variant-variant.
      else.
        message id sy-msgid type 'S'
                     number sy-msgno
                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    Atul

  • Why can not catch the standard BACK event in ALV's USER_COMMAND event,

    Hi expert, why i can not catch the standard BACK event in ALV's USER_COMMAND event,
    Code:
    DATA G_CON_UC_FORM   TYPE SLIS_FORMNAME VALUE 'F_USER_COMMAND',
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM      = SY-REPID
          I_CALLBACK_TOP_OF_PAGE  = G_CON_FORM
          I_CALLBACK_USER_COMMAND = G_CON_UC_FORM
          IT_FIELDCAT             = G_TAB_FIELDCAT
          IT_SORT                 = G_TAB_SORT_INF
          I_SAVE                  = G_CON_U
    *<<<Liang
        IT_EVENTS               = G_TAB_ALV_EVENTS
    *<<<Liang
        TABLES
          T_OUTTAB                = G_TAB_OUTPUT_DATA
        EXCEPTIONS
          PROGRAM_ERROR           = 1
          OTHERS                  = 2.
    *&      Form  F_USER_COMMAND
          ALV USER COMMAND processing
    FORM F_USER_COMMAND .
      IF SY-UCOMM = '&FO3'.
        LEAVE TO SCREEN 0.
      ENDIF.
    ENDFORM.                    " F_USER_COMMAND
    When I set breakpoint on this subrouting ,and try to click stardard  BACK or CANCEL button, the callback form do not run, but if double click one of line of alv report, the callback form works well,
    so why??

    hi
    good
    check this report and change your code accordingly.
    THESE LINES ARE FOR THE MAIN PROGRAM ***
    SAP V40B ***
    REPORT Z_PICK_LIST .
    TABLES: RESB.
    SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.
    SELECT-OPTIONS: S_WERKS FOR RESB-WERKS," Plant
                    S_AUFNR FOR RESB-AUFNR," Order number
                    S_BDTER FOR RESB-BDTER." Req. date
    SELECTION-SCREEN END OF BLOCK BL1.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT DEFAULT '/STANDARD'.
    DATA: BEGIN OF OUT OCCURS 10,
            AUFNR LIKE RESB-AUFNR,         " Order number
            MATNR LIKE RESB-MATNR,         " Material
            BDMNG LIKE RESB-BDMNG,         " Requirements in UM
            MEINS LIKE RESB-MEINS,         " Unit of Measure (UM)
            ERFMG LIKE RESB-ERFMG,         " Requirements in UE
            ERFME LIKE RESB-ERFME,         " Unit of Entry (UE)
            MAKTX LIKE MAKT-MAKTX,         " Mat. description
          END OF OUT.
    INCLUDE Z_ALV_VARIABLES.
    INITIALIZATION.
      REPNAME = SY-REPID.
      PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].
      PERFORM BUILD_EVENTTAB USING EVENTS[].
      PERFORM BUILD_COMMENT USING HEADING[].
      PERFORM INITIALIZE_VARIANT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
      PERFORM F4_FOR_VARIANT.
    AT SELECTION-SCREEN.
      PERFORM PAI_OF_SELECTION_SCREEN.
    START-OF-SELECTION.
      PERFORM GET_ORDERS.
      PERFORM GET_MATERIAL_DESCRIPTION.
    END-OF-SELECTION.
      PERFORM BUILD_LAYOUT USING LAYOUT.
      PERFORM BUILD_PRINT  USING PRINTS.
      PERFORM WRITE_USING_ALV.
          FORM INITIALIZE_FIELDCAT                               *
    -->  P_TAB                                                         *
    FORM INITIALIZE_FIELDCAT USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.
      DATA: CAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR CAT.
    ENDFORM.                               " INITIALIZE_FIELDCAT
    *&      Form  GET_ORDERS
          text
    FORM GET_ORDERS.
      SELECT AUFNR MATNR BDMNG MEINS ERFMG ERFME
             FROM RESB
             APPENDING TABLE OUT
             WHERE XLOEK EQ SPACE          " deletion indicator
             AND   XWAOK EQ 'X'            " goods movement indicator
             AND   WERKS IN S_WERKS        " plant
             AND   BDTER IN S_BDTER        " req. date
             AND   AUFNR IN S_AUFNR.       " pr. order
    ENDFORM.                               " GET_ORDERS
    *&      Form  GET_MATERIAL_DESCRIPTION
          text
    FORM GET_MATERIAL_DESCRIPTION.
      SORT OUT BY MATNR.
      LOOP AT OUT.
        SELECT SINGLE MAKTX
               INTO OUT-MAKTX
               FROM MAKT
               WHERE MATNR EQ OUT-MATNR
               AND   SPRAS EQ 'EN'.
        MODIFY OUT.
      ENDLOOP.
      SORT OUT BY AUFNR MATNR.
    ENDFORM.                               " GET_MATERIAL_DESCRIPTION
          FORM TOP_OF_PAGE                                              *
    FORM TOP_OF_PAGE.
      DATA: L_POS TYPE P.
    first line
      WRITE:/ TEXT-001.                    " Plant:
      IF S_WERKS-HIGH NE SPACE.
        WRITE: S_WERKS-LOW, TEXT-TO1, S_WERKS-HIGH.
      ELSEIF S_WERKS-LOW NE SPACE.
        LOOP AT S_WERKS.
          WRITE: S_WERKS-LOW.
        ENDLOOP.
      ELSEIF S_WERKS-LOW EQ SPACE.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = ( SY-LINSZ DIV 2 ) - ( STRLEN( TEXT-TIT ) DIV 2 ).
      POSITION L_POS. WRITE: TEXT-TIT.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-011, SY-UNAME RIGHT-JUSTIFIED.  " User:
    second line
      WRITE:/ TEXT-002.                    " Order:
      IF S_AUFNR-HIGH NE SPACE.
        WRITE: S_AUFNR-LOW, TEXT-TO1, S_AUFNR-HIGH.
      ELSEIF S_AUFNR-LOW NE SPACE.
        LOOP AT S_AUFNR.
          WRITE: S_AUFNR-LOW.
        ENDLOOP.
      ELSEIF S_AUFNR-LOW EQ SPACE.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-012,SY-DATUM.      " Date:
    third line
      WRITE:/ TEXT-003.                    " Req. Date:
      IF S_BDTER-HIGH(1) NE '0'.
        WRITE: S_BDTER-LOW, TEXT-TO1, S_BDTER-HIGH.
      ELSEIF S_BDTER-LOW(1) NE '0'.
        LOOP AT S_BDTER.
          WRITE: S_BDTER-LOW.
        ENDLOOP.
      ELSEIF S_BDTER-LOW(1) EQ '0'.
        WRITE: TEXT-ALL.
      ENDIF.
      L_POS = SY-LINSZ - 20.
      POSITION L_POS. WRITE: TEXT-013, SY-PAGNO.   " Page:
    ENDFORM.                               " TOP_OF_PAGE
          FORM END_OF_LIST                                              *
    FORM END_OF_LIST.
      DATA: L_POS TYPE P.
      ULINE.
      WRITE:/ '|', TEXT-021.      " Delivered by:
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|', TEXT-031.            " Received by:
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      WRITE:/ '|'.
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|'.
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      ULINE.
      WRITE:/ '|', TEXT-012.      " Date:
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|', TEXT-012.            " Date:
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      WRITE:/ '|'.
      L_POS = SY-LINSZ DIV 2.
      POSITION L_POS. WRITE: '|'.
      L_POS = SY-LINSZ.
      POSITION L_POS. WRITE: '|'.
      ULINE.
    ENDFORM.                               " END_OF_LIST
    *&      Form  WRITE_USING_ALV
          text
    FORM WRITE_USING_ALV.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME     = REPNAME
                I_INTERNAL_TABNAME = 'OUT'
                I_INCLNAME         = REPNAME
           CHANGING
                CT_FIELDCAT        = FIELDTAB.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM       = REPNAME
               i_callback_pf_status_set = 'PF_STATUS_SET'
               i_callback_user_command  = 'USER_COMMAND'
                I_STRUCTURE_NAME         = 'OUT'
                IS_LAYOUT                = LAYOUT
                IT_FIELDCAT              = FIELDTAB
                I_DEFAULT                = 'A'
                I_SAVE                   = G_SAVE
                IS_VARIANT               = G_VARIANT
                IT_EVENTS                = EVENTS[]
                IS_PRINT                 = PRINTS
           TABLES
                T_OUTTAB                 = OUT.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
      ENDIF.
    ENDFORM.                               " WRITE_USING_ALV
    THESE LINES ARE FOR THE INCLUDE ***
    ***INCLUDE Z_ALV_VARIABLES .
    TYPE-POOLS: SLIS.
    DATA: FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
          HEADING  TYPE SLIS_T_LISTHEADER,
          LAYOUT   TYPE SLIS_LAYOUT_ALV,
          EVENTS   TYPE SLIS_T_EVENT,
          REPNAME  LIKE SY-REPID,
          F2CODE   LIKE SY-UCOMM VALUE  '&ETA',
          PRINTS   TYPE SLIS_PRINT_ALV,
          TITLE(40) TYPE C,
          G_SAVE(1) TYPE C,
          G_EXIT(1) TYPE C,
          G_VARIANT LIKE DISVARIANT,
          GX_VARIANT LIKE DISVARIANT.
    CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
               FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',
               FORMNAME_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',
               FORMNAME_BEFORE_LINE TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE',
               FORMNAME_AFTER_LINE TYPE SLIS_FORMNAME VALUE 'AFTER_LINE'.
          FORM MAIN_STATEMENTS                                          *
    THIS IS THE CODE THAT MUST BE INSERTED IN THE MAIN PROGRAM
    FORM MAIN_STATEMENTS.
    Declare the parameter P_VARI wherever you want it. If you don't
    want it, hide it with NO-DISPLAY, but it must exist.
    parameters: p_vari like disvariant-variant. " ALV Variant
    You have to add the following line after the data and parameter
    declaration:
    include z_alv_variables.
    Then, after the data/parameter declaration, add these lines:
    *initialization.
    repname = sy-repid.
    perform initialize_fieldcat using fieldtab[].
    perform build_eventtab using events[].
    perform build_comment using heading[].
    perform initialize_variant.
    If you are using the variable P_VARI (ALV Variant), also add this:
    *at selection-screen on value-request for p_vari.
    perform f4_for_variant.
    *at selection-screen.
    perform pai_of_selection_screen.
    After the "END-OF-SELECTION" statement, add these lines:
    perform build_layout using layout.
    perform build_print  using prints.
    perform write_using_alv.
    You also have to create the following forms: (you can find samples
    in this program)
    INITIALIZE_FIELDCAT
    USER_COMMAND     (only if you are creating a STATUS)
    WRITE_USING_ALV
    ENDFORM.
    *&      Form  INITIALIZE_FIELDCAT_SAMPLE
          THIS IS A SAMPLE, DO NOT USE THIS FORM IN YOUR PROGRAM
         -->P_FIELDTAB[]  text                                           *
    FORM INITIALIZE_FIELDCAT_SAMPLE USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.
      DATA: CAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR CAT.                           " Always clear before use
      CAT-TABNAME = 'I'.                   " Your internal table
      CAT-REF_TABNAME = 'ZCUSTMAS'.  " The data dictionary reference table
      CAT-FIELDNAME = 'KUNNR'.       " Name of your field in the itable.
      CAT-COL_POS   = 1.                   " Output position
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'NAME1'.             " Next field
      CAT-COL_POS   = 2.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'STRAS'.             " and the next
      CAT-COL_POS   = 3.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'LOEVM'.
      CAT-SELTEXT_S = 'Del'.         " You can always override the descrip-
      CAT-SELTEXT_M = 'Delivery'.          " tion (short, medium, large)
      CAT-SELTEXT_L = 'Delivery Num'.
      CAT-COL_POS   = 4.
      APPEND CAT TO P_TAB.
      CAT-FIELDNAME = 'FKIMG'.
      CAT-DO_SUM    = 'X'.                 " You want totals calculated.
      CAT-NO_OUT    = 'X'.                 " and hidden.
      APPEND CAT TO P_TAB.
    ENDFORM.                               " INITIALIZE_FIELDCAT
    *&      Form  BUILD_EVENTTAB
          THIS IS THE SAME FOR ALL THE PROGRAMS
         -->P_EVENTS[]  text                                             *
    FORM BUILD_EVENTTAB USING P_EVENTS TYPE SLIS_T_EVENT.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = P_EVENTS.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_END_OF_LIST
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_END_OF_LIST TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_BEFORE_LINE_OUTPUT
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_BEFORE_LINE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_AFTER_LINE_OUTPUT
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_AFTER_LINE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
      CLEAR LS_EVENT.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
    ENDFORM.                               " BUILD_EVENTTAB
    *&      Form  BUILD_COMMENT
    NOT REALLY NEEDED, BUT I'LL LEAVE IT THERE, JUST IN CASE...
         -->P_HEADING[]  text                                            *
    FORM BUILD_COMMENT USING P_HEADING TYPE SLIS_T_LISTHEADER.
      DATA: HLINE TYPE SLIS_LISTHEADER,
            TEXT(60) TYPE C,
            SEP(20) TYPE C.
      CLEAR: HLINE, TEXT.
      HLINE-TYP  = 'H'.
    write: text-101 to text+23.
      HLINE-INFO = TEXT.
      APPEND HLINE TO P_HEADING.
    ENDFORM.                               " BUILD_COMMENT
    *&      Form  INITIALIZE_VARIANT
    VERY IMPORTANT WHEN YOU USE VARIANTS!!!
    FORM INITIALIZE_VARIANT.
      G_SAVE = 'A'.
      CLEAR G_VARIANT.
      G_VARIANT-REPORT = REPNAME.
      GX_VARIANT = G_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                I_SAVE     = G_SAVE
           CHANGING
                CS_VARIANT = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND  = 2.
      IF SY-SUBRC = 0.
        P_VARI = GX_VARIANT-VARIANT.
      ENDIF.
    ENDFORM.                               " INITIALIZE_VARIANT
    *&      Form  PAI_OF_SELECTION_SCREEN
    ALSO FOR VARIANTS
    FORM PAI_OF_SELECTION_SCREEN.
      IF NOT P_VARI IS INITIAL.
        MOVE G_VARIANT TO GX_VARIANT.
        MOVE P_VARI TO GX_VARIANT-VARIANT.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  I_SAVE     = G_SAVE
             CHANGING
                  CS_VARIANT = GX_VARIANT
             EXCEPTIONS
                  WRONG_INPUT   = 1
                  NOT_FOUND     = 2
                  PROGRAM_ERROR = 3.
        IF SY-SUBRC EQ 0.
          G_VARIANT = GX_VARIANT.
        ELSE.
          PERFORM INITIALIZE_VARIANT.
        ENDIF.
      ELSE.
        PERFORM INITIALIZE_VARIANT.
      ENDIF.
    ENDFORM.                               " PAI_OF_SELECTION_SCREEN
    *&      Form  F4_FOR_VARIANT
          text
    FORM F4_FOR_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                IS_VARIANT = G_VARIANT
                I_SAVE     = G_SAVE
           IMPORTING
                E_EXIT     = G_EXIT
                ES_VARIANT = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND  = 2.
      IF SY-SUBRC = 2.
        MESSAGE ID SY-MSGID TYPE 'S'      NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        IF G_EXIT = SPACE.
          P_VARI = GX_VARIANT-VARIANT.
        ENDIF.
      ENDIF.
    ENDFORM.                               " F4_FOR_VARIANT
    *&      Form  BUILD_LAYOUT
    STANDARD LAYOUT
         -->P_LAYOUT  text                                               *
    FORM BUILD_LAYOUT USING P_LAYOUT TYPE SLIS_LAYOUT_ALV.
      P_LAYOUT-F2CODE       = F2CODE.
      P_LAYOUT-ZEBRA        = 'X'.
    p_layout-detail_popup = 'X'.
      P_LAYOUT-TOTALS_TEXT  = SPACE.
      P_LAYOUT-SUBTOTALS_TEXT = SPACE.
    ENDFORM.                               " BUILD_LAYOUT
          FORM BUILD_PRINT                                              *
    STANDARD PRINT OPTIONS                                             *
    -->  P_PRINT                                                       *
    FORM BUILD_PRINT USING P_PRINT TYPE SLIS_PRINT_ALV.
      P_PRINT-NO_PRINT_LISTINFOS = 'X'.
      P_PRINT-NO_PRINT_SELINFOS  = ' '.
    ENDFORM.                               " BUILD_PRINT
          FORM PF_STATUS_SET                                            *
    NAME YOUR STATUS ALV. IF YOU NEED IT..                             *
    FORM PF_STATUS_SET USING EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'ALV' EXCLUDING EXTAB.
    ENDFORM.                               " PF_STATUS_SET
          FORM USER_COMMAND_SAMPLE                                      *
    -->  UCOMM                                                         *
    -->  SELFIELD                                                      *
    FORM USER_COMMAND_SAMPLE USING UCOMM    LIKE SY-UCOMM
                               SELFIELD TYPE SLIS_SELFIELD.
      CASE UCOMM.
        WHEN 'MSXL'.                       " Export to Excel
         perform set_excel_export.
          CLEAR UCOMM.
        WHEN 'MM03'.
         set parameter id 'MAT' field selfield-value.
         call transaction 'MM03' and skip first screen.
          CLEAR UCOMM.
        WHEN 'BGR1'.
         perform fill_available.
         perform graph_available.
          CLEAR UCOMM.
        WHEN 'DOCU'.
         call function 'Z_HELP' exporting repname = repname.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND
    *&      Form  WRITE_USING_ALV_SAMPLE
    *THIS IS A SAMPLE AND MUST BE WRITTEN DIRECTLY IN THE MAIN PROGRAM
    FORM WRITE_USING_ALV_SAMPLE.
    YOU CAN MERGE WITH A DATA DICTIONARY TABLE USING THIS:
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
          exporting
               i_program_name     = repname
               i_internal_tabname = 'I'
               i_inclname         = repname
          changing
               ct_fieldcat        = fieldtab.
    if sy-subrc <> 0.
       write: 'SY-SUBRC: ', sy-subrc, 'REUSE_ALV_FIELDCATALOG_MERGE'.
    endif.
    OR JUST DISPLAY IT USING THIS:
    call function 'REUSE_ALV_LIST_DISPLAY'
          exporting
               i_callback_program       = repname
               i_callback_pf_status_set = 'PF_STATUS_SET'
               i_callback_user_command  = 'USER_COMMAND'
               i_structure_name         = 'I'
               is_layout                = layout
               it_fieldcat              = fieldtab
               i_default                = 'A'
               i_save                   = g_save
               is_variant               = g_variant
               it_events                = events[]
               is_print                 = prints
          tables
               t_outtab                 = i.
    if sy-subrc <> 0.
       write: 'SY-SUBRC: ', sy-subrc, 'REUSE_ALV_LIST_DISPLAY'.
    endif.
    ENDFORM.                               " WRITE_USING_ALV
    thanks
    mrutyun^

  • Catch a JList event, which JList is in a JTable

    I have got a JTable and in its cells are JLists or JLabels (it depend on data)
    Here is code spinnet:
    DefaultTableCellRenderer ownRenderer = new DefaultTableCellRenderer() {
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    NERecordSet nyers = (NERecordSet)tData.getModel();
    if (nyers.getValueAt(row, column).getClass().getName().equals("com.nextent.corridor.db.NERecordSet")) {
    JList listCell = new JList();
    listCell.setModel((NERecordSet)nyers.getValueAt(row, column));
    listCell.setCellRenderer(ownListCellRenderer);
    listCell.setForeground(Color.BLACK);
    if (isSelected) {
    listCell.setBackground(Color.blue);
    else {
    listCell.setBackground(Color.LIGHT_GRAY);
    return listCell;
    else {
    JLabel lCell = new JLabel();
    lCell.setToolTipText(tooltip);
    return lCell;
    I'd like to catch the event 'click to one of elements of JList' -> How can I do it? (I tried to add an event handler in the renderer (JList.addMouseListener()), but it was wrong)
    other questions: I'd like to add tooltip to the elements of JList, but I can't
    Please help me to solve these problems!
    Thanks!
    rflair

    Try this:
    listCell.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                System.out.println("value changed in JList: " + evt);
    );Good luck!

  • Bug: JList does not always show the right selection

    I have a JList (Navigator model!) on my form which contains the data of a certain view. The view consists of several attributes but the navigator model always only shows the value of one field. The field I have choosen hasn't an unique value but that's no problem for what I want to do with the JList.
    When I select another row in the view object useing it's key the row is selected in the view object (which I can check looking at the primary key attribute of the currently selected row), but in the JList sometimes the wrong row is selected. I noticed that if there is another row with the same value for the visible attribute (in my case an attribute called "name") as the row which is selected in the view object sometimes this wrong row is selected in the JList. This occurs if the wrong row with the same visible value (name) is at a higher position in the list. So it looks like the BC4J framework checks what the value is of the visible attribute of the currently selected row in the view object and used this value to select the first row in the JList that has this value. This doesn't necessarily mean it's the right row!!!
    E.g.
    The initial view object:
    PK | Name
    1 | test
    2 | another test <-- currently selected row
    3 | test
    The initial JList:
    | test |
    | another test | <-- currently selected row
    | test |
    Now I tell the view object that I want to select the row with primary key value "3".
    Now my view object looks like this:
    PK | Name
    1 | test
    2 | another test
    3 | test <-- currently selected row
    But my JList now looks like this:
    | test | <-- currently selected row
    | another test |
    | test |
    I hope this is sufficient information to trace the bug, if not feel free to contact me (by sending a response to this message). I'm useing JDeveloper 9.0.3 preview!
    Regards,
    Peter

    Well, how should the list resolve the difference between two "displayed values" that are same?Well, if I select a certain value in the list the connected record in the ViewObject is selected. In other words the JList seems to know enough about the ViewObject to select the correct record (it doesn't select the first record in the ViewObject with the display value!). So if "it" knows how to do it one way, why not the other way?When you select by index then the object corresponding to that index is selected and that means the right row (if you are able to figure out which row by simply having the knowledge of the row index though even though the displayed values are duplicate - but I won't say that's realistic). The other way, it only has a value - string that it has to match with a set of values in the list and that logic has no clues which of the "duplicate" entries would be the right one.
    To resolve such conflicts you could add another "displayed attribute" in the list which is going to make the attribute-set unique in the list.I did do that already, but then my list becomes read-only (not selectable) because the attribute I added is a primary key attribute which is a DBSequence field what may not be changed once it has been inserted. The weird thing is, you can't change the value when you select it from the list, so why does it behave like this? (In other words why is a list with a read only display attribute also read only? because selecting something in a navigator list doesn't mean something get's changed in the selected attribute value!). I'd chase this one. This definitely sounds like a bug. Readonly-ness should not be derived from "displayed" attributes but "updateable" attributes.

  • ALV OOP- Catching the event when the user clicks a cell

    Hi Experts,
    i have 2 alvs to display using custom containers, now the problem is that i need to make some lines uneditable and some lines editable. On making this i find that ALV does not offer this functionality of selective editable rows, right? I offered a workaround by just popping an error message if a user clicks a row which suppose to be disabled/uneditable. My problem is that how can i catch the single click event in ALV using OOP?
    Thanks to replies and points will be given...

    hi,
    hope this helps.
    creating Editable Cells in ALV
    Making a column editable in ALV:
    IT_FIELDCAT is an internal table which has the structure of the data to be displayed. Each row in this internal table creates a column in ALV. The fieldcat structure has an optional field u2018EDITu2019 which is not required to be passed all the time. By default the column is non-editable. If the value of the field EDIT is u2018Xu2019, that column becomes editable in the display.
    Example:
      wa_fieldcat-fieldname = 'CHECK'.
      wa_fieldcat-edit      = 'X'.
      wa_fieldcat-coltext   = 'Delete'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
    The column DELETE in the ALV display is editable. The corresponding output internal table field name is CHECK.
    Making individual cells editable or non-editable:
    1.     Include an internal table of type lvc_t_styl in the output internal table (as a field) of the ALV. This inner table is like other output fields of the internal table.
    Example:
    TYPES: BEGIN OF tt_project,
                check TYPE c,
                status(132) TYPE c,
                it_styletab TYPE lvc_t_styl.       
    TYPES: END OF tt_project.
    2.     This inner internal table controls the style of each cell in the row of the output internal table.
    3.     Same like other fields of the output internal table, this style table (inner internal table) should be filled for each row of the table.
    4.     The structure of the output internal table.
    CHECK     STATUS     IT_STYLETAB
    X     ABC     Fieldname     Style
    CHECK     Non-editable(MC_STYLE_DISABLED)
    STATUS     editable(MC_STYLE_ENABLED)
         CDF     Fieldname     Style
         Non-editable(MC_STYLE_DISABLED)
          wa_stylerow-fieldname = u2018CHECKu2019. -
    > Optional
          wa_stylerow-style =  cl_gui_alv_grid=>mc_style_disabled. (Non-editable)
          or
          wa_stylerow-style =  cl_gui_alv_grid=>mc_style_enabled.  (Editable)
          Append wa_stylerow to wa_project-it_styletab.
         Wa_stylerow is a work area for IT_STYLETAB.
           Wa_project is work area for output internal table.
    5.     Refresh the inner internal table for each row in outer internal table.
    6.     If the fieldname is not provided for the style internal table, the entire row becomes editable or non-editable.
    7.     This provides the ability to enable input for a cell dynamically.
    8.     The layout of the ALV Grid should also be changed in order to achieve this. The layout has a parameter, u2018STYLENAMEu2019. The name of the style internal table should be given as the value for this field. The layout should be passed in SET_TABLE_FOR_FIRST_DISPLAY.
         Example:
         wa_layout-stylefname = 'IT_STYLETAB'.
    reward if useful.
    regards
    srishti

  • Catching the Record Change Event

    Hello,
    We are currently using SAP 2004, and would like to catch an event when a sap record changes, for example in Item Master Data window when the user clicks on the << < > >> and the Item Number/ Information changes. From what I can tell there is no specific form event that can be caught like on item number text change…
    Any help with this problem would be greatly appreciated
    Thanks

    Hi Bill,
    Unfortunately, there is not a "record change".
    You'll have to catch all the menu event when the user click on the << < > >>
    Private Sub SBO_Application_MenuEvent(pVal As SAPbouiCOM.IMenuEvent, BubbleEvent As Boolean)
          If pVal.BeforeAction = False Then
              Select Case pVal.MenuUID
                Case "1288" 'Next Record
                    oRecordSet.MoveNext
                    '// If reached EOF show last
                    If oRecordSet.EOF = True Then
                        oRecordSet.MoveLast
                    End If
                Case "1289" 'Previous record
                Case "1290" 'First record
                Case "1291" 'Last record
                End Select
            End If
    End Sub

  • Can I select the data of the indexes?

    Hi everybody,
    Oracle storages indexes in index type segments as I know.
    Is it possible to see the data of these index segments like a table or view?
    So I would like to see not only the structue of it with:
    select * from dba_segments SG where SG.segment_name = ’index_name’
    I think something like this:
    For example if I have a table named Table1.
    (please don’t see the format of the rowid):
    Rowid....field1
    1_1.......AA
    1_2.......AB
    1_3.......BB
    and I have an index on field1 named ndx_t1_f1.
    Create index ndx_t1_f1 on Table1(field1);
    I would like to see something like this
    (if it is a simple Btree index like the ndx_t1_f1):
    Select * from some_schema.???ndx_t1_f1???
    Rowid..........ParentRowid..........ValuePrefix..........SolutionRowid
    2_1
    2_11............2_1.......................A
    2_12............2_1.......................B
    2_111..........2_11.....................AA......................1_1
    2_112..........2_11.....................AB......................1_2
    2_121..........2_12.....................BB......................1_3
    And if i run:
    select field1 from table1 where filed1 like 'B%'
    oracle can use ndx_t1_f1 index like this:
    2_1 -> 2_12 -> 2_121 -> BB
    Yes, I know, there are some promlems with this imagine, but is it possible, or is it a silly question?
    Thanx: lados.

    Hi,
    You asked: „Why do you want to do that?”
    Well, I have a table T with fields F1, F2, F3 ...
    If I run:
    select F2, T.* from T where F1=12345;
    the result is one record and the value of F2 is ‘A’.
    But if I run:
    select F2, F1 from T where F1=12345;
    the result is one record and the value of F2 is ‘B’.
    And this is the same record. Oppps!!!!!
    I think the cause of the problem is the next:
    I have an index on F1, F2 named ndx_T_F1_F2
    In the second case: oracle uses only the index blocks and no table blocks, because all asked data exists in the index blocks.
    In the first case: oracle uses the table blocks too, because I asked all field.
    And I think there is a corrupted data on the index.
    I created a new index on (F1,F2,F3), and I suggest to use this.
    select /*+index(T, ndx_T_F1_F2_F3)*/ T.F2 from T where F1=12345;
    the result is one record and the value of F2 is ‘A’.
    But what is strange, oracle didn’t realise this inconsistent situation.
    (It could be an earlier crash, I don’t know, I’m new at this workplace)
    I think, the problem can solve with recreating the index ndx_T_F1_F2.
    But it’s a very special situation for me, and I would like to see the corrupted data concretly with my eyes.
    I think, that
    Select * from some_schema.???ndx_t1_f1???
    would I see like a view, but it would based on procedures and not tables.
    It would be enough to me, because I only could see the data in the index.
    But it is impossible as you wrote, isn’t it?
    Thanx: lados.

  • HOW CAN I DELETE AN EVENT WITHOUT  HAVING TO SELECTING IT FROM THE LIBRARY?

    I have a big problem.
    I want to delete an entire event from my library because everytime I select it imovie freezes and then close itself up. So I have to re-open imovie again. And when I want to select that particular event again the same problem occures. So I can not select that particular event. Therefore I can take NO action on this event.
    HOW CAN I DELETE AN EVENT WITHOUT HAVING TO SELECTING IT FROM THE LIBRARY?
    (Everytime I select it imovie closes itself up)
    All other events work fine. I believe The footage had a problem from capturing. but now it's in my computer and i can't open it.
    Please help me, I don't need this event, I can't open it therefore I can't use it and it takes place on my hardrive for nothing.
    Thank you

    One can delete it from one's computer. In the finder go to homeuser, movies, imovie events, delete the footage.
    Then reopen iMovie and see if that helps.
    Hugh

Maybe you are looking for