User command in ALV grid

Hi
I am displaying the output of a report in the ALV grid.
I have used REUSE_ALV_LIST_DISPLAY in my code as follows.
FORM DISPLAY_ALV_LIST.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
  I_CALLBACK_PROGRAM = SYREPID
  IS_LAYOUT = FIELDLAYOUT
  I_CALLBACK_USER_COMMAND  = 'USER-COMMAND'
  IT_FIELDCAT = FIELDCATALOG[]
  I_SAVE = 'X'
  IT_EVENTS = EVENTSTAB[]
  TABLES
  T_OUTTAB = ITAB_1
  EXCEPTIONS
  PROGRAM_ERROR = 1
  OTHERS = 2.
ENDFORM. " DISPLAY_ALV_LIST
When I try to call a transaction at the user command with sy-ucomm = &IC1 sys gives a message 'Not valid'.
FORM USER-COMMAND USING UCOMM LIKE SY-UCOMM
                       SELFIELD TYPE SLIS_SELFIELD.
  READ TABLE ITAB_1 INDEX SELFIELD-TABINDEX.
  CHECK SY-SUBRC = 0.
  CASE UCOMM.
    WHEN '&IC1'.
      CASE SELFIELD-SEL_TAB_FIELD.
        WHEN 'ITAB_1-VBELN'.
          SET PARAMETER ID 'VF' FIELD ITAB_1-VBELN.
          CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
        WHEN 'ITAB_1-MATNR'.
          SET PARAMETER ID 'MAT' FIELD ITAB_1-MATNR.
          CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
      ENDCASE.
  ENDCASE.
ENDFORM.                    "USER_COMMAND
Kindly let me know what am I missing in the above code. As this FORM USER-COMMAND is at all called during the user-command.
Regds
Priya

the Code what u are given is WRONG , check this one.
put like this , it will solve ur probs.
  check r_ucomm = '&IC1'.             "User Double Clicked on Some field
  check not rs_selfield-value is initial.
  case rs_selfield-fieldname.
    when 'AUFNR'.
      if rad4 ne 'X'.
        read table  itab_order index rs_selfield-tabindex.
      else.
        read table  itab_order2 index rs_selfield-tabindex.
        itab_order-aufnr = itab_order2-aufnr.
      endif.
      if sy-subrc eq 0.
        set parameter id 'ANR' field  itab_order-aufnr.
        set parameter id 'VGN' field '10'.
        call transaction 'CO14' and skip first screen.
      endif.                            " IF SY-SUBRC EQ 0
  endcase.
Regards
Prabhu
Message was edited by: Prabhu Peram

