Single click in alv grid

Hi friends,
below statement is for double clicking,
WHEN '&IC1'. " SAP standard code for double-clicking, but i need single click because when i select field(not doubble click only single click) in alv grid it has to trigger and perform some action  ,can any one know please tell me.

gwa_fldcat-col_pos       = 2.
  gwa_fldcat-fieldname     = 'CHK'.
  gwa_fldcat-tabname       = 'GT_FINAL'.
gwa_fldcat-EMPHASIZE = 'C310'.
gwa_fldcat-input        = 'X'.
  gwa_fldcat-edit          = 'X'.
  gwa_fldcat-checkbox      = 'X'.
  gwa_fldcat-just          = 'C'.
  gwa_fldcat-key           = 'X'.
  gwa_fldcat-outputlen     = 16.
  gwa_fldcat-seltext_l     = 'Selection'.
  gwa_fldcat-hotspot        = 'X'.
  APPEND gwa_fldcat TO git_fldcat.
  CLEAR gwa_fldcat.
  gs_events-name = 'USER_COMMAND'.
  gs_events-form = 'USER'.
  append gs_events to gi_events.
call function 'REUSE_ALV_GRID_DISPLAY'
   exporting
     i_callback_program                = sy-repid
     i_callback_pf_status_set          = 'PFSTATUS'
     i_callback_user_command           = 'USER'
     I_CALLBACK_TOP_OF_PAGE            = ' '
     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
     I_CALLBACK_HTML_END_OF_LIST       = ' '
     I_STRUCTURE_NAME                  =
     I_BACKGROUND_ID                   = ' '
     I_GRID_TITLE                      =
      I_GRID_SETTINGS                   = wa_grid
     is_layout                         = gs_layout
     it_fieldcat                       = git_fldcat
     IT_EXCLUDING                      =
     IT_SPECIAL_GROUPS                 =
     IT_SORT                           =
     IT_FILTER                         =
     IS_SEL_HIDE                       =
     I_DEFAULT                         = 'X'
     I_SAVE                            = ' '
     IS_VARIANT                        =
     it_events                         = gi_events
     IT_EVENT_EXIT                     =
     IS_PRINT                          =
     IS_REPREP_ID                      =
     I_SCREEN_START_COLUMN             = 0
     I_SCREEN_START_LINE               = 0
     I_SCREEN_END_COLUMN               = 0
     I_SCREEN_END_LINE                 = 0
     IT_ALV_GRAPHICS                   =
     IT_HYPERLINK                      =
     IT_ADD_FIELDCAT                   =
     IT_EXCEPT_QINFO                   =
     I_HTML_HEIGHT_TOP                 =
     I_HTML_HEIGHT_END                 =
IMPORTING
     E_EXIT_CAUSED_BY_CALLER           =
     ES_EXIT_CAUSED_BY_USER            =
tables
     t_outtab                          = gt_final.
  gs_layout-colwidth_optimize = 'X'.
  gs_layout-zebra             = 'X'.
  gs_layout-info_fieldname    = 'COLOR'.
gs_layout-KEY_HOTSPOT       = 'X'.
form user using lv_okcode   like sy-ucomm
                       rs_selfield type slis_selfield.
  lv_okcode = sy-ucomm.
case lv_okcode.
when '&IC1'.
loop at gt_final into gwa_final .
where chk = 'X'.
  if gwa_final-chk is not initial.
gwa_final-color = 'C111' .
modify gt_final from gwa_final
   index sy-tabix transporting color.
clear gwa_final.
endif.
endloop.
encase.
form Grid_settings .
wa_grid-EDT_CLL_CB = 'X'.
endform.

