ALV diaply : hotspot event

Hi ,
     I am using CL_GUI_ALV_GRID for displaying data in ALV grid format.
Lets say my data is displyed as under the following fields :
EQUNR   AB             BIS
000001  21012001       21022002
000002  21012001       21022002
When I click on EQUNR '000001'.
It should again display the following information in a separate ALV grid display.
EQUNR    DEVLOC MATNR
000001   0012   MAT1
I am using hotspot event of ALV and on click I would like to fetch EQUNR to display the next ALV information.
How do I get the value of the current cell , in this case '000001' when I click on value '000001' of EQUNR ?
I am using get_current_cell and get_selected_cells methods of class CL_GUI_ALV_GRID but of no use .
Can you please suggest ?
Thanks and regards,
S Das

hi sudipta,
You have to code as follows in class definition and implementation.
METHODS : HANDLE_HOTSPOT_CLICK
                   FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                   IMPORTING E_ROW_ID E_COLUMN_ID.
METHOD  HANDLE_HOTSPOT_CLICK.
CASE E_COLUMN_ID-FIELDNAME.
           WHEN 'EQUNR'.
                       READ GT_ALVTAB INTO GS_ALVTAB INDEX E_ROW_ID-INDEX.
                       " ADD LOGIC HERE TO DISPLAY THE CORRESPONDING DATA.
ENDCASE.
ENDMETHOD.
Regards,
Karthik D