Similar Messages

  • Pf status & user-command in alv grid

    Hi Friends,
    I have one query for ALV grid.
    Actually my requirement is like that
    Whenever the user double click on grid the control moves to transaction 'VA01' tcode.
    I also wanted to set the gui status in ALV grid.
    How to do it??
    Plz tell me in detail.

    Very simple....
    copy paste this code.... remember I have created a GUI Status called ZALV_STATUS.
    So u will have to create this status to run ur program.
    U can come back if u have any doubts...
    *& Report  Z_ALV_TRAINING_LIST_HOTSPOT
    REPORT  Z_ALV_TRAINING_LIST_HOTSPOT.
    Type Pools Used  **********
    TYPE-POOLS : SLIS.
    Internal Tables Declare  ************
    DATA : it_document   type standard table of bkpf initial size 0 with header line,
           IT_FIELD_CAT  TYPE SLIS_T_FIELDCAT_ALV,
           it_alv_event  type SLIS_T_EVENT,
           fl_layout     type slis_layout_alv.
    Select Data  ***********
    start-of-selection.
    select * from bkpf into table it_document.
    Make Field Catalog  ******
    PERFORM MAKE_FIELD_CATALOG.
    Make Layout  *********
    perform sub_fill_layout.
    Make Events Table  *******
    perform sub_Fill_alv_event.
    Display ALV  *********
    PERFORM DISPLAY_ALV_LIST.
    *&      Form  make_field_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM MAKE_FIELD_CATALOG .
    data : wa type slis_fieldcat_alv.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
      I_PROGRAM_NAME               =
      I_INTERNAL_TABNAME           =
       I_STRUCTURE_NAME             = 'bkpf'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_INCLNAME                   =
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      CHANGING
        CT_FIELDCAT                  = it_field_cat
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    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 it_field_cat into wa index 3.
    wa-hotspot = 'X'.
    modify it_field_cat index 3 from wa.
    ENDFORM.                    " make_field_catalog
    *&      Form  display_alv_list
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_ALV_LIST .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM             = sy-repid
       I_CALLBACK_PF_STATUS_SET       = 'SET_MY_PF_STATUS'
      I_CALLBACK_USER_COMMAND        = ' '
       IS_LAYOUT                      = fl_layout
       IT_FIELDCAT                    = it_field_cat[]
      IT_SORT                        =
      I_DEFAULT                      = 'X'
       I_SAVE                         = 'X'
      IS_VARIANT                     = '/TEST_VV'
        IT_EVENTS                      = it_alv_event
      TABLES
        T_OUTTAB                       = it_document.
    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_alv_list
    *&      Form  sub_my_pf_event
          text
    -->  p1        text
    <--  p2        text
    FORM sub_my_pf_event using p_comm type sy-ucomm p_sEL_FIELD TYPE SLIS_SELFIELD.
      read table it_document index p_sel_field-tabindex.
      set parameter id 'BLN' field it_document-belnr.
      set parameter id 'BUK' field it_document-bukrs.
      set parameter id 'GJR' field it_document-gjahr.
      case p_comm.
        when 'PICK'.
          call transaction 'FB03' and skip first screen.
      endcase.
    ENDFORM.                    " sub_my_pf_event
    *&      Form  sub_Fill_alv_event
          text
    -->  p1        text
    <--  p2        text
    FORM sub_Fill_alv_event .
      data : wa type slis_alv_event.
      wa-name = 'USER_COMMAND'.
      wa-form = 'SUB_MY_PF_EVENT'.
      append wa to it_alv_event.
    ENDFORM.                    " sub_Fill_alv_event
    *&      Form  sub_fill_layout
          text
    -->  p1        text
    <--  p2        text
    FORM sub_fill_layout .
      fl_layout-f2code = 'PICK'.
      fl_layout-box_fieldname = 'BELNR'.
    ENDFORM.                    " sub_fill_layout
    *&      Form  SET_MY_PF_STATUS
          text
    -->  p1        text
    <--  p2        text
    FORM SET_MY_PF_STATUS USING    p_rt_extab TYPE slis_t_extab.
    SET PF-STATUS 'ZALV_STATUS'.
    ENDFORM.                    " SET_MY_PF_STATUS
    Plz award points if it was helpful....
    Message was edited by:
            Varun Verma

  • User command in ALv

    how to handle user command in alv grid?
    if we want to select only one row, but we get a table from calling method
    get_selected_rows.
    is there any method or way of getting a single row which is selected?

    Hi,
    This method indeed returns the table but only with the selected rows. Therefore when you select only one row, it will contain only one entry. For this use second parameter of the method ET_ROW_NO as the first one is obsolete. It will contain indexes of the selected rows.
    Note!
    You must use one of the these selection modes (A, C, D) in this case. The default one is B, so you have to change it in layout structure.
    layout_structure-sel_mode = 'A'.  "i.e.
    See possible selection modes [here|http://help.sap.com/saphelp_erp2004/helpdata/en/ef/a2e9eff88311d2b48d006094192fe3/frameset.htm]
    Regards
    Marcin

  • User input in ALV Grid

    Hello All,
    Is it possible to have a user input in ALV grid. I know there can be editable columns/cells but suppose the application demands an input field to be placed in ALV Grid where the user will enter some value.
    Could someone please suggest if this can be done.
    Regards
    Indrajit

    Here's THE definitive way to do it.
    This little proggy demonstrates the following.
    1) Create a DYNAMIC FCAT for an internal table with USER defined fields (i.e non ddic) and colour some columns in the FCAT.
    2) Create a DYNAMIC TABLE.
    3) Define a subclass of CL_GUI_ALV_GRID so you can access some very useful protected methods and attributes - you can get original and changed table IN ROWS which is a lot easier sometimes than messing around with individual
    cells.
    4) Create extra buttons on the toolbar.
    5) Define EVENT handlers including data change so you can get control when the user enters data. YOU DON'T NEED PAI anymore with event handlers.
    6) Call methods in your subclass of CL_GUI_ALV_GRID (you can also call methods in CL_GUI_ALV_GRID by virtue of Inheritance) from methods in your event handler class.
    7) Display an editable Grid.
    This method will work for almost any conditions you need to use.
    I'm sure this covers all the bases -- please reply if any queries.
    Run the program, click on the EDIT button and enter your data. Press ENTER when done.
    All you need to do is copy this code and create one empty screen (SE51) with a custom container called CCONTAINER1  with the following logic in it.
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    (In the program you don't actually do anything in the PAI as the event handler takes care of this)
    Now here's the program
    PROGRAM zdynfieldcat.
    class zcltest definition  deferred.  "For field symbol reference.
    Simple test of dynamic ITAB with user defined (not ddic) fields
    Build dynamic fcat
    Table structure obtained via new RTTI functionality
    use ALV grid to display and edit.
    Create a blank screen 100 with a custom container called CCONTAINER1.
    Define field symbols as these can't be defined in classes
    field-symbols: <dyn_table> type standard table,
                   <g2> type ref to zcltest,
                   <g1> type ref to cl_gui_custom_container,
                   <actual_tab> type standard table,
                   <outtab> type table,
                   <fs1> type ANY,
                   <FS2> TYPE TABLE,
                   <fs3> type table,
                   <fs4> type table,
                   <fs5> type  table.
    class zcltest definition inheriting from cl_gui_alv_grid.
    define this as a subclass so we can access the protected attributes
    of the superclass cl_gui_alv_grid
      public section.
        types:  g4 type ref to cl_gui_custom_container.
        types:  g3  type ref to cl_alv_changed_data_protocol.
        data:   i_parent type g4,
                lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
        zog like line of lr_rtti_struc->components. "RTTI
        types: struc like zog.
        types: struc1 type table of struc.
        methods:
           constructor
               importing i_parent type g4,
           disp_tab
               importing  p_er_data_changed type g3,
           create_dynamic_fcat
               importing zogt type struc1
               exporting it_fldcat type lvc_t_fcat.
    Protected section.
       data: stab type ref to data,
            wa_it_fldcat type lvc_s_fcat,
            c_index type sy-index.
    endclass.
    class zcltest implementation.
      METHOD constructor.
        CALL METHOD super->constructor
          EXPORTING
            i_appl_events = 'X'
            i_parent      = i_parent.
          endmethod.
      method disp_tab.
    mt_outtab is the data table held as a protected
    attribute in class cl_gui_alv_grid.
        assign me->mt_outtab->* TO <outtab>. "Original data
        assign p_er_data_changed->mp_mod_rows TO <FS1>.
        stab = p_er_data_changed->mp_mod_rows.
        assign p_er_data_changed->mt_inserted_rows to <fs3>.
        assign p_er_data_changed->mt_deleted_rows to <fs4>.
        assign p_er_data_changed->mt_mod_cells to <fs5>.
        assign stab->* TO <fs2>.
    do whatever you want with <outtab>
    contains data BEFORE changes each time.
    Note that NEW (Changed) table has been obtained
    already by  call to form
    check_data USING P_ER_DATA_CHANGED
    TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Entered data is in table defined by <fs2>
    In this method you can compare original and changed data.
    Easier than messing around with individual cells.
    do what you want with data in <fs2> validate / update / merge etc
      endmethod.
      method create_dynamic_fcat.
        loop at zogt into zog.
          c_index = c_index + 1.
          clear wa_it_fldcat.
          wa_it_fldcat-fieldname = zog-name .
          wa_it_fldcat-datatype = zog-type_kind.
          wa_it_fldcat-inttype = zog-type_kind.
          wa_it_fldcat-intlen = zog-length.
          wa_it_fldcat-decimals = zog-decimals.
          wa_it_fldcat-coltext = zog-name.
          wa_it_fldcat-lowercase = 'X'.
          if c_index eq 2.
            wa_it_fldcat-emphasize = 'C411'.
          endif.
          if c_index eq 3.
            wa_it_fldcat-emphasize = 'C511'.
          endif.
          append wa_it_fldcat to it_fldcat .
        endloop.
      endmethod.                    "create_dynamic_fcat
    endclass.                    "zcltest IMPLEMENTATION
    class lcl_grid_event_receiver definition.
      public section.
    note that zcltest inherits all of events etc from
    class cl_gui_alv_grid so specify event handler for
    zcltest.
    methods:
        handle_data_changed
             for event data_changed of zcltest
             importing  er_data_changed,
        toolbar
             for event toolbar of zcltest
             importing e_object
             e_interactive,
        user_command
             for event user_command of zcltest
             importing e_ucomm.
    endclass.
    class lcl_grid_event_receiver implementation.
      method handle_data_changed.
    code whatever required after data entry.
    various possibilites here as you
    can get back Cell(s) changed
    columns or the entire updated table.
    Data validation is also possible here.
    Note here the field sybol <g2> contains our
    instance of  class zcltest so we can now
    call any methods / access
    attributes of that class from this method
    in our event handler class.
        call method <g2>->disp_tab
          EXPORTING
            p_er_data_changed = er_data_changed.
      endmethod.                    "handle_data_changed
      method toolbar.
        data : ls_toolbar type stb_button.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EDIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Edit' to ls_toolbar-text.
        move icon_change_text to ls_toolbar-icon.
        move 'Click2Edit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'UPDA' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Update' to ls_toolbar-text.
        move icon_system_save to ls_toolbar-icon.
        move 'Click2Update' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EXIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Exit' to ls_toolbar-text.
        move icon_system_end to ls_toolbar-icon.
        move 'Click2Exit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
      endmethod.                    "toolbar
      method user_command.
        case e_ucomm .
          when 'EDIT'. "From Tool bar
            perform set_input.
            perform init_grid.
          when 'UPDA'. "From Tool bar
            perform refresh_disp.
            perform update_table.
          when 'EXIT'. "From Tool bar
            leave program.
        endcase.
      endmethod.                    "user_command
    endclass.                    "lcl_grid_event_receiver IMPLEMENTATION
    program data
    include <icon>.
    define any old internal structure NOT in DDIC
    types: begin of s_elements,
    anyfield1(20) type c,
    anyfield2(20) type c,
    anyfield3(20) type c,
    anyfield4(20) type c,
    anyfield5(11) type n,
    end of s_elements.
    data: wa_element type s_elements,
    wa_data type s_elements.
    Note new RTTI functionality allows field detail
    retrieval at runtime for dynamic tables.
    data:
            grid1 type ref to zcltest,
            grid_handler type ref to lcl_grid_event_receiver,
            c_dec2 type s_elements-anyfield5,
            wa_it_fldcat type lvc_s_fcat,
            it_fldcat type lvc_t_fcat,
            lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
            lt_comp TYPE cl_abap_structdescr=>component_table,"RTTI
            ls_comp LIKE LINE OF lt_comp, "RTTI
            zog like line of lr_rtti_struc->components,  "RTTI
            struct_grid_lset type lvc_s_layo,
            l_valid type c,
            new_table type ref to data.
            types: struc like zog.
    data:  zogt type table of struc,
            grid_container1 type ref to cl_gui_custom_container,
            g_event_receiver type ref to lcl_grid_event_receiver,
            ok_code like sy-ucomm,
            i4 type int4.
    start-of-selection.
      call screen 100.
    module status_0100 output.
      if grid_container1 is initial.
        create object grid_container1
        exporting
        container_name = 'CCONTAINER1'.
        assign grid_container1 to <g1>.
        create object grid1
         exporting i_parent = grid_container1.
    we need reference to this instance so we can use
    Methods etc of zcltest class and alv (superclass)
    in our event receiver class.
         assign grid1 to <g2>.
        create object grid_handler.
        set handler:
        grid_handler->user_command for grid1,
        grid_handler->toolbar for grid1,
        grid_handler->handle_data_changed for grid1.
    Get the Internal table structure
        lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( wa_data ).
    Build field catalog just use basic data here
    colour specific columns as well
        zogt[] = lr_rtti_struc->components.
           call method grid1->create_dynamic_fcat
          EXPORTING
            zogt      = zogt
          IMPORTING
            it_fldcat = it_fldcat.
    Create dynamic internal table and assign
    to field symbol.
    Use dynamic field catalog just built.
      call method cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = new_table.
      assign new_table->* to <dyn_table>.
        perform populate_dynamic_itab.
        perform init_grid.
        perform register_enter_event.
    set off ready for input initially
        i4 = 0.
        call method grid1->set_ready_for_input
          EXPORTING
            i_ready_for_input = i4.
      endif.
    endmodule.                    "status_0100 OUTPUT
    module user_command_0100 input.
    *PAI not needed in OO ALV anymore as User Commands
    are handled as events
    *in method user_command.
    we can also get control if any data was entered
    and the ENTER is pressed by
    raising an event.
    Control then returns to method handle_data_changed.
    endmodule.                    "user_command_0100 INPUT
    form populate_dynamic_itab.
    load up a line of the dynamic table
      c_dec2 = c_dec2 + 11.
      wa_element-anyfield1 = 'Tabbies'.
      wa_element-anyfield2 = 'ger.shepards'.
      wa_element-anyfield3 = 'White mice'.
      wa_element-anyfield4 = 'Any old text'.
      wa_element-anyfield5 = c_dec2.
      append wa_element to <dyn_table>.
    endform.                    "populate_dynamic_itab
    form exit_program.
      call method grid_container1->free.
      call method cl_gui_cfw=>flush.
      leave program.
    endform.                    "exit_program
    form refresh_disp.
      call method grid1->refresh_table_display.
    endform.                    "refresh_disp
    form update_table.
    The dynamic table here is the changed table
    read from the grid
    after user has changed it
    Data can be saved to DB or whatever.
      loop at <dyn_table> into wa_element.
    do what you want with the data here
      endloop.
    switch off edit mode again for next function
      i4 = 0.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "update_table
    form set_input.
      i4 = 1.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "set_input
    form switch_input.
      if i4 = 1.
        i4 = 0.
      else.
        i4 = 1.
      endif.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "switch_input
    form init_grid.
    Enabling the grid to edit mode,
      struct_grid_lset-edit = 'X'. "To enable editing in ALV
      struct_grid_lset-grid_title = 'Jimbos Test'.
       call method grid1->set_table_for_first_display
        EXPORTING
          is_layout       = struct_grid_lset
        CHANGING
          it_outtab       = <dyn_table>
          it_fieldcatalog = it_fldcat.
    endform.                    "init_grid
    form register_enter_event.
      call method grid1->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    Instantiate the event or it won't work.
      create object g_event_receiver.
      set handler g_event_receiver->handle_data_changed for grid1.
    endform.                    "register_enter_event
    Have fun with this
    Cheers
    jimbo

  • Problem with User Command in alv report

    Hi
    I have developed a ALV grid report with drill down capability to transaction code for user command. I am having a trouble with this.
    CASE ucomm.
        WHEN '&IC1'.
          CLEAR: wa_import.
          IF selfield-fieldname EQ 'ANLN1'.
            READ TABLE t_import INTO wa_import INDEX selfield-tabindex.
            SET PARAMETER ID 'BUK' FIELD wa_import-bukrs.
            SET PARAMETER ID 'ANl' FIELD wa_import-anln1.
            CALL TRANSACTION 'AW01N'.
          ENDIF.
    here my parameter ids are showing the values but when i call the transaction i am not getting the actual asset numbers.
    Can someone help me out this
    Thanks

    Hi,
    add the AND SKIP FIRST SCREEN...addition..
    CALL TRANSACTION 'AW01N' AND SKIP FIRST SCREEN.
    Thanks
    Naren

  • Using GETGUI command --in ALV grid, how to extract multiple DATA

    Using GETGUI command , I am able to get a single value form the ALV grid. Please explain me how I can read multiple data like rows and columns data from the ALV grid.
    Please be detailed as I already tried selecting the whole block of ALV grid, but I could not help myself.
    Regards
    Srinivas.

    Hi Srinivas,
    You will have to use the concept of Regular expressions for this. We will have to loop through each row/coloumn to do what u desire.
    The ID of an element on grid will be something like GRIDNAME-<ELEMENT NAME>[ROW NO] [COLUMN NO]
    we need to parameterize the row and also the el;ementname changes for each column along with the column number. Please let me know if this much detail is enough. If not i can show u a real time ecatt code snippet on how to play around with grids.
    Regards,
    Justin

  • ALV Grid: event for user return in ALV Grid Control

    Hi developers,
    i'm wanna do something after a user has pressed the return button in a alv grid control. For that i need probably a event. But i can not find a proper event in the documentation. Could one of you guys help me?
    Best regards christian

    Hi Christian
    ALV grid is an encapsulated object, so it seems there is no way, you ought to implement the data_changed event. So if you want to make bulk data input and after trigger the event by pressing the return key, you should make the ALV Grid get your changes after pressing the key but not after a cell change of a modified cell.
    To set this attribute:
    CALL METHOD gr_alvgrid->register_edit_event
         EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter .
    This way "data_changed" event will be triggered whenever you press the return key while editing.
    For some more information you can also 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>.
    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>

  • At user command in alv's

    how to handle at user commads in alv's?

    Hi Praveen
    Interactive Reports
    As the name suggests, the user can Interact with the report. We can have a drill down into the report data. For example, Column one of the report displays the material numbers, and the user feels that he needs some more specific data about the vendor for that material, he can HIDE that data under those material numbers.
    And when the user clicks the material number, another report (actually sub report/secondary list) which displays the vendor details will be displayed.
    We can have a basic list (number starts from 0) and 20 secondary lists (1 to 21).
    Events associated with Interactive Reports are:
    AT LINE-SELECTION
    AT USER-COMMAND
    AT PF<key>
    TOP-OF-PAGE DURING LINE-SELECTION.
    HIDE statement holds the data to be displayed in the secondary list.
    sy-lisel : contains data of the selected line.
    sy-lsind : contains the level of report (from 0 to 21)
    <u><b>Interactive Report Events:</b></u>
    AT LINE-SELECTION : This Event triggers when we double click a line on the list, when the event is triggered a new sublist is going to be generated. Under this event what ever the statements that are been return will be displayed on newly generated sublist.
    AT PFn: For predefined function keys...
    <u><b>AT USER-COMMAND :</b></u> It provides user functions keys.
    TOP-OF-PAGE DURING LINE-SELECTION :top of page event for secondary list.
    <b>check this sample code</b>
    TYPE-POOLS: slis.                      " ALV Global Types
    DATA :
      gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
    *       Form  F_LIRE_DATA
    FORM f_read_data.
      REFRESH gt_user.
    * Get User's info
      CALL FUNCTION 'THUSRINFO'
           TABLES
                usr_tabl = gt_user.
    * Wait in a task
      PERFORM f_call_rfc_wait.
    ENDFORM.                               " F_READ_DATA
    *      Form  F_DISPLAY_DATA
    FORM f_display_data.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DEFINE m_event_exit.
        clear ls_event_exit.
        ls_event_exit-ucomm = &1.
        ls_event_exit-after = 'X'.
        append ls_event_exit to lt_event_exit.
      END-OF-DEFINITION.
      DATA :
        ls_layout     TYPE slis_layout_alv,
        lt_sort       TYPE slis_t_sortinfo_alv,
        ls_sort       TYPE slis_sortinfo_alv,
        lt_event_exit TYPE slis_t_event_exit,
        ls_event_exit TYPE slis_event_exit.
    * Build Sort Table
      m_sort 'ZEIT'.
    * Build Event Exit Table
      m_event_exit '&NTE'.                 " Refresh
      ls_layout-zebra = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_callback_program      = sy-cprog
                i_callback_user_command = 'USER_COMMAND'
                is_layout               = ls_layout
                i_structure_name        = 'UINFO'
                it_sort                 = lt_sort
                it_event_exit           = lt_event_exit
           TABLES
                t_outtab                = gt_user.
    ENDFORM.                               " F_DISPLAY_DATA
    *       FORM USER_COMMAND                                             *
    FORM user_command USING i_ucomm     TYPE syucomm
                            is_selfield TYPE slis_selfield.     "#EC CALLED
      CASE i_ucomm.
        WHEN '&NTE'.
          PERFORM f_read_data.
          is_selfield-refresh = 'X'.
          SET USER-COMMAND '&OPT'.         " Optimize columns width
      ENDCASE.
    ENDFORM.                               " USER_COMMAND
    *      Form  F_CALL_RFC_WAIT
    FORM f_call_rfc_wait.
      DATA lv_mssg(80).                                         "#EC NEEDED
    * Wait in a task
      CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '001'
        PERFORMING f_task_end ON END OF TASK
        EXPORTING
          seconds               = 5        " Refresh time
          busy_waiting          = space
        EXCEPTIONS
          RESOURCE_FAILURE      = 1
          communication_failure = 2  MESSAGE lv_mssg
          system_failure        = 3  MESSAGE lv_mssg
          OTHERS                = 4.
    ENDFORM.                               " F_CALL_RFC_WAIT
    *      Form  F_TASK_END
    FORM f_task_end USING u_taskname.
      DATA lv_mssg(80).                                         "#EC NEEDED
    * Receiving task results
      RECEIVE RESULTS FROM FUNCTION 'RFC_PING_AND_WAIT'
        EXCEPTIONS
          RESOURCE_FAILURE      = 1
          communication_failure = 2  MESSAGE lv_mssg
          system_failure        = 3  MESSAGE lv_mssg
          OTHERS                = 4.
      CHECK sy-subrc EQ 0.
      SET USER-COMMAND '&NTE'.             " Refresh
    ENDFORM.                               " F_TASK_END
    *************** END OF PROGRAM Z_ALV_AUTO_REFRESH *********************
    check this link too
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-AddUsercommandfunctionalitytoALVgridreport&
    Reward all helpfull answers
    Regards
    Pavan

  • At line-selection /at user-command in alv

    hai ,
             i used layout-listappend to output 3 alv's in one page .but
    after using layout-listappend i_usercommand in reuse_alv_.. is not working .so i tried to use at line selection . please guide me to solve this problem how to use at line-selection in this prob or is there any other suitable way.

    hi,
    try this code it will help you
    *& Report  ZP_ALV8
    REPORT  zp_alv8.
    TABLES: kna1, mara, vbak, mard.
    TYPE-POOLS: slis.
    **TYPE DECLERATION
    TYPES: BEGIN OF ty_kna1,
             kunnr LIKE kna1-kunnr,
             land1 LIKE kna1-land1,
             name1 LIKE kna1-name1,
             ort01 LIKE kna1-ort01,
           END OF ty_kna1.
    TYPES: BEGIN OF ty_mara,
             matnr LIKE mara-matnr,
             ersda LIKE mara-ersda,
             ernam LIKE mara-ernam,
           END OF ty_mara.
    TYPES: BEGIN OF ty_vbak,
             vbeln LIKE vbak-vbeln,
             erdat LIKE vbak-erdat,
             ernam LIKE vbak-ernam,
           END OF ty_vbak.
    TYPES: BEGIN OF ty_mard,
             matnr LIKE mard-matnr,
             werks LIKE mard-werks,
             lgort LIKE mard-lgort,
          END OF ty_mard.
    **DATA DECLERATION
    DATA: it_kna1 TYPE STANDARD TABLE OF ty_kna1,
          wa_kna1 TYPE ty_kna1.
    DATA: it_mara TYPE STANDARD TABLE OF ty_mara,
          wa_mara TYPE ty_mara.
    DATA: it_vbak TYPE STANDARD TABLE OF ty_vbak,
          wa_vbak TYPE ty_vbak.
    DATA: it_mard TYPE STANDARD TABLE OF ty_mard,
          wa_mard TYPE ty_mard.
    DATA: it_fieldcat_kna1 TYPE slis_t_fieldcat_alv,
          wa_fieldcat_kna1 TYPE slis_fieldcat_alv,
          it_fieldcat_mara TYPE slis_t_fieldcat_alv,
          wa_fieldcat_mara TYPE slis_fieldcat_alv,
          it_fieldcat_vbak TYPE slis_t_fieldcat_alv,
          wa_fieldcat_vbak TYPE slis_fieldcat_alv,
          it_fieldcat_mard TYPE slis_t_fieldcat_alv,
          wa_fieldcat_mard TYPE slis_fieldcat_alv.
    DATA: it_event_kna1 TYPE slis_t_event,
          wa_event_kna1 TYPE slis_alv_event,
          it_event_mara TYPE slis_t_event,
          wa_event_mara TYPE slis_alv_event,
          it_event_vbak TYPE slis_t_event,
          wa_event_vbak TYPE slis_alv_event,
          it_event_mard TYPE slis_t_event,
          wa_event_mard TYPE slis_alv_event.
    DATA: wa_layout TYPE slis_layout_alv,
          it_listheader TYPE slis_t_listheader,
          wa_listheader TYPE slis_listheader.
    selection-screen begin of block b1 with frame title text-001.
    select-options: s_kunnr for kna1-kunnr default '1000' to '1050'.
    selection-screen end of block b1.
    selection-screen begin of block b2 with frame title text-002.
    select-options: s_matnr for mara-matnr default '1' to '100'.
    selection-screen end of block b2.
    **INITIALIZATION
    INITIALIZATION.
      PERFORM layout.
      PERFORM fieldcat_kna1.
      PERFORM fieldcat_mara.
      PERFORM event_kna1.
      PERFORM event_mara.
      PERFORM eventpopulate_kna1.
      PERFORM eventpopulate_mara.
    **START OF SELECTION AND FIRST LIST DISPLAY
    START-OF-SELECTION.
      SELECT kunnr land1 name1 ort01
             FROM kna1
             INTO TABLE it_kna1
             where kunnr in s_kunnr.
           UP TO 10 ROWS.
      SELECT matnr ersda ernam
             FROM mara
             INTO TABLE it_mara
             where matnr in s_matnr.
            UP TO 20 ROWS.
      PERFORM display.
    **FORM LAYOUT
    *&      Form  layout
          text
    -->  p1        text
    <--  p2        text
    FORM layout .
      wa_layout-zebra ='X'.
      wa_layout-get_selinfos      = 'X'.
      wa_layout-key_hotspot = 'X'.
    ENDFORM.                    " layout
    *FIELD CATALOUGE*******************************
    *&      Form  fieldcat_kna1
          text
    -->  p1        text
    <--  p2        text
    FORM fieldcat_kna1 .
      REFRESH it_fieldcat_kna1.
      CLEAR wa_fieldcat_kna1.
      wa_fieldcat_kna1-fieldname = 'KUNNR'.
      wa_fieldcat_kna1-seltext_l = 'CUSTOMER NUMBER'.
      wa_fieldcat_kna1-datatype = 'CHAR'.
      wa_fieldcat_kna1-outputlen = 30.
      wa_fieldcat_kna1-tabname = 'IT_KNA1'.
      wa_fieldcat_kna1-key = 'X'.
      wa_fieldcat_kna1-hotspot = 'X'.
      wa_fieldcat_kna1-col_pos = 1.
      wa_fieldcat_kna1-emphasize = 'C21'.
      APPEND wa_fieldcat_kna1 TO it_fieldcat_kna1.
      CLEAR wa_fieldcat_kna1.
      wa_fieldcat_kna1-fieldname = 'LAND1'.
      wa_fieldcat_kna1-seltext_l = 'COUNTRY CODE'.
      wa_fieldcat_kna1-datatype = 'CHAR'.
      wa_fieldcat_kna1-outputlen = 30.
      wa_fieldcat_kna1-tabname = 'IT_KNA1'.
      wa_fieldcat_kna1-hotspot = 'X'.
      wa_fieldcat_kna1-col_pos = 2.
      wa_fieldcat_kna1-emphasize = 'C31'.
      APPEND wa_fieldcat_kna1 TO it_fieldcat_kna1.
      CLEAR wa_fieldcat_kna1.
      wa_fieldcat_kna1-fieldname = 'NAME1'.
      wa_fieldcat_kna1-seltext_l = 'CUSTOMER NAME'.
      wa_fieldcat_kna1-datatype = 'CHAR'.
      wa_fieldcat_kna1-outputlen = 30.
      wa_fieldcat_kna1-tabname = 'IT_KNA1'.
      wa_fieldcat_kna1-hotspot = 'X'.
      wa_fieldcat_kna1-col_pos = 3.
      wa_fieldcat_kna1-emphasize = 'C71'.
      APPEND wa_fieldcat_kna1 TO it_fieldcat_kna1.
      CLEAR wa_fieldcat_kna1.
      wa_fieldcat_kna1-fieldname = 'ORT01'.
      wa_fieldcat_kna1-seltext_l = 'COUNTRY '.
      wa_fieldcat_kna1-datatype = 'CHAR'.
      wa_fieldcat_kna1-outputlen = 30.
      wa_fieldcat_kna1-tabname = 'IT_KNA1'.
      wa_fieldcat_kna1-hotspot = 'X'.
      wa_fieldcat_kna1-col_pos = 4.
      wa_fieldcat_kna1-emphasize = 'C51'.
      APPEND wa_fieldcat_kna1 TO it_fieldcat_kna1.
      CLEAR wa_fieldcat_kna1.
    ENDFORM.                    " fieldcat_kna1
    *&      Form  fieldcat_kna2
          text
    FORM fieldcat_mara  .
      wa_fieldcat_mara-fieldname = 'MATNR'.
      wa_fieldcat_mara-seltext_l = 'MATERIAL NUMBER'.
      wa_fieldcat_mara-datatype = 'CHAR'.
      wa_fieldcat_mara-outputlen = 30.
      wa_fieldcat_mara-tabname = 'IT_MARA'.
      wa_fieldcat_mara-key = 'X'.
      wa_fieldcat_mara-hotspot = 'X'.
      wa_fieldcat_mara-col_pos = 1.
      wa_fieldcat_mara-emphasize = 'C21'.
      APPEND wa_fieldcat_mara TO it_fieldcat_mara.
      CLEAR wa_fieldcat_mara.
      wa_fieldcat_mara-fieldname = 'ERSDA'.
      wa_fieldcat_mara-seltext_l = 'CREATED ON'.
      wa_fieldcat_mara-datatype = 'CHAR'.
      wa_fieldcat_mara-outputlen = 30.
      wa_fieldcat_mara-tabname = 'IT_MARA'.
      wa_fieldcat_mara-hotspot = 'X'.
      wa_fieldcat_mara-col_pos = 2.
      wa_fieldcat_mara-emphasize = 'C41'.
      APPEND wa_fieldcat_mara TO it_fieldcat_mara.
      CLEAR wa_fieldcat_mara.
      wa_fieldcat_mara-fieldname = 'ERNAM'.
      wa_fieldcat_mara-seltext_l = 'CREATED BY'.
      wa_fieldcat_mara-datatype = 'CHAR'.
      wa_fieldcat_mara-outputlen = 30.
      wa_fieldcat_mara-tabname = 'IT_MARA'.
      wa_fieldcat_mara-hotspot = 'X'.
      wa_fieldcat_mara-col_pos = 3.
      wa_fieldcat_mara-emphasize = 'C61'.
      APPEND wa_fieldcat_mara TO it_fieldcat_mara.
      CLEAR wa_fieldcat_mara.
    ENDFORM.                    "fieldcat_kna2
    *&      Form  FIELDCAT_VBAK
          text
    FORM fieldcat_vbak.
      wa_fieldcat_vbak-fieldname = 'VBELN'.
      wa_fieldcat_vbak-seltext_l = 'SALES ORDER'.
      wa_fieldcat_vbak-datatype = 'CHAR'.
      wa_fieldcat_vbak-outputlen = 30.
      wa_fieldcat_vbak-tabname = 'IT_VBAK'.
      wa_fieldcat_vbak-hotspot = 'X'.
      wa_fieldcat_vbak-col_pos = 3.
      wa_fieldcat_vbak-emphasize = 'C31'.
      APPEND wa_fieldcat_vbak TO it_fieldcat_vbak.
      CLEAR wa_fieldcat_vbak.
      wa_fieldcat_vbak-fieldname = 'ERDAT'.
      wa_fieldcat_vbak-seltext_l = 'CREATED ON'.
      wa_fieldcat_vbak-datatype = 'DATS'.
      wa_fieldcat_vbak-outputlen = 30.
      wa_fieldcat_vbak-tabname = 'IT_VBAK'.
      wa_fieldcat_vbak-hotspot = 'X'.
      wa_fieldcat_vbak-col_pos = 3.
      wa_fieldcat_vbak-emphasize = 'C41'.
      APPEND wa_fieldcat_vbak TO it_fieldcat_vbak.
      CLEAR wa_fieldcat_vbak.
      wa_fieldcat_vbak-fieldname = 'ERNAM'.
      wa_fieldcat_vbak-seltext_l = 'CREATED BY'.
      wa_fieldcat_vbak-datatype = 'CHAR'.
      wa_fieldcat_vbak-outputlen = 30.
      wa_fieldcat_vbak-tabname = 'IT_VBAK'.
      wa_fieldcat_vbak-hotspot = 'X'.
      wa_fieldcat_vbak-col_pos = 3.
      wa_fieldcat_vbak-emphasize = 'C51'.
      APPEND wa_fieldcat_vbak TO it_fieldcat_vbak.
      CLEAR wa_fieldcat_vbak.
    ENDFORM.                    "FIELDCAT_VBAK
    *&      Form  fieldcat_mard
          text
    FORM fieldcat_mard.
      wa_fieldcat_mard-fieldname = 'MATNR'.
      wa_fieldcat_mard-seltext_l = 'MATERIAL NUMBER'.
      wa_fieldcat_mard-datatype = 'CHAR'.
      wa_fieldcat_mard-outputlen = 30.
      wa_fieldcat_mard-tabname = 'IT_MARD'.
      wa_fieldcat_mard-hotspot = 'X'.
      wa_fieldcat_mard-col_pos = 1.
      wa_fieldcat_mard-emphasize = 'C31'.
      APPEND wa_fieldcat_mard TO it_fieldcat_mard.
      CLEAR wa_fieldcat_mard.
      wa_fieldcat_mard-fieldname = 'WERKS'.
      wa_fieldcat_mard-seltext_l = 'PLANT'.
      wa_fieldcat_mard-datatype = 'CHAR'.
      wa_fieldcat_mard-outputlen = 30.
      wa_fieldcat_mard-tabname = 'IT_MARD'.
      wa_fieldcat_mard-hotspot = 'X'.
      wa_fieldcat_mard-col_pos = 2.
      wa_fieldcat_mard-emphasize = 'C61'.
      APPEND wa_fieldcat_mard TO it_fieldcat_mard.
      CLEAR wa_fieldcat_mard.
      wa_fieldcat_mard-fieldname = 'LGORT'.
      wa_fieldcat_mard-seltext_l = 'STORAGE LOCATION'.
      wa_fieldcat_mard-datatype = 'CHAR'.
      wa_fieldcat_mard-outputlen = 30.
      wa_fieldcat_mard-tabname = 'IT_MARD'.
      wa_fieldcat_mard-hotspot = 'X'.
      wa_fieldcat_mard-col_pos = 3.
      wa_fieldcat_mard-emphasize = 'C81'.
      APPEND wa_fieldcat_mard TO it_fieldcat_mard.
      CLEAR wa_fieldcat_mard.
    ENDFORM  .                    "fieldcat_mard
    **FORM DISPLAY
    *&      Form  Display
          text
    -->  p1        text
    <--  p2        text
    FORM display .
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = sy-repid
      I_CALLBACK_PF_STATUS_SET       = ' '
       I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'.
      IT_EXCLUDING                   =
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = wa_layout
          it_fieldcat                      = it_fieldcat_kna1
          i_tabname                        = 'IT_KNA1'
         it_events                         = it_event_kna1
      IT_SORT                          =
      I_TEXT                           = ' '
        TABLES
          t_outtab                         = it_kna1
       EXCEPTIONS
         program_error                    = 1
         maximum_of_appends_reached       = 2
         OTHERS                           = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = wa_layout
          it_fieldcat                      = it_fieldcat_mara
          i_tabname                        = 'IT_MARA'
          it_events                        = it_event_mara
      IT_SORT                          =
      I_TEXT                           = ' '
        TABLES
          t_outtab                         = it_mara
       EXCEPTIONS
         program_error                    = 1
         maximum_of_appends_reached       = 2
         OTHERS                           = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_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
    **EVENTS FOR KNA1 AND MARA
    *&      Form  EVENT_KNA1
          text
    -->  p1        text
    <--  p2        text
    FORM event_kna1 .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event_kna1
        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.
    ENDFORM.                    " EVENT_KNA1
    *&      Form  EVENT_MARA
          text
    -->  p1        text
    <--  p2        text
    FORM event_mara .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event_mara
        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.
    ENDFORM.                    " EVENT_MARA
    **POPULATING EVENTS
    *&      Form  eventpopulate_kna1
          text
    -->  p1        text
    <--  p2        text
    FORM eventpopulate_kna1 .
      READ TABLE it_event_kna1 INTO wa_event_kna1 WITH KEY name = 'TOP_OF_PAGE'.
      IF sy-subrc = 0.
        wa_event_kna1-form = 'TOP_OF_PAGE_KNA1'.
        MODIFY it_event_kna1 FROM wa_event_kna1 TRANSPORTING form WHERE name = wa_event_kna1-name.
      ENDIF.
    READ TABLE it_event_kna1 INTO wa_event_kna1 WITH KEY name = 'USER_COMMAND'.
    IF sy-subrc = 0.
       wa_event_kna1-form = 'USER_COMMAND_KNA1'.
       MODIFY it_event_kna1 FROM wa_event_kna1 TRANSPORTING form WHERE name = wa_event_kna1-name.
    ENDIF.
    ENDFORM.                    " eventpopulate_kna1
    *&      Form  eventpopulate_mara
          text
    -->  p1        text
    <--  p2        text
    FORM eventpopulate_mara .
      READ TABLE it_event_mara INTO wa_event_mara WITH KEY name = 'TOP_OF_PAGE'.
      IF sy-subrc = 0.
        wa_event_mara-form = 'TOP_OF_PAGE_MARA'.
        MODIFY it_event_mara FROM wa_event_mara TRANSPORTING form WHERE name = wa_event_mara-name.
      ENDIF.
    READ TABLE it_event_mara INTO wa_event_mara WITH KEY name = 'USER_COMMAND'.
    IF sy-subrc = 0.
       wa_event_mara-form = 'USER_COMMAND_MARA'.
       MODIFY it_event_mara FROM wa_event_mara TRANSPORTING form WHERE name = wa_event_mara-name.
    ENDIF.
    ENDFORM.                    " eventpopulate_mara
    **TOP OF PAGE
    *&      Form  TOP_OF_PAGE_KNA1
          text
    FORM top_of_page_kna1.
    wa_listheader-typ = 'H'.
    wa_listheader-info = 'CUSTOMER DETAILS' .
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
      WRITE:/ 'CUSTOMER DETAILS'.
    ENDFORM.                    "TOP_OF_PAGE_KNA1
    *&      Form  TOP_OF_PAGE_MARA
          text
    FORM top_of_page_mara.
    wa_listheader-typ = 'H'.
    wa_listheader-info = 'MATERIAL DETAILS' .
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
      WRITE:/ 'MATERIAL DETAILS' .
    ENDFORM.                    "TOP_OF_PAGE_KNA1
    **CODE FOR SECOND LIST DISPLAY FOR VBAK
    *&      Form  USER_COMMAND
          text
         -->UCOMM      text
         -->R_SELFIELD text
    FORM user_command
         USING ucomm LIKE sy-ucomm
               r_selfield TYPE slis_selfield.
    CASE UCOMM.
      when '&IC1'.
        CASE R_SELFIELD-TABNAME.
          WHEN 'IT_KNA1'.
            DATA: CUST(10) TYPE n.
            CUST = r_selfield-value.
             SELECT vbeln erdat ernam
                    FROM vbak
                    INTO TABLE it_vbak
                    WHERE kunnr = cust.
             PERFORM fieldcat_vbak.
             PERFORM display_vbak.
          WHEN 'IT_MARA'.
            DATA: MAT(18) TYPE N.
            MAT = R_selfield-value.
              SELECT matnr werks lgort
                   FROM mard
                   INTO TABLE it_mard
                   WHERE matnr = mat.
            PERFORM fieldcat_mard.
            PERFORM display_mard.
         ENDCASE.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    **&      Form  USER_COMMAND_MARA
          text
         -->UCOMM      text
         -->S_SELFIELD text
    *FORM user_command_mara
        USING ucomm LIKE sy-ucomm
              s_selfield TYPE slis_selfield.
    SELECT matnr werks lgort
            FROM mard
            INTO TABLE it_mard
            WHERE matnr = s_selfield-value.
    PERFORM fieldcat_mard.
    PERFORM display_mard.
    *ENDFORM.                    "USER_COMMAND_MARA
    *&      Form  DISPLAY_VBAK
          text
    -->  p1        text
    <--  p2        text
    FORM display_vbak .
    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          = ' '
      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                      =
      I_GRID_SETTINGS                   =
       IS_LAYOUT                         = wa_layout
       IT_FIELDCAT                       = it_fieldcat_vbak
      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
      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                          = it_vbak
    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_VBAK
    *&      Form  display_mard
          text
    FORM display_mard .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         i_callback_program             = sy-repid
      I_CALLBACK_PF_STATUS_SET       = ' '
        i_callback_user_command        = 'USER_COMMAND_MARD'
      I_STRUCTURE_NAME               =
         is_layout                      = wa_layout
         it_fieldcat                    = it_fieldcat_mard
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
        it_events                      = it_event_mard
      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
      IR_SALV_LIST_ADAPTER           =
      IT_EXCEPT_QINFO                =
      I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
          t_outtab                       = it_mard
    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_mard
    regards
    prasanth

  • USER-Command  at ALV report.

    Hi Guys,
    I've created one ALV report displaying SALES ORDER created.My requirement is if I click on SALES Document no it should take me into VA03(sales orde display) transaction so that I can see all the data related for that document no. I have used BAPI .

    Hi guys,
    I have written this code but still it is not taking me into VAO3 Transaction. What else I should write?
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_BUFFER_ACTIVE          = 'X'
               I_BACKGROUND_ID          = 'ALV_BACKGROUND'
                I_CALLBACK_PROGRAM       = L_REPID
               I_CALLBACK_PF_STATUS_SET = L_STATUS
                I_CALLBACK_USER_COMMAND  = L_USER_COMMAND
              I_STRUCTURE_NAME         = 'VBUK'
               IS_LAYOUT                = LF_LAYOUT
                IT_FIELDCAT              = LF_FIELDCAT[]
              IT_EXCLUDING             =
               IT_SPECIAL_GROUPS        = LF_SP_GROUP
              I_DEFAULT                = 'X'
               I_SAVE                   = L_SAVE
               IS_VARIANT               = L_VARIANT
               IT_EVENTS                = LF_EVENTS[]
              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                 = IT_HEADER .
    FORM L_USER_COMMAND USING vl_ucomm LIKE sy-ucomm     
                      rs_selfield TYPE slis_selfield.
      CASE vl_ucomm.
        WHEN '&IC1'.
          IF rs_selfield-fieldname = 'DOC_NO'
          OR rs_selfield-fieldname = 'SO_KUNNR' .
          SET PARAMETER ID 'AUN' FIELD rs_selfield-VALUE.
            CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
          ENDIF.
        WHEN OTHERS.
       EXIT.
      ENDCASE.
    ENDFORM.

  • Not diaplsy buttons on alv grid display

    Hi,
    In the below code,i dont understand where i made a mistake,i used a user command on alv it's working but not display the buttons on a output.Please check the below code and solve it.
    REPORT  Y_ALV_VERSION.
    TYPE-POOLS : SLIS.
    DATA : BEGIN OF ITAB OCCURS 0,
           MATNR LIKE MARC-MATNR,       "Plant Data for Material-Material Number
           WERKS LIKE MARC-WERKS,       "Plant Data for Material-Plant
           EKGRP LIKE MARC-EKGRP,       "Plant Data for Material-Purchasing Group
           END OF ITAB.
    DATA : BEGIN OF ITAB1 OCCURS 0,
           MATNR LIKE MARD-MATNR,       "Storage Location Data for Material-Material Number
           WERKS LIKE MARD-WERKS,       "Storage Location Data for Material-Plant
           LGORT LIKE MARD-LGORT,       "Storage Location Data for Material-Storage Location
           END OF ITAB1.
    DATA : REPID LIKE SY-REPID.
    DATA : V_LINE TYPE SY-TABIX.
    DATA : X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA : I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : I_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
    DATA : X_ALV_EVENTS TYPE SLIS_ALV_EVENT.
    DATA : T_ALV_EVENTS TYPE SLIS_T_EVENT.
    DATA : X_ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
    *********************START-OF-SELECTION***************
    START-OF-SELECTION.
      PERFORM SUB_SELECT_RECORD.
      PERFORM SUB_PREPARE_FIELDCATALOG.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = T_ALV_EVENTS
    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 T_ALV_EVENTS INTO X_ALV_EVENTS WITH KEY NAME = 'USERCOMMAND'.
      IF SY-SUBRC = 0.
        X_ALV_EVENTS-FORM = 'USER_ACTION'.
        MODIFY T_ALV_EVENTS FROM X_ALV_EVENTS INDEX SY-TABIX.
      ENDIF.
      READ TABLE T_ALV_EVENTS INTO X_ALV_EVENTS WITH KEY NAME = 'PF_STATUS_SET'.
      IF SY-SUBRC = 0.
        X_ALV_EVENTS-FORM = 'PF_STATUS'.
        MODIFY T_ALV_EVENTS FROM X_ALV_EVENTS INDEX SY-TABIX.
      ENDIF.
      PERFORM SUB_DETERMINE_ALV_LAYOUT.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = REPID
       I_CALLBACK_PF_STATUS_SET          = 'PF_STATUS'
       I_CALLBACK_USER_COMMAND           = '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                      =
      I_GRID_SETTINGS                   =
          IS_LAYOUT                         = X_ALV_LAYOUT
          IT_FIELDCAT                       = I_FIELDCAT[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
       I_DEFAULT                         = 'X'
       I_SAVE                            = 'A'
      IS_VARIANT                        =
          IT_EVENTS                         = T_ALV_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
      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                          = 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.
    *&      Form  PF_STATUS
          text
         -->RT_EXTAB   text
    FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'ALV_PF_STATUS'.  " excluding rt_extab.
    ENDFORM.                    "PF_STATUS
    *&      Form  user_action
          text
         -->R_UCOMM      text
         -->RS_SELFIELD  text
    FORM USER_ACTION USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      DATA : OKCODE TYPE SY-UCOMM.
      OKCODE = R_UCOMM.
      CLEAR R_UCOMM.
      V_LINE = RS_SELFIELD-TABINDEX.
      CASE OKCODE.
        WHEN 'PICK'.
          READ TABLE ITAB INDEX V_LINE.
          PERFORM SUB_SELECT_RECORD1.
          PERFORM SUB_PREPARE_FIELDCATALOG1.
          CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = 'REPID'
      I_CALLBACK_PF_STATUS_SET          = '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                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
      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
      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                          = ITAB1
    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.
        WHEN 'EXIT'.
          RS_SELFIELD-EXIT = 'X'.
      ENDCASE.
    ENDFORM.                    "user_action
    *&      Form  SUB_PREPARE_FIELDCATALOG
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_PREPARE_FIELDCATALOG .
      X_FIELDCAT-SELTEXT_L = 'MATERIAL'.
      X_FIELDCAT-DATATYPE = 'CHAR'.
      X_FIELDCAT-OUTPUTLEN = 18.
      X_FIELDCAT-FIELDNAME = 'MATNR'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO I_FIELDCAT.
      CLEAR X_FIELDCAT.
      X_FIELDCAT-SELTEXT_L = 'PLANT'.
      X_FIELDCAT-DATATYPE = 'CHAR'.
      X_FIELDCAT-OUTPUTLEN = 4.
      X_FIELDCAT-FIELDNAME = 'WERKS'.
      APPEND X_FIELDCAT TO I_FIELDCAT.
      CLEAR X_FIELDCAT.
      X_FIELDCAT-SELTEXT_L = 'PUR.GROUP'.
      X_FIELDCAT-DATATYPE = 'CHAR'.
      X_FIELDCAT-OUTPUTLEN = 4.
      X_FIELDCAT-FIELDNAME = 'EKGRP'.
      X_FIELDCAT-EDIT = 'X'.
      APPEND X_FIELDCAT TO I_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " SUB_PREPARE_FIELDCATALOG
    *&      Form  SUB_SELECT_RECORD
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_SELECT_RECORD.
      SELECT MATNR WERKS EKGRP FROM MARC INTO TABLE ITAB UP TO 10 ROWS WHERE WERKS = '1000'.
    ENDFORM.                    " SUB_SELECT_RECORD
    *&      Form  SUB_DETERMINE_ALV_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_DETERMINE_ALV_LAYOUT .
      X_ALV_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      X_ALV_LAYOUT-F2CODE = 'PICK'.
      X_ALV_LAYOUT-WINDOW_TITLEBAR = 'PLANT DATA'.
      X_ALV_LAYOUT-KEY_HOTSPOT = 'X'.
    ENDFORM.                    " SUB_DETERMINE_ALV_LAYOUT
    *&      Form  SUB_PREPARE_FIELDCATALOG1
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_PREPARE_FIELDCATALOG1 .
      X_FIELDCAT-SELTEXT_L = 'MATERIAL'.
      X_FIELDCAT-DATATYPE = 'CHAR'.
      X_FIELDCAT-OUTPUTLEN = 18.
      X_FIELDCAT-FIELDNAME = 'MATNR'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO I_FIELDCAT1.
      CLEAR X_FIELDCAT.
      X_FIELDCAT-SELTEXT_L = 'PLANT'.
      X_FIELDCAT-DATATYPE = 'CHAR'.
      X_FIELDCAT-OUTPUTLEN = 4.
      X_FIELDCAT-FIELDNAME = 'WERKS'.
      APPEND X_FIELDCAT TO I_FIELDCAT1.
      CLEAR X_FIELDCAT.
      X_FIELDCAT-SELTEXT_L = 'Storage Location'.
      X_FIELDCAT-DATATYPE = 'CHAR'.
      X_FIELDCAT-OUTPUTLEN = 4.
      X_FIELDCAT-FIELDNAME = 'LGORT'.
      X_FIELDCAT-EDIT = 'X'.
      APPEND X_FIELDCAT TO I_FIELDCAT1.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " SUB_PREPARE_FIELDCATALOG1
    *&      Form  SUB_SELECT_RECORD1
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_SELECT_RECORD1 .
      SELECT MATNR WERKS LGORT FROM MARD INTO TABLE ITAB1 WHERE MATNR = ITAB-MATNR AND WERKS = ITAB-WERKS.
      REFRESH I_FIELDCAT1.
    ENDFORM.                    " SUB_SELECT_RECORD1
    thanks and regards

    Consider this logic.
    DATA:
      g_exclude                  TYPE slis_t_extab.
    *       FORM display_alv_report                                       *
    FORM display_alv_report.
      PERFORM fieldcat_init      USING g_fieldcat[].
      PERFORM build_sort_fields  USING g_sort[].
      PERFORM eventtab_build     USING g_events[]
                                       g_events_ex[].
      PERFORM layout_build       USING g_layout.
      PERFORM exclude_icons.
      PERFORM list_view.
    ENDFORM.                    " display_alv_report.
    *      Form  exclude_icons
    FORM exclude_icons.
      APPEND '&ETA' TO g_exclude.     "Details
    *  APPEND '&OUP' TO g_exclude.     "Sort Up
    *  APPEND '&ODN' TO g_exclude.     "Sort Down
      APPEND '&ILT' TO g_exclude.     "Set Filter
      APPEND '&UMC' TO g_exclude.     "Sum
      APPEND '&RNT_PREV' TO g_exclude.     "Print preview
    *  APPEND '&VEXCEL' TO g_exclude.     "Excel
      APPEND '&AQW' TO g_exclude.     "Word processing
      APPEND '%PC' TO g_exclude.     "Local File
      APPEND '%SL' TO g_exclude.     "Mail recepient
      APPEND '&ABC' TO g_exclude.     "ABC Analysis
      APPEND '&GRAPH' TO g_exclude.     "Graphic
    *  APPEND '&OL0' TO g_exclude.     "Change layout
    *  APPEND '&OAD' TO g_exclude.     "Select layout
      APPEND '&AVE' TO g_exclude.     "Save Layout
      APPEND '&INFO' TO g_exclude.  "Information
    ENDFORM.                    " exclude_icons
    FORM list_view.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program = g_repid
                is_layout          = g_layout
                it_sort            = g_sort[]
                it_events          = g_events[]
                it_fieldcat        = g_fieldcat[]
                i_save             = g_save
                it_excluding       = g_exclude     "<== Exclude
           TABLES
                t_outtab           = it_work
           EXCEPTIONS
                program_error      = 1
                OTHERS             = 2.
      IF sy-subrc <> 0.
        MESSAGE e208(00) WITH 'Error: ALV Grid'.
      ENDIF.
    ENDFORM.                    " layout_build

  • Alv grid to excel question

    Hello, I have a report with an selection screen with a few input parameters. This results in an alv grid being displayed. The users downloads the alv grid to excel. This works fine.
    I'd like to include the input parameters as the top row in the downloaded excel, on top of the result set. Is this possible? How do you do it?
    Best regards /Otto

    This data would have to be included in the ALV grid itself(assuming that you are using the standard excel functionality embedded into the ALV grid). 
    There are others ways to get around this.  You could add a new button to the applicatoin toolbar, where then you would handle the building of the excel file in your custom code.
    REgards,
    Rich Heilman

  • ALV GRID WEB DYNPRO ABAP

    I created an alv grid in my web dynpro...
    Everything worked fine ! Then I needed to add a column to the alv grid...
    SO
    1 - Chnaged the structure un SE11
    2 - Update component controller context so that the field is displayed
    3 - Update all bindings
    4 - Update biding between DATA and ALV Table
    But the column is not displayed by default in the alv grid ! But if I go to settings, the colomn is available...
    What should i do to display this column by default ???
    Regards,
    SteKam

    Yatah !
    I manage to show the columns by default !
    We discovered it was stored in the user settings...
    Then the question is ... "How do I disable user settings on ALV Grid"
    Thanks in advance!
    Stekam

  • Hide alv grid PR custom subscreen

    Hello All,
    I have a custom subscreen on PR ( bulit via screen exit) with ALV grid and some screen elements ( to get input data from user) on it.
    In create and change PR mode, I need to get the input ( could be multiple rows with the help of create next icon )from user and update ALV grid with the input values. But in PR display mode, I need to hide the ALV grid.
    I tried using desctructor method FREE, but dint work.
    Any suggestions?
    Thanks,
    Chandra

    I have a similiar problem:
    I have a dynpro where there are different possibilities for ALV grids to be shown. I have 10 containers (that's the maximum number of ALV grids that can appear) and want to use the highest first. Now, it might be that I want to show another ALV in a container I have had an ALV before, therefore I must hide / delete / destroy the previous ALV in this container.
    I use the FREE( ) method of the alv controls, I clear and free all references, but still, even after leaving and accessing the dynpro again, the ALV is shown. That's why I'd need some help here too...
    Thanks in advance, Christopher

  • Editable rows on ALV Grid

    Hi.
    How can I make one column user-editable on ALV Grid?
    Thanks in advance,
    Brian Gonsales

    Hi,
      Check out the below links:
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    Thanks.

Maybe you are looking for

  • APEX 3.0 print report error (empty file).

    I installed BI 10.1.3.2.0 successfully. I tested my convert servlet (which comes with BI Publisher) by trying to go there directly in browser: http://roman:80/xmlpserver/convert I get the message in Firefox: "500 Internal Server Error Servlet error:

  • Variable in Report Title?

    Hi I'm fairly new to ORACLE BI and want to output the Date in the Filename of the reports when the users run them. So when they download the report as XLS PDF etc is shows "filename DD-MM-YY". Is this possible? Many Thanks Ed

  • How to manage photo albums in iPad?

    Well II6 is here and looks like you can create albums on iPad now. Great. However, also discovered that once you add photos to them, those albums dont sync back to your mac (itunes) or iphoto. I use iphoto, and can sync albums down to my ipad (this i

  • Relation between Prod. Hierarchy and Profit Centre

    Dearest all, does anybody know what the relation between prod. hierarchies and profit centre? actually, i am trying to display total of actual line items (table GPCPT, if i am not wrong). The total value grouped by Profit Centre? But I want to displa

  • Changing one instance of a recurring meeting does not allow an update to be sent to all attendees

      The Outlook Community seems to think this an Exchange problem, although I'm skeptical: Have a user that is executive admin, handles many calendars and sets up many recurring meetings that have several attendees. It would appear that occasionally so