Similar Messages

  • Single click in ALV Grid display

    Hi All,
    I need to trigger an event at the instant when a whole row is selected in ALV.
    Not any HOTSPOT.
    Is there any SY-UCOMM when a single row will be selected in ALV?
    Thanks in advance,
    Tabraiz

    Hi,
    In the below function module:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
       I_INTERFACE_CHECK                 = ' '
       I_BYPASSING_BUFFER                = ' '
       I_BUFFER_ACTIVE                   = ' '
          i_callback_program                = sy-repid
          i_callback_pf_status_set          = 'PF_STATUS'
          i_callback_user_command           = 'COMM'      -->this statement is used to catch the user command actions , i.e a subroutine will be created of this name  
       i_callback_top_of_page            = 'TOP'
       I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
       I_CALLBACK_HTML_END_OF_LIST       = ' '
       I_STRUCTURE_NAME                  =
       I_BACKGROUND_ID                   = ' '
          i_grid_title                      = it_grid_title
       I_GRID_SETTINGS                   =
          is_layout                         = it_layout
          it_fieldcat                       = it_field
       it_excluding                      = itab_exclude
       IT_SPECIAL_GROUPS                 =
          it_sort                           = itab_sort
       IT_FILTER                         =
       IS_SEL_HIDE                       =
       I_DEFAULT                         = ''
        I_SAVE                            = 'A'
        IS_VARIANT                        = SVARIANT
          it_events                         = itab_events
    -->The subroutine created is like:
    FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA: okcode TYPE sy-ucomm.
      okcode = ucomm.
      CASE okcode.
        WHEN 'REF'.
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel         = 'MANSI'
            txt1          = 'CREATED BY'
            txt2          = SY-UNAME
          TXT3          = ' '
          TXT4          = ' '
    endcase.
    Hope it helps you
    Regrds
    Mansi

  • How to handle check box click in ALV grid

    Hi Experts,
    I use ALV grid using FM.
    I have list of delivery note items with one custom field as check-box. When I check the checkbox, all other lines related to the same delivery note should be automaticaly checked.
    Is there any event or function code, where I can handle single click to checkbox?
    Thanks&regards, 
    Jirka

    HI
    you can use following code in user command function .
    DATA :BEGIN OF IT_MAINDATA OCCURS 0,
          MAINDATA(1),
          IT_RD1(1),
    END OF IT_MAINDATA.
    data: V_INDEX TYPE I.
    DESCRIBE TABLE itab LINES LINE.
      DO. " line times.
        READ LINE SY-INDEX FIELD VALUE Iitab-RD1.
        IF SY-SUBRC NE 0. EXIT. ENDIF.
        CHECK V_INDEX > 0.
        CHECK itab-RD1 = 'X'.
        MODIFY itab INDEX V_INDEX.
        IT_MAINDATA-IT_RD1 = Iitab-RD1.
      ENDDO.
    i think is work.
    regards,
    Abhi

  • Regarding single click in alv's

    hi guru's
    i have a small problem.
    iam using a alv grid display. after clicking on the row in alv , i need to navigate to a transaction mm03. 
    My problem is the navigation is happening in double-click. how can i use the single click option.
    my program consists of:
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-repid
          i_structure_name       = l_c_struc
          i_inclname             = sy-repid
        CHANGING
          ct_fieldcat            = fp_l_i_fieldcat
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = sy-cprog
          i_callback_user_command = l_c_user_command
          i_grid_title            = text-004
          is_layout               = fp_wa_layout
          it_fieldcat             = fp_i_fieldcatalog
          i_save                  = l_c_a
          it_events               = fp_i_event
        TABLES
          t_outtab                = fp_i_makt
    FORM at_user_command USING fp_ucom     TYPE sy-ucomm
                               fp_selfield TYPE slis_selfield.  "#EC *
        CASE fp_ucom.
          WHEN '&IC1'.
            READ TABLE i_makt INTO wa_final
                                        INDEX fp_selfield-tabindex.
            IF sy-subrc EQ c_0.
              SET PARAMETER ID 'MAT' FIELD wa_final-matnr.
              CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
            ENDIF.
          WHEN OTHERS.
            MESSAGE i009.
        ENDCASE.
    ENDFORM.                  
    please give me a detailed description as iam new to abap programming.

    HI USE THIS EXAMPLE ,
    use the hot spot for this option.
    *& Report  Z_TEST001
    REPORT  Z_TEST001.
    TYPE-POOLS:  slis.
    tables: rseg.
    DATA: begin of TAB_ARSEG occurs 0.
            INCLUDE STRUCTURE RSEG.
    DATA: END OF TAB_ARSEG.
    DATA: T_FIELDCAT TYPE slis_t_fieldcat_alv.
    DATA: c_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
    START-OF-SELECTION.
    <<<  YOUR CODE  >>> ***********************
    select * from rseg into table tab_arseg .
    END-OF-SELECTION.
    perform build_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
        i_buffer_active                   = space
        i_callback_program                = sy-repid
       I_CALLBACK_USER_COMMAND            = c_user_command
      I_STRUCTURE_NAME                  =
      IS_LAYOUT                         =
       IT_FIELDCAT                        = T_FIELDCAT[]
      TABLES
        T_OUTTAB                          = TAB_ARSEG
    EXCEPTIONS
       PROGRAM_ERROR                      = 1
       OTHERS                             = 2.
    IF SY-SUBRC ne 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    **&      Form  USER_COMMAND
    FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
                    I_SELFIELD TYPE SLIS_SELFIELD.
      DATA: F_SUBRC LIKE SY-SUBRC,
            s_arseg like tab_arseg.
      READ TABLE tab_arseg INDEX i_selfield-tabindex INTO s_arseg.
        CASE F_UCOMM.
            WHEN '&IC1'.
            CASE i_SELFIELD-SEL_TAB_FIELD.
            WHEN 'TAB_ARSEG-BELNR'.
              CHECK NOT S_ARSEG-BELNR IS INITIAL.
              SET PARAMETER ID 'RBN' FIELD S_ARSEG-BELNR.
              SET PARAMETER ID 'GJR' FIELD S_ARSEG-GJAHR.
              CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
            ENDCASE.
        ENDCASE.
    ENDFORM.
    **&      Form  build_fieldcat
    FORM build_fieldcat .
    DATA: FIELDCAT TYPE SLIS_FIELDCAT_ALV.
      CLEAR FIELDCAT.
      FIELDCAT-FIELDNAME     = 'BELNR'.
      FIELDCAT-TABNAME       = 'TAB_ARSEG'.
      FIELDCAT-REF_TABNAME   = 'RSEG'.
      FIELDCAT-REF_FIELDNAME = 'BELNR'.
      fieldcat-hotspot   = 'X'.
      FIELDCAT-COL_POS       = 1.
      APPEND FIELDCAT TO t_fieldcat.
      CLEAR FIELDCAT.
      FIELDCAT-FIELDNAME     = 'GJAHR'.
      FIELDCAT-TABNAME       = 'TAB_ARSEG'.
      FIELDCAT-REF_TABNAME   = 'RSEG'.
      FIELDCAT-REF_FIELDNAME = 'GJAHR'.
      FIELDCAT-COL_POS       = 2.
      APPEND FIELDCAT TO t_fieldcat.
    ENDFORM.                    " build_fieldcat
    REGARDS,
    VENKAT.

  • Double-click in ALV Grid on BDC recording not recorded

    Hi,
    I'm recording a BDC session in a CRM system to enter a business partner.  One of the steps is to choose a marketing attribute.  To do this you have to double click on a (read only) ALV grid to select the attribute.
    When I record this in SHDB or LSMW, the double click is never recorded?
    Anybody else had problems recording a double click in an ALV grid.
    Thanks
    Naidoo

    Unfortunely, BDC and gui controls do not get along.   The ALV_Grid uses a gui control to intereactive with the user.  Doing a recording over these kinds of transaction is not suggested for this very reason.  You will have to find another way to achieve your result.  Is there any BAPI or function module which does this functionality?
    Regards,
    Rich Heilman

  • Double click in alv grid not refreshing until I click elsewhere

    Hello,
    I'm very new to abap and just managed to partly implement double click in an alv grid.
    I also created a button that calls the exact same function as double click (selects the row and fills in the data areas on the page). When I use the button, everything works fine, but when I double click, nothing changes until I click on a tab or other form of input button on the page.
    I have followed the process in debugging and can't find the fault anywhere.
    My double click is implemented by:
               create object lcl_event_receiver.
               set handler lcl_event_receiver->double_click
                    for search_alv_grid.
              endif.
    CLASS lcl_event_handler DEFINITION.
        public section.
        methods:
        double_click         for event double_click
                             of cl_gui_alv_grid.
    ENDCLASS.               "lcl_event_handler
    CLASS lcl_event_handler IMPLEMENTATION.
    *       METHOD double_click                                           *
      method double_click.
      perform select_search_result.
      endmethod.                    "double_click
    ENDCLASS. 
    Any help would be much appreciated

    Hello,
    Try using the template code given below.  Let me know if you have any questions.
    data : GT_EVENTS TYPE SLIS_T_EVENT.
    get event
    PERFORM BUILD_EVENT_TOPOFPAGE USING GT_EVENTS[].
    display alv data
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = W_xxxxx
    IT_FIELDCAT = GT_xxxx
    IT_EVENTS = GT_EVENTS[]
    TABLES
    T_OUTTAB = T_xxxx
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.
    get event perform
    FORM BUILD_EVENT_TOPOFPAGE USING LT_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 = LT_EVENTS.
    Read double click event using the below statement
    READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
    INTO LS_EVENT.
    IF SY-SUBRC = 0.
    ENDIF.
    ENDFORM. " BUILD_EVENT_TOPOFPAGE
    FORM USER_COMMAND USING L_UCOMM LIKE SY-UCOMM
    LS_SELFIELD TYPE SLIS_SELFIELD.
    CASE L_UCOMM.
    WHEN <double click>
        Perform do_something.
    ENDCASE.
    ENDFORM. " USER_COMMAND
    Best Regards,
    Krishna

  • Single selection in ALV Grid Control

    hi,
    I want to enable single row selection only in the alv grid displayed.
    attribute sel_mode of layout doesnt help.
    Can anybody provide me a solution.
    Regards,
    Auro

    Hello,
    Try this:
    DATA:gs_layout type lvc_s_layo.
    gs_layout-NO_ROWMARK = 'X'.
    call method g_grid->set_table_for_first_display
           exporting is_layout             = gs_layout
    Regards,
    Beejal
    **reward if this helps

  • Select single row in ALV grid

    ABAPer's ,
    Does anyone can guide me to select single row only in ALV grid , without OO.

    Hello,
    I did not get u.
    But check the below code it may help u.
    tables: mara.
    TYPE-POOLS: SLIS.
    data:repid like sy-repid.
    data: itb type mara occurs 0 with header line,
    IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV WITH HEADER LINE,
    IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
    ITB1 TYPE MAKT OCCURS 0 WITH HEADER LINE.
    selection-screen begin of block b.
    parameters: p_matnr type matnr.
    selection-screen end of block b.
    select * from mara into table itb where matnr = p_matnr.
    SELECT * FROM MAKT INTO TABLE ITB1 WHERE MATNR = P_MATNR.
    repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
       I_CALLBACK_PROGRAM             = repid
      I_CALLBACK_PF_STATUS_SET       = ' '
       I_CALLBACK_USER_COMMAND        = 'HANDLE_USER_COMMAND'
       I_STRUCTURE_NAME               = 'MARA'
       IS_LAYOUT                      = IT_LAYOUT
       IT_FIELDCAT                    = IT_FIELDCAT[]
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
      IT_EVENTS                      =
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      TABLES
        t_outtab                       = itb
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    FORM HANDLE_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE
    SLIS_SELFIELD.
    CASE R_UCOMM.
    WHEN '&IC1'.
    CLEAR IT_FIELDCAT[].
    IF RS_SELFIELD-FIELDNAME = 'MATNR'.
    READ TABLE ITB1 INDEX RS_SELFIELD-TABINDEX.
    WRITE: / ITB1-MAKTX.
    ENDIF.
    ENDCASE.
    ENDFORM. "HANDLE_USER_COMMAND
    Regards

  • Displaying items in a single line in ALV grid using  ALV_TOP_OF_PAGE.

    Hello Guys,
    I am having a problem in displaying items in a single line in the ALV Grid using event ALV_TOP_OF_PAGE.
    My requirement is to group items on a single line i.e. in the example below, Vendor code and posting date are on the same line. The next line the prints Vendor Name and Document no.
    Vendor Code: 123123                               Posting Date : 01.01.2011
    Vendor Name: ABCD                                 Document No: 152246598.
    Here is my code in subroutine 'ALV_TOP_OF_PAGE', 
      wa_list_comments-typ = 'S'. 
      wa_list_comments-key = ''.
      wa_list_comments-info = 'Vendor Code'.
      APPEND wa_list_comments TO it_list_comments.
      wa_list_comments-typ = 'S'. 
      wa_list_comments-key = ''.
      wa_list_comments-info = 'Posting Date'.
      APPEND wa_list_comments TO it_list_comments.
    The above code prints in the following format i.e one below the other,
    Vendor Code: 123123                              
    Posting Date : 01.01.2011.
    I also tried using HTML_TOP_OF_PAGE, but it didn't work.
    Can anybody please help me out with this.
    Regards,
    Danish.

    Hi Danish,
    Your problem is with the alignment and you need some fix positions .
    The solution i feel is u can use as below :
    In CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    use 
    i_callback_html_top_of_page       = 'HTML_TOP_OF_PAGE'.
    Now on calling routine call use cl_dd_document class :
    FORM html_top_of_page USING document TYPE REF TO cl_dd_document .
    data : doctable TYPE REF TO cl_dd_table_element,
              col1_t1 TYPE REF TO cl_dd_area,
              col2_t1 TYPE REF TO cl_dd_area,
              col1_t2 TYPE REF TO cl_dd_area,
              col2_t2 TYPE REF TO cl_dd_area.
    add quick table with five columns
        CALL METHOD lw_document->add_table
          EXPORTING
            no_of_columns               = 2
            border                      = '0'
         cell_background_transparent = ' '
            width                       = '100%'
          IMPORTING
            table                       = doctable.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '40%'
          IMPORTING
            column = col1_t1.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '60%'
          IMPORTING
            column = col2_t1.* Filling columns in row
    Call method doctable->new_row.
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '40%'
          IMPORTING
            column = col1_t2.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '60%'
          IMPORTING
            column = col2_t2.
    *Now adding the texts
    lw_text1 = 'your first text'
    CALL METHOD col1_t1->add_text
          EXPORTING
            text = lw_text.
    *Similarly add text for other columns
    *Adujust % in width to adjust the column as required
    Endform.
    Hope this will solve your problem .

  • How to Open new screen for single click on ALV icon.

    Hi All,
    Can any body help me regarding the below ALV requirement.
    I need to create a executable program ZPROGRAM with a table having field to store long text.The ALV report should display records according to the selection screen parameters with a icon in each record when clicked should open a new screen with present data in the field and must be able to save the entered long text.
    Can any body give me the idea after displaying the simple ALV in the output,
    How to open new screen(not the Pop-up’s) after single click on the icon,
    in that I should be able to modify & save the long text in my ZTABLE and
    able to retrieve the same text for single clicked icon record.
    which function modules/Classes/Methods can we use for this requirement.
    And how retrieve the same text for this record.
    Thanks in advance.
    Regards,
    Kalam A.

    *& Report  ZTEST_ALV
    REPORT  ZTEST_ALV.
    TYPE-POOLS slis.
    DATA: gt_fieldcat TYPE TABLE OF slis_fieldcat_alv .
    DATA: gs_layout  TYPE slis_layout_alv.
    DATA: gt_list_top_of_page TYPE slis_t_listheader.
    DATA: gt_sortinfo_alv   TYPE  slis_t_sortinfo_alv.
    DATA: gs_print_alv TYPE slis_print_alv.
    DATA: gs_grid TYPE lvc_s_glay.
    DATA: gt_event TYPE slis_t_event.
    DATA: gs_event TYPE slis_alv_event.
    DATA: BEGIN OF GT_DISPLAY OCCURS 100.
       INCLUDE STRUCTURE MARA.
       DATA: BOX.
    DATA: END OF GT_DISPLAY.
    START-OF-SELECTION.
    SELECT * FROM MARA UP TO 50 ROWS
      INTO CORRESPONDING FIELDS OF TABLE GT_DISPLAY.
    End-of-Selection.
      PERFORM build_alv.
      PERFORM display_screen .
    FORM build_alv .
      DATA: ls_fieldcat LIKE LINE OF gt_fieldcat.
      DATA: ls_top TYPE LINE OF slis_t_listheader.
      DATA: ls_sort TYPE slis_sortinfo_alv.
      CLEAR: ls_fieldcat, gt_fieldcat[], ls_top,gt_list_top_of_page[],
             ls_sort,gs_grid,gs_print_alv,gt_sortinfo_alv[].
    *&-----gs_layout definition.
    gs_layout-zebra = 'X'.
    gs_layout-detail_popup = 'X'.          "ÊÇ·ñµ¯³öÏêϸÐÅÏ¢´°¿Ú
    gs_layout-f2code = '&ETA'.             "ÉèÖô¥·¢µ¯³öÏêϸÐÅÏ¢´°¿ÚµÄ¹¦ÄÜÂë,ÕâÀïÊÇË«»÷
      gs_layout-no_vline = ' '.              "ÉèÖÃÁмä¸ôÏß
      gs_layout-colwidth_optimize = 'X'.     "ÓÅ»¯Áпí
      gs_layout-detail_initial_lines = 'X'.
    gs_layout-coltab_fieldname = 'LINE_COLOR'. "Line_colorΪgt_displayµÄÒ»¸ö×Ö¶Î,¾ßÌåÑÕÉ«ÉèÖüûÏÂÃæ˵Ã÷.
      gs_layout-hotspot_fieldname = 'MATNR'.
    gs_layout-detail_titlebar = 'ÏêϸÄÚÈÝ'. "ÉèÖõ¯³ö´°¿ÚµÄ±êÌâÀ¸
    gs_layout-group_change_edit = 'X'.
    *&-----gs_grid definition.
      gs_grid-top_p_only = 'X'.
    *&-----gs_print_alv definition.
      gs_print_alv-prnt_title = 'X'.
      gs_print_alv-prnt_info = 'X'.
    *&-----gt_sortinfo_alv definition. С¼Æ
      ls_sort-fieldname = 'MTART'.
      ls_sort-tabname =  'GT_DISPLAY'.
      ls_sort-subtot = 'X'.
      ls_sort-spos      = 1.
      ls_sort-up        = 'X'.
    ls_sort-group = 'UL'.
      APPEND ls_sort TO gt_sortinfo_alv.
      ls_sort-fieldname = 'AENAM'.
      ls_sort-tabname =  'GT_DISPLAY'.
      ls_sort-subtot = 'X'.
      ls_sort-spos      = 1.
      ls_sort-up        = 'X'.
    ls_sort-group = 'UL'.
      APPEND ls_sort TO gt_sortinfo_alv.
    *&-----slis_t_listheader definition. title.
      CLEAR  ls_top.
      ls_top-key  = 'µ±Ç°ÈÕÆÚ:'.
      ls_top-typ  = 'S'.  " H = Header, S = Selection, A = Action
      CONCATENATE  sy-datum0(4)   '-' sy-datum4(2) '-' sy-datum+6(2) INTO ls_top-info .
      APPEND ls_top TO gt_list_top_of_page.
      CLEAR  ls_top.
      ls_top-key  = 'title'.
      ls_top-typ  = 'S'.  " H = Header, S = Selection, A = Action
      ls_top-info = space.
      APPEND ls_top TO gt_list_top_of_page.
    *&-----gs_print_alv definition.
      gs_print_alv-prnt_title = 'X'.
      gs_print_alv-prnt_info = 'X'.
    *&-----gt_fieldcat definition.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         i_program_name     = sy-repid
         i_internal_tabname = 'GT_DISPLAY'
          i_structure_name = 'MARA'
          I_CLIENT_NEVER_DISPLAY = 'X'
         i_inclname         = sy-repid
       CHANGING
         ct_fieldcat        = gt_fieldcat[]
       EXCEPTIONS
         inconsistent_interface = 1
         program_error          = 2
         OTHERS                 = 3.
      ls_fieldcat-hotspot = 'X'.
      MODIFY gt_fieldcat FROM ls_fieldcat INDEX 2.
    **-1. definition with macro.
      DEFINE macro.
       col_pos = col_pos + 1.
       ls_fieldcat-tabname   = 'it_typ_data'.
        ls_fieldcat-fieldname = '&1'.
        ls_fieldcat-seltext_l =  &2.
       ls_fieldcat-col_pos   =  col_pos.
        ls_fieldcat-outputlen =  '&3'.
       ls_fieldcat-datatype  =  '&4'.
       ls_fieldcat-do_sum    =  &5.
       ls_fieldcat-edit    =   &6.
       ls_fieldcat-checkbox  =   &7.
       ls_fieldcat-key   =   &9.
       ls_fieldcat-fix_column =  &10.
       ls_fieldcat-no_out =  &11.
        ls_fieldcat-ref_fieldname = &4.    " System F4 Effect.
        ls_fieldcat-ref_tabname   =  &5.   " System F4 Effect.
        ls_fieldcat-hotspot   =   &6.
        append ls_fieldcat to gt_fieldcat.
        clear ls_fieldcat.
      END-OF-DEFINITION.
      macro matnr     'matnr'            18   'MATNR'   'MARA'  'X'.
      macro MTART     'MTART'            18      'MTART' 'MARA'  ''.
      macro  AENAM    'AENAM'            18       'MAENAM'  'MARA'   ''.
    **-2. definition one-by-one.
    CLEAR ls_fieldcat.
    ls_fieldcat-fieldname = 'MATNR'.
    ls_fieldcat-seltext_s = 'ÎïÁÏ'.
    ls_fieldcat-ref_fieldname = 'ROLLNAME'.
    ls_fieldcat-ref_tabname   =  'DD03L'.
    APPEND ls_fieldcat TO gt_fieldcat.
    ENDFORM.                    "build_alv
    FORM display_screen .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type     = 0
       IMPORTING
         et_events       = gt_event
       EXCEPTIONS
         list_type_wrong = 1
         OTHERS          = 2.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ TABLE gt_event INTO gs_event WITH KEY name = 'TOP_OF_PAGE'.
    IF sy-subrc EQ 0.
       gs_event-form = 'TOP_OF_PAGE'.
       MODIFY gt_event FROM gs_event INDEX sy-tabix.
    ENDIF.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = sy-repid
        i_callback_pf_status_set          = 'PF_STATUS_SET '
         i_callback_user_command           = 'USER_COMMAND'
        i_callback_top_of_page            = 'TOP_OF_PAGE'
       I_CALLBACK_HTML_TOP_OF_PAGE       = 'HTML_TOP_OF_PAGE'
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
        I_BACKGROUND_ID                   = 'ALV_BACKGROUND'    "When top-of-page is initial.
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
         is_layout                         = gs_layout
         it_fieldcat                       = gt_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
        it_sort                           =  gt_sortinfo_alv[]
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
       I_SAVE                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         = gt_event
      IT_EVENT_EXIT                     =
       IS_PRINT                          = gs_print_alv
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = gt_display
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "display_screen
    FORM user_command          USING ucomm LIKE sy-ucomm
                               selfield TYPE slis_selfield.
    Data ref1 type ref to cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' "Check Box need fieldcat-checkbox, input and edit.
         IMPORTING
           E_GRID = ref1.
      CASE ucomm.
        WHEN '&IC1'. " SAP standard code for double-clicking
    READ TABLE gt_display INTO gs_display INDEX  slis_selfield-tabindex.
    CHECK sy-subrc = 0.
         CASE  selfield-fieldname  .
           WHEN 'PLNUM'.
             SET PARAMETER ID 'PAF' FIELD gs_display-plnum.
             CALL TRANSACTION 'MD12' AND SKIP FIRST SCREEN.
           WHEN  'POSNR'.
           SUBMIT  rvscd100 USING SELECTION-SCREEN '1000' WITH vbeln = gs_display-vbeln
                                                          WITH posnr = gs_display-posnr
                                                          WITH zinfo = 'X'
                                                          AND RETURN.
         ENDCASE.
       IF selfield-sel_tab_field = 'OUT_ITAB-PI_SL'. " Line detail.
           READ TABLE i_output INTO pisl_itab INDEX selfield-tabindex.
           IF sy-subrc EQ 0.
       ENDIF.
        WHEN 'CHANGE'.
         CALL METHOD ref1->check_changed_data.
         CALL METHOD ref1->refresh_table_display.
    *5´Ë´¦´úÂë×èÖ¹'REUSE_ALV_GRID_DISPLAY´´½¨ÐµÄÆÁÄ»£¬Ôì³ÉÆÁÄ»¶à²ã
         selfield-refresh = 'X'.
        WHEN 'SWITCH'.
         PERFORM switch_edit_mode.
        WHEN OTHERS.
      ENDCASE.
    ENDFORM.                    "user_command
    Add your code in user_command form.
    WHEN you click matnr ucomm eq '&IC1'.
    Message was edited by:
            Chunhai Hu

  • Handling  single click in alv tree

    Hello Friends,
    Is there an event triggered,for single click on an alv tree.
    regards
    kaushik

    hi ,
    it_fieldcat-hotspot = 'X'.
    regards,
    venkat.
    Edited by: venkat  appikonda on Mar 13, 2008 8:11 PM
    Edited by: venkat  appikonda on Mar 13, 2008 8:12 PM

  • Double Click on ALV Grid

    Hi,
    I have this doubt regarding ALV grid display.
    I am displaying a list using REUSE_ALV_GRID_DISPLAY.
    I need to go to a transaction when i double click on a particular line on the output list based on the content of the 1st cell of that line. (ie if i have 4 columns and 5 records and click on the 3rd column of 2nd record then i need to know the value of the 1st field of the 2nd record)
    I am using a call back user command subroutine to capture the index and the field which has been clicked upon. This index is giving perfect result by which I am reading the output table and doing the later operations.
    But what if i sort the list in ALV by any column? Then the index that I will get on double clicking will correspond to the index on the screen but not to the index on my internal output table. In that case I will get a wrong value of the 1st field.
    I do not want to use OO alv. Is there a way to handle this situation?
    Regards,
    Shinjan

    Hello Shinjan,
    When i display an output table say t_out on ALV GRID, the records in the table shown on the grid is identical to what i have in t_out. Hence the tabindex will correspond to that very record in t_out.
    But when i sort the table on the grid, the order of the rows changes... so for example a row which had index 2 will now have an index 6 (say). So on clicking this record, the tabindex will be 6 where as the same record exist in 2nd position in t_out. How to handle this?
    {quote]
    Did you try this scenario? Your output table t_out also gets refarranged after SORT. Good thing is you DONOT have to code anything for this )
    As per your example the table t_out will be rearranged so that the initial 2nd record will be at 6th posn.
    FORM f_user_command  USING   fp_v_ucomm   TYPE syucomm
                                 fp_selfield  TYPE slis_selfield."#EC CALLED
      CONSTANTS:
              l_c_ic1           TYPE char4 VALUE '&IC1',
              l_c_vl            TYPE char2 VALUE 'VL',
              l_c_vl03n         TYPE char5 VALUE 'VL03N'.
      CASE fp_v_ucomm.
    * Ok code for double code
        WHEN l_c_ic1.
          IF fp_selfield-tabindex NE space.
            READ TABLE it_final INTO wa_final           "it_final gets rearranged as per the SORT condition
                                   INDEX fp_selfield-tabindex. "tabindex keeps the correct index after SORT
            SET PARAMETER ID l_c_vl FIELD wa_final-vbeln.
            CALL TRANSACTION l_c_vl03n AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "f_user_command
    Please check & let us know.
    BR,
    Suhas
    Edited by: Suhas Saha on Jan 2, 2009 11:48 AM
    Edited by: Suhas Saha on Jan 2, 2009 11:53 AM

  • Double-click in ALV grid should take to BSP application

    Hi,
    In the portals, in an application, R/3 ALV grid is displayed. On double clicking one of the entries in the list, corresponding transaction in R/3 is opened and the details are displayed. Now, instead of opening the transaction in R/3, Corresponding PCUI application has to be opened. Is it possible to do it Portals? Can you please tell me how this can be acheived?
    Thanks & Regards
    G.Raja
    P.S:- I'm not sure whether this topic can be discussed in this forum. Since the functionality is required in Portals, I'm putting it here.

    Hello G.Raja,
    I think we should connect the Topics:
    <a href="https://forums.sdn.sap.com/thread.jspa?threadID=70688">Calling PCUI application on clicking ALV grid in portals</a> by a link.
    Regards
    Gregor

  • Modifying single cell in ALV Grid via OO

    Hi All,
    Got a problem I hope someone can assist me with.  I have a custom program generating an editable ALV grid.  The users want to update a single cell in a row with value from a custom drop down.  I've got the dropdown working, but I can't work out how to get the value back into the field.  My attempts result in a 'GETWA_NOT_ASSIGNED' short dump.
    I'm using the CL_GUI_ALV_GRID->get_selected_cells_id method to get the reference for the field to be modified, but I don't know where to go from here. 
    Any thoughts would be greatly appreciated.  Btw, my knowledge of OO is passable, but not great, so any explanations of what the code is doing in a proposed solution would be greatly appreciated.
    points will be rewarded.
    Cheers,
    Stephen

    Hello Stephen
    Since your dropdown list restrict the already allowed values there should be no special need to validate the selected values.
    Simply "grab" the data from the editable ALV into your internal itab in the ABAP report.
    I have copied sample report BCALV_EDIT_07 into ZUS_SDN_BCALV_EDIT_07 and modified the report to show how to retrieve the dropdown values (which is simple). Please note that I added the GUI-function 'SAVE' to the GUI-status MAIN100.
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      "$TMP
      g_grid->check_changed_data( ). " retrieve changes from editable grid
      CASE save_ok.
        WHEN 'EXIT'.
          PERFORM exit_program.
        "$TMP
        WHEN 'SAVE'.
          PERFORM save_data.
        WHEN OTHERS.
    *     do nothing
      ENDCASE.
    ENDMODULE.                    "pai INPUT
    *&      Form  SAVE_DATA
    *       text
    FORM save_data.  "$TMP
    * define local data
      data: ls_fcat   type lvc_s_fcat,
            lt_fcat   type lvc_t_fcat.
      lt_fcat = gt_fieldcat.
      ls_fcat-edit = ' '.
      modify lt_fcat from ls_fcat
          TRANSPORTING edit
        where ( edit = 'X' ).  " display ALV should be not editable
      " Simulate saving of data
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                =
    *     I_BUFFER_ACTIVE                   =
    *     I_CALLBACK_PROGRAM                = ' '
    *     I_CALLBACK_PF_STATUS_SET          = ' '
    *     I_CALLBACK_USER_COMMAND           = ' '
    *     I_CALLBACK_TOP_OF_PAGE            = ' '
    *     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *     I_CALLBACK_HTML_END_OF_LIST       = ' '
    *     I_STRUCTURE_NAME                  =
    *     I_BACKGROUND_ID                   = ' '
          I_GRID_TITLE                      = 'Display modified list data'
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT_LVC                     =
          IT_FIELDCAT_LVC                   = lt_fcat
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS_LVC             =
    *     IT_SORT_LVC                       =
    *     IT_FILTER_LVC                     =
    *     IT_HYPERLINK                      =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
    *     I_SAVE                            = ' '
    *     IS_VARIANT                        =
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT_LVC                      =
    *     IS_REPREP_ID_LVC                  =
          I_SCREEN_START_COLUMN             = 5
          I_SCREEN_START_LINE               = 5
          I_SCREEN_END_COLUMN               = 120
          I_SCREEN_END_LINE                 = 20
    *     I_HTML_HEIGHT_TOP                 =
    *     I_HTML_HEIGHT_END                 =
    *     IT_EXCEPT_QINFO_LVC               =
    *     IR_SALV_FULLSCREEN_ADAPTER        =
        TABLES
          t_outtab                          = gt_outtab
        EXCEPTIONS
          PROGRAM_ERROR                     = 1
          OTHERS                            = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "SAVE_DATA
    And here is the entire coding: In order to find the modified parts of the coding simply search for $TMP.
    PROGRAM zus_sdn_bcalv_edit_07.
    * Purpose:
    * ~~~~~~~~
    * This example shows how to define dropdown listboxes for
    * particular cells of your output table.
    * To check program behavior
    * ~~~~~~~~~~~~~~~~~~~~~~~~~
    * Conceive that customers are only allowed to smoke in the
    * first class. For this reason, if the customer is a smoker
    * only the first class (F) can be chosen in column 'CLASS',
    * otherwise all classes.
    * Essential steps (search for '§')
    * ~~~~~~~~~~~~~~~
    * 1.Define an extra field in your output table
    * 2.Define a dropdown table and pass it to ALV.
    * 3.Set your dropdown field editable and assign the fieldname of the
    *   corresponding additional field to DRDN_FIELD of the fieldcatalog.
    * 4.Set the handle of your additional field of your output
    *   table according to the listbox that shall be displayed.
    DATA: ok_code LIKE sy-ucomm,
          save_ok LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
          g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gt_fieldcat TYPE lvc_t_fcat,
          gs_layout TYPE lvc_s_layo,
          g_max TYPE i VALUE 100.
    *§1.Define an extra field in your output table
    *   for each column where you want to use drop down listboxes.
    *   (One additional field refers to cells of one column).
    DATA: BEGIN OF gt_outtab OCCURS 0.
            INCLUDE STRUCTURE sbook.
    DATA: drop_down_handle TYPE int4.
    DATA: END OF gt_outtab.
    *       MAIN                                                          *
    END-OF-SELECTION.
      CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF g_custom_container IS INITIAL.
        PERFORM create_and_init_alv CHANGING gt_outtab[]
                                             gt_fieldcat.
      ENDIF.
    ENDMODULE.                    "pbo OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      "$TMP
      g_grid->check_changed_data( ). " retrieve changes from editable grid
      CASE save_ok.
        WHEN 'EXIT'.
          PERFORM exit_program.
        "$TMP
        WHEN 'SAVE'.
          PERFORM save_data.
        WHEN OTHERS.
    *     do nothing
      ENDCASE.
    ENDMODULE.                    "pai INPUT
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      LEAVE PROGRAM.
    ENDFORM.                    "exit_program
    *&      Form  SAVE_DATA
    *       text
    FORM save_data.  "$TMP
    * define local data
      data: ls_fcat   type lvc_s_fcat,
            lt_fcat   type lvc_t_fcat.
      lt_fcat = gt_fieldcat.
      ls_fcat-edit = ' '.
      modify lt_fcat from ls_fcat
          TRANSPORTING edit
        where ( edit = 'X' ).  " display ALV should be not editable
      " Simulate saving of data
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                =
    *     I_BUFFER_ACTIVE                   =
    *     I_CALLBACK_PROGRAM                = ' '
    *     I_CALLBACK_PF_STATUS_SET          = ' '
    *     I_CALLBACK_USER_COMMAND           = ' '
    *     I_CALLBACK_TOP_OF_PAGE            = ' '
    *     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *     I_CALLBACK_HTML_END_OF_LIST       = ' '
    *     I_STRUCTURE_NAME                  =
    *     I_BACKGROUND_ID                   = ' '
          I_GRID_TITLE                      = 'Display modified list data'
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT_LVC                     =
          IT_FIELDCAT_LVC                   = lt_fcat
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS_LVC             =
    *     IT_SORT_LVC                       =
    *     IT_FILTER_LVC                     =
    *     IT_HYPERLINK                      =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
    *     I_SAVE                            = ' '
    *     IS_VARIANT                        =
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT_LVC                      =
    *     IS_REPREP_ID_LVC                  =
          I_SCREEN_START_COLUMN             = 5
          I_SCREEN_START_LINE               = 5
          I_SCREEN_END_COLUMN               = 120
          I_SCREEN_END_LINE                 = 20
    *     I_HTML_HEIGHT_TOP                 =
    *     I_HTML_HEIGHT_END                 =
    *     IT_EXCEPT_QINFO_LVC               =
    *     IR_SALV_FULLSCREEN_ADAPTER        =
        TABLES
          t_outtab                          = gt_outtab
        EXCEPTIONS
          PROGRAM_ERROR                     = 1
          OTHERS                            = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "SAVE_DATA
    *&      Form  BUILD_FIELDCAT
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'SBOOK'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
      LOOP AT pt_fieldcat INTO ls_fcat.
    * Exchange smoker field with invoice field - just to
    * make the dependance between SMOKER and CLASS more transparent
    * (Smoking is only allowed in the first class).
        IF ls_fcat-fieldname EQ 'SMOKER'.
          ls_fcat-col_pos = 11.
          ls_fcat-outputlen = 10.
          MODIFY pt_fieldcat FROM ls_fcat.
        ELSEIF ls_fcat-fieldname EQ 'INVOICE'.
          ls_fcat-col_pos = 7.
          MODIFY pt_fieldcat FROM ls_fcat.
        ELSEIF    ls_fcat-fieldname EQ 'CLASS'.
    *§3.Set your dropdown field editable and assign the fieldname of the
    *   corresponding additional field to DRDN_FIELD of the fieldcatalog.
          ls_fcat-edit = 'X'.
          ls_fcat-drdn_field = 'DROP_DOWN_HANDLE'.
          ls_fcat-outputlen = 5.
    * Field 'checktable' is set to avoid shortdumps that are caused
    * by inconsistend data in check tables. You may comment this out
    * when the test data of the flight model is consistent in your system.
          ls_fcat-checktable = '!'.        "do not check foreign keys
          MODIFY pt_fieldcat FROM ls_fcat.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    *      <--P_GT_OUTTAB  text
    *      <--P_GT_FIELDCAT  text
    *      <--P_GS_LAYOUT  text
    FORM create_and_init_alv CHANGING pt_outtab TYPE STANDARD TABLE
                                      pt_fieldcat TYPE lvc_t_fcat.
      DATA: lt_exclude TYPE ui_functions.
      CREATE OBJECT g_custom_container
        EXPORTING
          container_name = g_container.
      CREATE OBJECT g_grid
        EXPORTING
          i_parent = g_custom_container.
      PERFORM build_fieldcat CHANGING pt_fieldcat.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM exclude_tb_functions CHANGING lt_exclude.
      PERFORM set_drdn_table.
      PERFORM build_data CHANGING pt_outtab.
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          it_toolbar_excluding = lt_exclude
        CHANGING
          it_fieldcatalog      = pt_fieldcat
          it_outtab            = pt_outtab[].
    * Set editable cells to ready for input initially
      CALL METHOD g_grid->set_ready_for_input
        EXPORTING
          i_ready_for_input = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      <--P_LT_EXCLUDE  text
    FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
      APPEND ls_exclude TO pt_exclude.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  set_drdn_table
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_drdn_table.
    *§2.Define a dropdown table and pass it to ALV.
    *   One listbox is referenced by a handle, e.g., '1'.
    *   For each entry that shall appear in this listbox
    *   you have to append a line to the dropdown table
    *   with handle '1'.
    *   This handle can be assigned to several columns
    *   of the output table using the field catalog.
      DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = 'F'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = 'F'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = 'C'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = 'Y'.
      APPEND ls_dropdown TO lt_dropdown.
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    ENDFORM.                               " set_drdn_table
    *&      Form  build_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_data CHANGING pt_outtab TYPE STANDARD TABLE.
      DATA: lt_sbook TYPE TABLE OF sbook,
            ls_sbook TYPE sbook,
            l_index TYPE i,
            ls_outtab LIKE LINE OF gt_outtab.
      SELECT * FROM sbook INTO TABLE lt_sbook UP TO g_max ROWS."#EC CI_NOWHERE
      IF sy-subrc NE 0.
        PERFORM generate_entries CHANGING lt_sbook.
      ENDIF.
    *§4.Set the handle of your additional field of your output
    *   table according to the listbox that shall be displayed.
      LOOP AT lt_sbook INTO ls_sbook.
        l_index = sy-tabix.
        MOVE-CORRESPONDING ls_sbook TO ls_outtab.
        CLEAR ls_outtab-class.
    * Alternate between smoker and non smoker to make
    * it more obvious what this example is about
        l_index = l_index MOD 2.
        IF l_index EQ 1.
          ls_outtab-smoker = 'X'.
        ELSE.
          ls_outtab-smoker = ' '.
        ENDIF.
        IF ls_outtab-smoker EQ 'X'.
          ls_outtab-drop_down_handle = '1'.
        ELSE.
          ls_outtab-drop_down_handle = '2'.
        ENDIF.
        APPEND ls_outtab TO pt_outtab.
      ENDLOOP.
    ENDFORM.                               " build_data
    *&      Form  generate_entries
    *       text
    *      <--P_LT_SLFIGHT  text
    FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
      DATA: ls_sbook TYPE sbook,
            l_month(2) TYPE c,
            l_day(2) TYPE c,
            l_date(8) TYPE c,
      l_prebookid TYPE i.
      ls_sbook-carrid = 'LH'.
      ls_sbook-connid = '0400'.
      ls_sbook-forcurkey = 'DEM'.
      ls_sbook-loccurkey = 'USD'.
      ls_sbook-custtype = 'B'.
      DO 110 TIMES.
        l_prebookid = sy-index.
        ls_sbook-forcuram = sy-index * 10.
        ls_sbook-loccuram = ls_sbook-loccuram * 2.
        ls_sbook-customid = sy-index.
        ls_sbook-counter = 18.
        ls_sbook-agencynum = 11.
        l_month = sy-index / 10 + 1.
        DO 2 TIMES.
          l_day = 3 + l_month + sy-index * 2.
          l_date+0(4) = '2000'.
          l_date+4(2) = l_month.
          l_date+6(2) = l_day.
          ls_sbook-fldate = l_date.
          SUBTRACT 3 FROM l_day.
          ls_sbook-order_date+0(6) = l_date+0(6).
          ls_sbook-order_date+6(2) = l_day.
          ls_sbook-bookid = l_prebookid * 2 + sy-index.
          IF sy-index EQ 1.
            ls_sbook-smoker = 'X'.
          ELSE.
            ls_sbook-smoker = space.
          ENDIF.
          ls_sbook-luggweight = l_prebookid * 10.
          IF ls_sbook-luggweight GE 1000.
            ls_sbook-wunit = 'G'.
            ls_sbook-class = 'C'.
          ELSE.
            ls_sbook-wunit = 'KG'.
            ls_sbook-class = 'Y'.
          ENDIF.
          IF ls_sbook-bookid > 40 AND ls_sbook-wunit EQ 'KG'.
            ls_sbook-invoice = 'X'.
          ENDIF.
          IF ls_sbook-bookid EQ 2.
            ls_sbook-cancelled = 'X'.
            ls_sbook-class = 'F'.
          ENDIF.
          APPEND ls_sbook TO pt_sbook.
        ENDDO.
      ENDDO.
    ENDFORM.                               " generate_entries
    Regards
      Uwe

  • How to handle double click on alv grid

    When I want to double click on a row of the alv grid, I want to give a message or redirecting the user to the row details screen..
    I wait for your helps.
    Thanks alot.

    Hello,
    Check this report:
    FORM ALV_DISPLAY.
    *--- ALV List Display
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM          = G_PROGNAME
                I_CALLBACK_USER_COMMAND    = G_CALLBACK_USER_COMMAND
                IT_FIELDCAT                 = G_T_FIELDCAT
    *            IT_EVENTS                   = IT_EVENTS
           TABLES
                T_OUTTAB                    = G_T_OUTTAB
           EXCEPTIONS
                PROGRAM_ERROR               = 1
                OTHERS                      = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " ALV_DISPLAY
    *&      Form  F_USER_COMMAND_ALV
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM F_ALV_USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                                  RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
    *--- Hotspot selektion
          CASE RS_SELFIELD-FIELDNAME.
            WHEN 'POSID'.
    *------ PSP-Element
    *-------- Click auf PSP Element -> PSP Element anzeigen (CJ12)
              SET PARAMETER ID 'PSP' FIELD SPACE.
              SET PARAMETER ID 'PRO' FIELD RS_SELFIELD-VALUE.
              CALL TRANSACTION 'CJ12' AND SKIP FIRST SCREEN.
            WHEN 'STTXT_INT'.
    *------ Systemstatus
              G_STTXT_INT = RS_SELFIELD-VALUE.
    *-------- G_T_LEGENDE erfüllen
              PERFORM F_FILL_G_T_LEGENDE_INT.
              G_R_LAYOUT-WINDOW_TITLEBAR = 'Systemstatus'(004).
              PERFORM F_STATUS_LEGENDE_POPUP.
            WHEN 'STTXT_EXT'.
    *------ Anwenderstatus
              G_STTXT_EXT = RS_SELFIELD-VALUE.
    *-------- G_T_LEGENDE erfüllen
              PERFORM F_FILL_G_T_LEGENDE_EXT.
              G_R_LAYOUT-WINDOW_TITLEBAR = 'Anwenderstatus'(005).
              PERFORM F_STATUS_LEGENDE_POPUP.
          ENDCASE.
      ENDCASE.
    ENDFORM. "F_USER_COMMAND_ALV
    IF useful reward.
    Vasanth