Similar Messages

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

  • HOW TO FIRE ALV'S ON_SELECT EVENT(NOT ON_LEAD_SELECT )

    Hi,
    I have created dynamic ALV and it's multi-selected.
    I want to check the selected row value when the row is selected.
    What I want  is The ON_SELECT event like the standard table UI element.  But I can't find the ON_SELECT event in ALV.
    (ON_LEAD_SELECT EVENT is only fired when lead selection is changed. )
    anyone has idea on it?
    by the way the select mode is setted to cl_wd_table=>e_selection_mode-multi_no_lead.

    Hi,
    I have a same requirment as you have. I found the note 1281200. Unfrotunately, this event was implemented in enhancement pack 2.
    Cheers

  • How can I call functionality of ALV Grid by event of button outside grid?

    Hello,
    How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
    Best regards,
    Josef Motl

    hi Motl,
    these are steps to create a button in ALV and trigger an event from it..
    1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
    i_callback_program = gd_repid
    i_callback_pf_status_set = 'SET_PF_STATUS'
    form set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'NEWALVSTATUS'.
    endform.
    You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
    2.You have to do the following to process the new button click.
    i_callback_user_command = 'USER_COMMAND'
    form user_command using i_ucomm like sy-ucomm
    is_selfield type slis_selfield.
    case i_ucomm.
    3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status.  Then look for the standard pf status. Copy this to Z range and then add your new button.
    reward points if helpful
    regards
    satesh

  • Alv hotspot event

    Hi guys ,
    I have created an ALV report using the CAll function " REUSE alv grid display "
    I want the functionality that on double clicking the doc nr ( belnr of table bseg ) the doc should open .
    I have found the folowing cod from sdn
    FORM dis_data.
    g_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = g_repid
    i_callback_user_command = 'USER_COMMAND'
    i_grid_title = 'Interactive ALV'
    it_fieldcat = fcat
    it_events = eve
    TABLES
    t_outtab = itab
    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. "dis_data
    FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.
    CLEAR fcat1.
    CASE u_com.
    WHEN '&IC1'.
    READ TABLE itab INDEX sel_field-tabindex.
    IF sy-subrc = 0.
    t_doc = itab-vbeln.
    SET PARAMETER ID 'AUN' FIELD t_doc.
    CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.
    ENDIF.
    ENDCASE.
    ENDFORM. "user_command
    In the above code there is an event eve .. does someone kno what is this. also what is t_doc here .
    Which parameter id should i set .
    Thanks & Regards
    Ashish

    Hi Ashish,
    let's go step by step:
    1. "eve" is an internal table that holds the list events you would like to handle. A typical example could be:
      DATA: eve         TYPE slis_t_event.
      DATA: le_events   TYPE slis_alv_event.
      le_events-name = 'TOP_OF_PAGE'.
      le_events-form = 'PRINT_TOP'.
      APPEND le_events TO eve.
      le_events-name = 'END_OF_LIST'.
      le_events-form = 'PRINT_SELECTIONS'.
      APPEND le_events TO eve.
    ...where PRINT_TOP and PRINT_SELECTIONS are FORMs that carry out some headers and some footers of the listing.
    2. "t_doc" seems to me to be a variable that stores a sales document number (VBELN), which is then passed to a SET/GET parameter 'AUN'.
    I strongly recommend you to have a llok at the documentation of the parameters of function module REUSE_ALV_GRID_DISPLAY, it is VERY complete and helpful.
    I hope this helps. Best regards,
    Alvaro

  • ALV Grid Click Event Handler

    Haw can i handle the single-click mouse event in a ALV Grid class implementation...???
    The LEFT_CLICK_RUN and RIGHT_CLICK don't help's me....
    Someone can update me...???
    Thank's...

    hi,
    you can just set all the field as hotspot , and implement the event hotspot_click.
    check the code below:
    pay attention the words in red
    REPORT  ZDAVID_ALV1.
    CLASS ZCL_EVENT_RECEIVER DEFINITION DEFERRED." Declear a custom class
    tables zemployee.
    data: ls_fcat type lvc_s_fcat,
          li_fcat type lvc_t_fcat,
          ls_layo type lvc_s_layo,
          ls_color type lvc_s_scol,
          LO_EVENT TYPE REF TO ZCL_EVENT_RECEIVER.
    data: container type ref to cl_gui_custom_container,
          grid type ref to cl_gui_alv_grid.
    types: begin of ty_emp,
      emp_x type c,
      zemp_id type zemp_id,
      zemp_name type zemp_name,
      zemp_salary type zemp_salary,
      zemp_dpart type zemp_dpart,
      rowcolor(4) type c,
      cellcolor type lvc_t_scol,
      end of ty_emp.
    data: emp type table of ty_emp,
          wa_emp type ty_emp,
          wcellcolor type lvc_s_scol.
    call screen 9000.
    CLASS ZCL_EVENT_RECEIVER DEFINITION." class definition
      PUBLIC SECTION.
        methods:
          handle_single_click
             for event hotspot_click of cl_gui_alv_grid
               importing
                 e_row_id es_row_no e_column_id.
      PRIVATE SECTION.
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION
    *   LCL_EVENT_RECEIVER (DEFINITION)
    *  ===============================================================
    *   LOCAL CLASSES: IMPLEMENTATION
    *  ===============================================================
    *   CLASS LCL_EVENT_RECEIVER (IMPLEMENTATION)
    *   IN THIS EXAMPLE, ONLY EVENT DOUBLE_CLICK IS CAUGHT
    CLASS ZCL_EVENT_RECEIVER IMPLEMENTATION." implementation
    method handle_single_click.
         message e_column_id-fieldname type 'I'.
       endmethod.
    ENDCLASS.                    "LCL_EVENT_RECEIVER IMPLEMENTATION
    form sub_get_data.
      select * from zemployee into corresponding fields of wa_emp.
        wa_emp-emp_x = 'X'.
        if wa_emp-zemp_id = '171184'.
    "        wa_emp-rowcolor = 'C610'.
           wcellcolor-fname = 'ZEMP_ID'.
           wcellcolor-color-col = '7'.
           wcellcolor-color-int = '1'.
           append wcellcolor to wa_emp-cellcolor.
          ENDIF.
        append wa_emp to emp.
        CLEAR WA_EMP. clear wcellcolor.
        endselect.
      endform.
    form sub_create_obj.
      if container is initial.
        create object container
         exporting
           container_name = 'MYCONT'.
       endif.
       if grid is initial.
         create object grid
          exporting
            i_parent = container.
        endif.
      endform.
    form sub_call_alv.
        call method grid->set_table_for_first_display
        exporting
          is_layout                     = ls_layo
        changing
          it_outtab                     = emp
          it_fieldcatalog               = li_fcat
          "it_sort                       = i_sort2
        exceptions
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          others                        = 4.
        if sy-subrc <> 0.
          endif.
        create object lo_event.
        set handler lo_event->handle_single_click for grid." set handler
      endform.
    form sub_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'EMP_X'.
      ls_fcat-coltext = 'Check'.
      ls_fcat-checkbox = 'X'.
      ls_fcat-edit = 'X'.
      ls_fcat-hotspot = 'X'." hotspot
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_ID'.
      ls_fcat-coltext = 'ID'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_NAME'.
      ls_fcat-coltext = 'Name'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_SALARY'.
      ls_fcat-coltext = 'Salary'.
      ls_fcat-do_sum = 'X'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_DPART'.
      ls_fcat-coltext = 'Department'.
      ls_fcat-drdn_hndl = '1'.
      ls_fcat-edit = 'X'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      endform.
    form sub_layout.
      ls_layo-zebra = 'X'.
      ls_layo-INFO_FNAME = 'ROWCOLOR'.
      endform.
    module pbo output.
       perform sub_get_data.
       perform sub_fcat.
       perform sub_layout.
       perform sub_create_obj.
       perform sub_drop.
       perform sub_call_alv.
      endmodule.
    module pai input.
      data: ok_code type sy-ucomm.
      case ok_code.
        when 'SHOW'.
          MESSAGE 'D' TYPE 'I'.
        WHEN 'EXIT'.
          leave program.
        WHEN OTHERS.
          ENDCASE.
      clear ok_code.
      endmodule.
    form sub_drop.
      data: wa_drop type lvc_s_drop,
            drop type lvc_t_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Dev'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Testing'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Admin'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'NSS'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Finance'.
      append wa_drop to drop.
      clear wa_drop.
      call method grid->set_drop_down_table
        EXPORTING
          it_drop_down = drop.
      endform.
    *&      Module  set_gui  OUTPUT
    *       text
    MODULE set_gui OUTPUT.
      set pf-status 'PF_GUI'.
    ENDMODULE.                 " set_gui  OUTPUT

  • Problem with ALV Grid Hotspot

    Hi ,
    I am having a problem with Hotspot <<removed_by_moderator>>
    I need to Open up SE16 and need to skip the first screen of the Table 'ZLE_WH01' and display the selection screen with the MATNR passed from my ALV Report.
    I tried using Call Transaction and Submit commands, but couldn't achive my target.
    when I used SUBMIT and pass the MATNR Value to the SE16 selection screen for the corresponding Table, the value is appearing in the MATNR field of the Selection screen but the Execute button is not working.
    When I try the Call Transaction Method, the value is not capturing in the 2nd screen. Table name is capturing in the first screen.
    Kindly advice me how to resolve this issue.
    Regards,
    Srinivas
    Edited by: Vijay Babu Dudla on Feb 25, 2009 11:08 PM

    For se16
    Use fm SE16N_INTERFACE

  • Issue with ALV Grid and events

    Hi,
    I am creating an ALV Grid with fields Matnr,Charg,Labst,Meins. The first three fields are editable and the last (MEINS) is read only.
    Now I am trying to fill the MEINS field programmaticly after entering the MATNR and confirm with enter/return.
    I think that I have to "overload" the enter event of the alv grid to fill the MEINS everytime when a MATNR was entered. But I don't know how I could implementing this. Could you give me a hint how I could solve this problem?
    (The behavior should look like in transaction MIGO)
    Thanks

    Hi Alex
    When you press enter an event is triggerd and function code is filled in sy-ucoom or you can say in ok_code. At that time PAI event occurs. In PAI of that screen you need to check ok_code and load new data in table which you passed to ALV and also refresh the ALV.
    data: ok_code like sy-ucomm.
    PAI----screen 100
    case ok_code.
    when 'ENTER'.
    select data
    and refresh ALV
    then again call
    funtion to display ALV
    Regards
    Aditya

  • Dynamically ALV  Titles  Using Events - How To

    Dear All,
    There is a selection screen. Depending upon the selection, there will be output in ALV grid or list. This output doesn't contain any field of selection.
    So the output must be grouped on the basis of selection as their common title.
    Eg. If model and type are in selection screen then output something like
    Model No. 1    Type No. 2
         ALV Grid for Model 1 and Type 2
    Model No. 3    Type No. 4
         ALV Grid for Model 3 and Type 4
    How to use ALV Events to process the data dynamically for the titles as in above case the numbers 1, 2 ,3 & 4 are present in the output table which is passed to ALV for display.
    Thanks & Regards,
    Sapna Modi.

    Hi Sapna
    To set title you can fill a structure of type <b>"LVC_S_LAYO"</b> (the field gridtitle) and use the method <b>"set_frontend_layout"</b>. You can get the current layout structure using the method <b>"get_frontend_layout"</b>.
    To set column headers you can use to get and set the fieldcatalog at any instance of the runtime. For this you can use <b>"set_frontend_fieldcatalog"</b> and <b>"get_frontend_fieldcatalog"</b>. At the field catalog, you can set titles for columns using <i>"coltext", "scrtext_s", "scrtext_m", "scrtext_t"</i> .
    For more information you can refer to the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference For ALV Grid Control"</a>.
    *--Serdar
    [email protected]

  • ALV access protected event click_row_col ?

    Hi All,
    Could anyone give a sample code as to how I can access the ALV protected event "click_row_col" ?.
    I am trying to get an event to trigger to validate (select only 1 checkbox per row) after user checks on a checkbox on the alv grid display.
    Thankss,
    Neeth

    Hi Nameeth
    Or do you want to select the row whose checkbox field is checked. Then, at the data_changed event you can use the method "set_selected_rows" .
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • Example of creating  ALV double click event that can be used in ANY Program

    Once you get the hang of OO you can really create useful generalized code that can be used in a huge number of situtations.
    Double click on ALV is often wanted
    Right  here goes to implement a generalized double click action that returns the row, column and column name back to the caller.
    In your CLASS  in the DEFINITION part code as follows.
    CLASS zcl_dog DEFINITION.
    PUBLIC SECTION.
    METHODS:
      constructor
          IMPORTING       z_object type ref to zcl_dog,
                         i_parent     type ref to  cl_gui_custom_container,
    PRIVATE SECTION.
    on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row
                    e_column
                    es_row_no,
    dubbleklik
          IMPORTING
                     e_row  type  LVC_S_ROW
                     e_column   TYPE LVC_S_COL
                     es_row_no  type lvc_s_ROID
                     program type sy-repid.
    code here any extra any methods you need.
    In the CONSTRUCTOR method of the implementation
    CLASS zcl_dog IMPLEMENTATION.
    METHOD constructor.
       CREATE OBJECT grid_container1
           EXPORTING
                   container_name = 'CCONTAINER1'.
        CREATE OBJECT  grid1
            EXPORTING
                  i_parent = grid_container1.
        SET HANDLER z_object->on_user_command for grid1.
        SET HANDLER z_object->on_toolbar for grid1.
        SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
        SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
    endmethod.
    METHOD on_dubbelklik.
    CALL METHOD me->dubbleklik
    exporting
                     e_row  = e_row
                     e_column =  e_column
                     es_row_no = es_row_no
                     program  = sy-repid.
    break-point 1.
    method dubbleklik.
      perform dubbleklik IN PROGRAM (program)
        using
        e_row
        e_column
        es_row_no.
      ENDMETHOD.
    endclass.
    This will now perform a routine called dubbleklik  in your application program whenever you double click a cell in the grid.
    In the application program just code the following
    DATA:  z_object type ref to zcl_dog,  "Instantiate our class
           grid_container1 type ref to cl_gui_custom_container,
    CREATE OBJECT z_object EXPORTING z_object = z_object.
    call ANY method in the class  which eventually displays the grid
    CALL METHOD z_object->build_dynamic_structures
            CHANGING it_fldcat = it_fldcat.
    form dubbleklik using
            e_row   type LVC_S_ROW
            e_column type LVC_S_col
            es_row_no type lvc_s_roid.
    break-point 1.
    endform.
    When you double click a cell you'should be at the break point in your routine in the application program.
    You've got the cell that was clicked so by reading your table you can examine the data and take the appropriate action.
    Cheers
    Jimbo

    I suggest you purchase a case and have a dedicated support engineer work with you directly:
    http://www.sdn.sap.com/irj/boc/gettingstarted
    Or
    http://store.businessobjects.com/store/bobjects/Content/pbPage.CSC_map_countyselector/pgm.67024400?resid=jFmmLgoBAlcAAALO-iYAAAAP&rests=1278687224728
    If this is a bug you'll get a refund, if not post your enhancement request in the Idea Place. Or the Rep will suggest a better way to create your report.

  • ALV Tree - register event problem

    Hi,
    I'm trying to register standard events for ALV Tree. when perform register_events it raises exception 'illegal event combination'. does anybody know what is wrong it this code ?
    ***INCLUDE ZNT_SLORDERHIER_STATUS_0100O01 .
    *&      Module  STATUS_0100  OUTPUT
    *       text
    module STATUS_0100 output.
      set pf-status 'MAIN100'.
      if tree1 is initial.
        perform f_init_tree.
      endif.
      call method cl_gui_cfw=>flush.
    endmodule.                 " STATUS_0100  OUTPUT
    form register_events.
    * define the events which will be passed to the backend
      data: lt_events type cntl_simple_events,
            l_event type cntl_simple_event.
    * define the events which will be passed to the backend
      l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
      append l_event to lt_events.
      call method tree1->set_registered_events
        exporting
          events                    = lt_events
        exceptions
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      if sy-subrc <> 0.
            call function 'POPUP_TO_DISPLAY_TEXT_LO'
              exporting
                titel        = 'Error number:'
                textline1    = sy-subrc
                start_column = 1
                start_row    = 6.               "#EC NOTEXT
      endif.
    endform.                               " register_events
    form f_init_tree.
      perform f_build_fieldcatalog.
    * create container for alv-tree
      data: l_tree_container_name(30) type c,
            l_custom_container type ref to cl_gui_custom_container.
      l_tree_container_name = 'TREE1'.
      if sy-batch is initial.
        create object l_custom_container
          exporting
                container_name = l_tree_container_name
          exceptions
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
        if sy-subrc <> 0.
          message x208(00) with 'ERROR'.                        "#EC NOTEXT
        endif.
      endif.
    * create tree control
      create object tree1
        exporting
            parent              = l_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection      = space
            no_html_header      = ''
            no_toolbar          = ''
        exceptions
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                          "#EC NOTEXT
      endif.
    * create Hierarchy-header
      data l_hierarchy_header type treev_hhdr.
      perform f_build_hierarchy_header changing l_hierarchy_header.
    * create info-table for html-header
      data: lt_list_commentary type slis_t_listheader,
            l_logo             type sdydo_value.
      perform f_build_comment using
                     lt_list_commentary
                     l_logo.
    * repid for saving variants
      data: ls_variant type disvariant.
      ls_variant-report = sy-repid.
    CLEAR gt_sorder[].
    * create emty tree-control
      call method tree1->set_table_for_first_display
        exporting
          is_hierarchy_header = l_hierarchy_header
          it_list_commentary  = lt_list_commentary
          i_logo              = l_logo
          i_background_id     = 'ALV_BACKGROUND'
          i_save              = 'A'
          is_variant          = ls_variant
        changing
          it_outtab           = gt_sorder "table must be emty !!
          it_fieldcatalog     = gt_fieldcatalog.
    * create hierarchy
      perform f_create_hierarchy.
      perform register_events.
    endform.                    " init_tree
    form f_build_fieldcatalog.
    DATA gs_fieldcat LIKE LINE OF gt_fieldcatalog.
    * get fieldcatalog
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
          i_structure_name = 'ZVNT_SLALVTREE'
        changing
          ct_fieldcat      = gt_fieldcatalog.
        clear gs_fieldcat.
    endform.
    form f_build_hierarchy_header changing
                                   p_hierarchy_header type treev_hhdr.
      p_hierarchy_header-heading = 'Hierarchy Header'.          "#EC NOTEXT
      p_hierarchy_header-tooltip =
                             'This is the Hierarchy Header !'.  "#EC NOTEXT
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    endform.
    form f_build_comment using
          pt_list_commentary type slis_t_listheader
          p_logo             type sdydo_value.
      data: ls_line type slis_listheader.
    * LIST HEADING LINE: TYPE H
      clear ls_line.
      ls_line-typ  = 'H'.
    * LS_LINE-KEY:  NOT USED FOR THIS TYPE
      ls_line-info = 'ALV-tree: sales order-overview'.          "#EC NOTEXT
      append ls_line to pt_list_commentary.
    * STATUS LINE: TYPE S
      p_logo = 'ENJOYSAP_LOGO'.
    endform.                    "build_comment
    form f_create_hierarchy.
      data: ls_sorder type ty_ZVNT_SLALVTREE,
            lt_sorder type ty_ZVNT_SLALVTREE occurs 0.
    * get data
      select * from ZVNT_SLALVTREE into table lt_sorder up to 200 rows WHERE spras = sy-langu and matnr in s_matnr
                                                                       and vbeln in s_vbeln.
      sort lt_sorder by vbeln.
    * add data to tree
      data: l_vbeln_key type lvc_nkey,
            l_posnr_key type lvc_nkey,
            l_last_key type lvc_nkey.
      loop at lt_sorder into ls_sorder.
        on change of ls_sorder-vbeln.
          perform f_add_vbeln_line using    ls_sorder
                                  changing l_vbeln_key.
        endon.
        on change of ls_sorder-posnr.
          perform f_add_posnr_line using    ls_sorder
                                           l_vbeln_key
                                  changing l_posnr_key.
        endon.
        perform f_add_complete_line using  ls_sorder
                                         l_posnr_key
                                changing l_last_key.
      endloop.
    * this method must be called to send the data to the frontend
      call method tree1->frontend_update.
    endform.                               " create_hierarchy
    form f_add_vbeln_line using     ps_sorder type ty_ZVNT_SLALVTREE
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value,
            ls_sorder type ty_ZVNT_SLALVTREE.
    * set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image = '@3P@'.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      append ls_item_layout to lt_item_layout.
    * add node
      l_node_text =  ps_sorder-vbeln.
      data: ls_node type lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      call method tree1->add_node
        exporting
          i_relat_node_key = p_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_sorder
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        importing
          e_new_node_key   = p_node_key.
    endform.
    form f_add_posnr_line using     ps_sorder type ty_ZVNT_SLALVTREE
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value,
            ls_sorder type ty_ZVNT_SLALVTREE.
    * set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image = '@3Y@'.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensified.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      append ls_item_layout to lt_item_layout.
    * add node
      l_node_text =  ps_sorder-posnr.
      data: relat type int4.
      relat = cl_gui_column_tree=>relat_last_child.
      call method tree1->add_node
        exporting
          i_relat_node_key = p_relat_key
          i_relationship   = relat
          i_node_text      = l_node_text
          is_outtab_line   = ls_sorder
          it_item_layout   = lt_item_layout
        importing
          e_new_node_key   = p_node_key.
    endform.                               " add_connid_line
    form f_add_complete_line using   ps_sorder type ty_ZVNT_SLALVTREE
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value.
    * set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      ls_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.
      ls_item_layout-editable = 'X'.
      append ls_item_layout to lt_item_layout.
      l_node_text =  ps_sorder-posnr.
      data: ls_node type lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      call method tree1->add_node
        exporting
          i_relat_node_key = p_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          is_outtab_line   = ps_sorder
          i_node_text      = l_node_text
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        importing
          e_new_node_key   = p_node_key.
    endform.                               " add_complete_line
    form exit_program.
      call method tree1->free.
      leave program.
    endform.
    Code Formatted by: Alvaro Tejada Galindo on Feb 14, 2008 9:54 AM
    Edited by: Lukasz Sekowski on Feb 14, 2008 4:11 PM

    I've finally fixed the problem:
    there was:
    item_selection      = space
    and should be:
    item_selection      = 'X'

  • Know alv grid on event click

    Hi,
    Is it possible to know the alv grid (TYPE REF TO cl_gui_alv_grid) on the event click? In fact, on a screen, I have 2 alv grids and I would like to store the alv grid name for a process at click moment.
    Thanks.
    Edited by: Xavier Couloumies on Sep 12, 2008 2:07 PM

    you might declare two differents methods for the two grids
    PUBLIC SECTION.
      METHODS:
        HANDLE_DOUBLE_CLICK
          FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
            IMPORTING E_ROW
                      E_COLUMN,
        HANDLE_DOUBLE_CLICK2
          FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
            IMPORTING E_ROW
                      E_COLUMN.
    something like that
    then , in the implementations do something like this
    METHOD HANDLE_DOUBLE_CLICK.
         PERFORM X USING GRID = '1'.
    ENDMETHOD.
    METHOD HANDLE_DOUBLE_CLICK2.
         PERFORM X USING GRID = '2'.
    ENDMETHOD.
    and do the respective validations on that form
    hope this help

  • Alv grid key event

    Hi,
    is it possible to register key press event in alv grid ? I want to detect ctrl button was pressed than call same action.
    help
    thx
    Message was edited by:
            mk kn

    Hi,
    did you find a solution? I have the same question.

  • ALV Grid-- "DOUBLECLICK EVENT" doesnt work with "DATA_CHANGED_FINISHED" ??

    Hello at all,
    i have an ALV-Grid with 2 different Events.
    .....First Event: "Doubleclick"
    Second Event: "data_changed_finished"
    If i click to a column than it should be trigger the Doubleclick Event.
    And if i write some text in the column and "Press" Enter than it should be trigger the Event data_changed_finished.
    But the Problem is:
    If i click double to any column it will allways trigger the Event datachanged_finished_
    But if i replace the Event data_changed_finished with Event data_change, than it will be work.
    What can I do to resolve the Problem??
    Please give me some ideas, what i can do!!!
    With kind regards
    Ersin

    Hi,
    Try to do SET HANDLER first for Hanld_Double_Click Event then Handle Data Changed
    Thanks,
    Pramod