Maybe you are looking for

  • Idoc to idoc xml specification example

    Hi,    I am a ABAP developer and have received a requirement for Writing Interface Specification. The requirement is as follows: There are 3 outbound master data idocs MATMAS,DEBMAS & BATMAS which need to be sent from SAP (client) to XI to Warehouse.

  • Change the Default_Where in 9iDS

    I want to execute this code in the trigger "WHEN-BUTTON-PRESSED": DECLARE      item_value varchar2(30);      where_clause varchar2(30); BEGIN      item_value:='12';      where_clause := 'where type='''||item_value||'''';           set_block_property(

  • How to use SearchService WSDL of IPM in Bpel

    Hi All, I am using Search Service WSDL in my bpel to execute the saved search in IPM, but how do i map my input type variable to the search argument of that Search Service. For eg :- If i need to get the saved search associated with the argument as I

  • Setting Things up on a Power Mac G5

    I'm a newbie to server administration, and would like to do the following: 1) I have a Power Mac G5 with two internal hard drives. I want to dedicate one of the hard drives to Apple OS X Server. How do I go about doing this? 2) Once I have the second

  • Custom Charting Objects in OBIEE 10g

    Hi , Has any one ever used their custom charting objects , meaning something other than the gauges , meaning custom images and built charts on or around them.I am using OBIEE 10.3.1.4. Thank you