Maybe you are looking for

  • ADF in JDeveloper 10.1.3.0.4: Error deploying bc4j.ear in JBoss-4.0.4.CR2

    Hello, Using the ADF Runtime Installer for JBoss found in JDeveloper 10.1.3.0.4, i've received deployment error during startup of JBoss. The error message as displayed in the console window as follows: 09:29:16,325 ERROR [URLDeploymentScanner] Incomp

  • Servlet calling a BAPI Web Service...

    Hi everyone, I downloaded the wsdl file for the BAPI_USER_GETLIST. I created a Deployable Proxy that points to this wsdl file. I created a Web modul project with a servlet. I also created an Enterprise application project that contains my Web modul p

  • Bug in Nokia Lumia 720

    Bug in Nokia Lumia 720" which i was using,After completion of my downloaded app"Java Tutorial" & i started to open this suddenly, my Wi-Fi connection got problem & i have been found a bug on it. Attachments: Nokia Lumia 720 with issue 20131130_0001.j

  • How to "Grab" or Highlight Safari Window Titles?

    Hello Folks, i was wondering if someone can answer a question for me about the titles that appear at the top of my Safari windows. (i'm using Safari 3.2.) When i display a webpage in a particular Safari window or tab within a window, there is a title

  • IPhone 6+ Controls Itself..?

    Hi! In December, I received and iPhone 6+ for Christmas. It was a really expensive gift, and it's frustrating that I'm already having a major problem with it. Everything that I try to do on my phone is interrupted! It operates on iOS 8.1.2, which I'v