ALV grid control, Adding the push Button in the Toolbar

Hello All,
I am facing a problem when trying to do calculation based on the button added at the toolbar of interactive ALV list.
When I click on the toolbar button Compute, the ALV should calculate the
multiplication of the Qty (manually entered by a user) & price per unit already available in the ALV & show it the Column Total value.
Presently when I try to do this using
  Method handle_user_command.
   modifying the inetrnal table GT_FINAL_OUTPUT
   with the Total price value .
   & updating the column Total price (Qty * price) in the Internal table
After doing this  I am agin calling the below function
    CALL METHOD g_grid->set_table_for_first_display
    EXPORTING
    i_structure_name = 'GT_FINAL_OUTPUT'
    is_layout = gs_layout
    CHANGING
    it_fieldcatalog = gt_fieldcat
     it_outtab = GT_FINAL_OUTPUT[].
At above function it gives  short dump or sometimes it does not update the  ALV screen with the new updated value of Total price .
The short dump comes states  the error of unassigned field symbol.
Kindly suggest a program where we can do manipulation at the editable ALV.
Or solution to above issue .
Regards,
Anurag

You should only be calling the SET_TABLE_FOR_FIRST_DISPLAY one time in the PBO of your screen,  otherwise you should be using the REFRESH_TABLE_DISPLAY method.  IN your PBO, check that the instance of the alv_container is alive, if so, do not call the SET method, rather call the REFRESH method.
if alv_container is initial.
    create object......
    create object g_grid.....
    call method g_grid->set_table_for_first_display......
else.
call method   g_grid->refresh_table_display( ).
endif.
Regards,
Rich HEilman

Similar Messages

  • How to add the push button on the apllication tollbar of IL02 tcode

    Hi Friends,
    I have to add the push button on the application tool bar of the IL02.when that push button is pressed then some operation to be performed.Could you please suggest how to add.Is there any screen exit if yes what is that.
    With out screen exits if there is any way ?
    Thanks and regards,
    shyla

    HI Vicky ,
                      if u want an interactive ALV report , there are lot of forums already having the solution for that , but let me give u the solution anyway.
    In the function module "REUSE_ALV_GRID_DISPLAY" , import parameters
         I_CALLBACK_PF_STATUS_SET          = 'FLIGHT'
         I_CALLBACK_USER_COMMAND           = 'BUTTON_CLICK'
    has to be supplied to this function module . The PF status is where u hav created the two buttons , that PF status has to be given here .If the user clicks on the button then it is handled by the form routines . Inside the sub-routine based on the button the user has selected u could perform the action.
    FORM FLIGHT    USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'FLIGHT' EXCLUDING RT_EXTAB.
    ENDFORM.
    Here the "Flight" is the PF_status .
    FORM BUTTON_CLICK USING UCOMM type SY-UCOMM
                           SELFIELD type SLIS_SELFIELD.
      CASE UCOMM.
        WHEN 'BUTTON!' .
    write ur code for button 1.
      WHEN "BUTTON"
      *Write ur code for button2 .
    end case.
    endform.
    for any queries reply back.
    regards

  • Adding a push button on the report toolbar

    adding a save button on the report toolbar, so that after clicking the button, the data fetched on the report will be stored in the application server.

    Hi
    to automate this process ,best way is to create a Z rport and there u can submit this sap standard report and get its output into an Internal table and then u can write this internal table to application server via following demo code -
    this is code for both (download /upload),u can not use CG3y and CG3z as u want to do it as a background job ..
    *& Report ZGILL_AS *
    REPORT ZGILL_AS message-id rp .
    tables: pa0001,pa0002.
    select-options s_pernr for pa0001-pernr no intervals MODIF ID XYZ.
    parameters: p_dwnld AS CHECKBOX ,
    p_upld AS CHECKBOX DEFAULT 'X'.
    parameters: P_DSNI(75) TYPE C MODIF ID ABG DEFAULT
    '/usr/local/sapdata/amit.dat' LOWER CASE.
    data: begin of itab occurs 0,
    pernr(8),
    sp1(1) value ',',
    werks(4),
    sp2(1) value ',',
    persg(1),
    sp3(1) value ',',
    persk(2),
    end of itab.
    data: s_eof(3).
    start-of-selection.
    if p_upld = 'X'.
    OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.
    PERFORM FETCH_DATA.
    STOP.
    elseif p_dwnld = 'X'.
    OPEN DATASET P_DSNI FOR INPUT IN LEGACY TEXT MODE.
    IF SY-SUBRC NE 0.
    MESSAGE E016 WITH
    'Error opening seq. file, RC:' SY-SUBRC.
    EXIT.
    ENDIF.
    CLEAR S_EOF.
    DO.
    PERFORM FETCH_file.
    IF S_EOF EQ 'YES'. stop. ENDIF.
    ENDDO.
    endif.
    END-OF-SELECTION.
    if itab[] is not initial.
    perform print_file1 tables itab.
    else.
    write:/ 'No records exists'.
    endif.
    *& Form FETCH_DATA
    text
    --> p1 text
    <-- p2 text
    FORM FETCH_DATA .
    SELECT * FROM PA0001 WHERE PERNR IN S_PERNR.
    MOVE-CORRESPONDING PA0001 TO ITAB.
    TRANSFER ITAB TO P_DSNI.
    APPEND ITAB.
    ENDSELECT.
    CLOSE DATASET P_DSNI.
    ENDFORM. " FETCH_DATA
    *& Form FETCH_file
    text
    --> p1 text
    <-- p2 text
    FORM FETCH_file .
    READ DATASET P_DSNI INTO itab.
    append itab.
    clear itab.
    IF SY-SUBRC NE 0.
    S_EOF = 'YES'. EXIT.
    ENDIF.
    ENDFORM. " FETCH_file
    *& Form print_file1
    text
    -->P_ITAB text
    FORM print_file1 tables P_ITAB structure itab .
    write:/2 'EmpNo',
    14 'Personnel Area',
    34 'Emp Group',
    47 'Emp SubGroup'.
    skip 1.
    loop at p_itab.
    write:2 p_itab-pernr,
    14 p_itab-werks,
    34 p_itab-persg,
    47 p_itab-persk.
    skip 1.
    endloop.
    ENDFORM. " print_file1
    <b>Reward if usefull</b>

  • ALV GRID - to include user defined buttons in the output

    Hi,
    Currently I am working on ALV grid output.
    Along with the standard buttons, I need to include my own push buttons.
    When I try to include it using pf-status like this,
    passing parameter  in alv
    I_callback_pf_status_set = G_status
    FORM STANDARD_02 USING EXTAB USING SLIS_T_EXTAB
    set pf-status 'PF_STATUS' EXCLUDING EXTAB.
    ENDFORM
    I have included Confirm and exit buttons
    In the output it shows only the button which I created .
    I want to get both standard buttons which gets displayed when using REUSE_ALV_GRID_DISPLAY and the newly created one .
    Plz help me to resolve this .
    I am just passing my own internal table values to the grid .
    Thanks in advance.
    Regards,
    Uma

    hi
    good
    create ur own GUI status in ur program using SET PF-STATUS '--'. now give that program name and pf status name while u r copying that standard status ie.,of ALV grid Go to transaction SE41 (Menu painter). In the initial screen give the program name SAPLKKBL In the status give STANDARD Then go to the menu bar.in that follow this menu User Interface>Copy--->Status. Then a pop up will appear to give ur program name and the status name.
    thanks
    mrutyun^

  • Add a New line to ALV Grid control

    Hi experts,
       My requirement is after filling ALV grid, user will select a + button from the menu, I need to add a new line next to the selected ALV line (Like in a table control).  Does it posible to do this? If can any body tell me how I can do this.
    Regards,
    Venkat.

    Hi Venkat...
    I have tried this and it worked...
    Just copy paste this program...
    Note : U will have to create a new PF status for this... and give the Function code as given in my program... then only it will work...
    *& Report  Z_ALV_TRAINING_LIST_EVENTS
    REPORT  Z_ALV_TRAINING_LIST_EVENTS.
    Tables  *************
    TABLES : T001.
    Type Pools Used  **********
    TYPE-POOLS : SLIS.
    Types Declared  **********
    Internal Tables Declare  ************
    DATA : IT_company    TYPE STANDARD TABLE OF T001 INITIAL SIZE 0 WITH HEADER LINE,
           IT_FIELD_CAT  TYPE SLIS_T_FIELDCAT_ALV,
           it_alv_event  type SLIS_T_EVENT.
    Select Data  ***********
    start-of-selection.
    SELECT * FROM T001 INTO TABLE IT_company.
    Make Field Catalog  ******
    PERFORM MAKE_FIELD_CATALOG.
    get evente  *****
    perform get_alv_events.
    Display ALV  *********
    end-of-selection.
    PERFORM DISPLAY_ALV_LIST.
    *&      Form  make_field_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM MAKE_FIELD_CATALOG .
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
      I_PROGRAM_NAME               =
      I_INTERNAL_TABNAME           =
       I_STRUCTURE_NAME             = 'T001'
      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.
    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_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
       I_CALLBACK_PROGRAM             = sy-repid
        I_CALLBACK_PF_STATUS_SET       = 'SET_MY_PF_STATUS'
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      = fl_layout
       IT_FIELDCAT                    = it_field_cat[]
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
       I_SAVE                         = 'X'
      IS_VARIANT                     = '/TEST_VV'
        IT_EVENTS                      = it_alv_event
      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_company
    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_alv_list
    *&      Form  get_alv_events
          text
    -->  p1        text
    <--  p2        text
    FORM get_alv_events .
    data : wa type slis_alv_event.
      wa-name = 'USER_COMMAND'.
      wa-form = 'SUB_MY_PF_EVENT'.
      append wa to it_alv_event.
    ENDFORM.                    " get_alv_events
    *&      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.
      data : wa type t001.
      case p_comm.
        when 'BACK'.
          leave program.
        when 'EXIT'.
          leave program.
        when 'NEW'.
          clear wa.
          insert wa into it_company[] index p_sel_field-tabindex.
          PERFORM DISPLAY_ALV_LIST.
      endcase.
    ENDFORM.                    " sub_my_pf_event
    *&      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 this was helpful....

  • Can we add page numbers to ALV Grid Control.

    Hi All,
    1.My requirement is to display page numbers when we down load the list in to EXCEL.
    Can we do this in ALV Grid Control.
    2.Can we display the page numbers in the SAP Query,when we down load the out put list in to the EXCEL.
    Thanks & Regards,
    Seshadri G

    Hi Seshadri,
    No, it is not possible to print the page number when you download the list to EXCEL. Because in ALV grid the report output is display as table contorl and this data can not be divided into page when you download to EXCEL.
    Regards,
    Satya.

  • Color of the push button in Forms 6i

    HI,
    I want to change the color of the push button from the default gray color to something else and also the font type. Is it possible? If yes, how to do it ?

    On Microsoft Windows, the colors of buttons, window title bars, and window borders are controlled by the Windows Control Panel color
    settings specified for these elements. You cannot override these colors in Form Builder even by using visual attributes.
    The button color attributes are controlled exclusively by the Color facility in the Control Panel.
    To define button color attributes do the following :
    1. To do this go to 'Settings' + 'control panel'.
    2. Double-click on 'display' and select 'appearance' from the menu .
    3. Select '3D Objects' from the 'item' list .
    4. The background color and the foreground color can be changed to your favourite ones.
    But the important thing to note here is that this will affect all the 3D objects in all the applications in your system .
    Or you can try this workaround if it is suitable. Use a display item with a "Bevel" property of "Raised" and the "Default Value"
    property whatever the label should be. Then attach a WHEN-MOUSE-CLICK trigger to it. You can change the foreground and background colors to whatever you want since it's really just a field.
    Abhijith Unnikannan,
    Oracle Support Services
    null

  • Push button in the application tool bar in the standard LDB PNP

    Hi ABAPERS,
    I have a  requirement that in the selction screen to use the standard LDB PNP beyond that I need to pass one push button in the selection screen 1000 ( in the application tool bar beside execute button) actually i  passes the push button in the gui status but its not refelcting in the output  and in the initilization event also i passed even then its noty working,
    initialization.
      move 'Cluster ID'(010) to sscrfields-functxt_01.
    Thanks and Regards,
    Deepthi.

    Pavan,
    write code like this
    TABLES: USR02,       "Logon data
            SSCRFIELDS.  "FIELDS ON SELECTION SCREENS
    STANDARD SELECTION SCREEN FOR SCROLLING LEFT AND RIGHT
    SELECTION-SCREEN: FUNCTION KEY 1.
    SELECTION-SCREEN begin of BLOCK b1.
      PARAMETERs p1 type i.
      SELECTION-SCREEN end of BLOCK b1.
    INITIALIZATION.
    SCREEN ICON LEFT AND RIGHT
      SSCRFIELDS-FUNCTXT_01 = 'Button'.
      start-OF-SELECTION.
    Thanks
    Bala Duvvuri

  • Can we disable the default push buttons on the ALV Grid

    Hi,
        Can we disable the default push buttons on the ALV
    Grid Control...
        If so, pls send me the procedure...
    thanks and regards
       raghu

    Hi,
    In the PBO:
      PERFORM f9100_exclude_functions USING :
                             i_exclude[]  '&CHECK',
                             i_exclude[]  '&REFRESH',
                             i_exclude[]  '&LOCAL&CUT' ,
                             i_exclude[]  '&LOCAL&COPY',
                             i_exclude[]  '&LOCAL&PASTE',
                             i_exclude[]  '&LOCAL&PASTE_NEW_ROW',
                             i_exclude[]  '&LOCAL&UNDO' ,
                             i_exclude[]  '&LOCAL&APPEND',
                             i_exclude[]  '&LOCAL&INSERT_ROW',
                             i_exclude[]  '&LOCAL&DELETE_ROW',
                             i_exclude[]  '&SORT_ASC',
                             i_exclude[]  '&SORT_DSC',
                             i_exclude[]  '&FIND',
                             i_exclude[]  '&SUMC',
                             i_exclude[]  '&SUBTOT',
                             i_exclude[]  '&MINIMUM',
                             i_exclude[]  '&MAXIMUM' ,
                             i_exclude[]  '&VGRID' ,
                             i_exclude[]  '&VEXCEL' ,
                             i_exclude[]  '&VCRYSTAL',
                             i_exclude[]  '&HTML',
                             i_exclude[]  '&MAINTAIN',
                             i_exclude[]  '&SAVE',
                             i_exclude[]  '&GRAPH',
                             i_exclude[]  '&HELP',
                             i_exclude[]  '&ALL' ,
                             i_exclude[]  '&SAL' .
    *                         i_exclude[]  '&EXCLALLFC'.
    *&      Form  f9100_exclude_functions
    * This form exclude buttons  from the toolbar.
    *      -->P_IEXCLUDE  text
    *      -->P_1150   text
    FORM f9100_exclude_functions USING   pexclude LIKE i_exclude
                                   value(pfunction).
      DATA: l_exclude TYPE ui_func.
      l_exclude = pfunction.
      APPEND l_exclude TO pexclude.
    ENDFORM.                    " f9100_exclude_functions
    This will exculde the default push buttons.
    Let us know if it works for you.
    Regards,
    Anjali

  • Wan to add push button in the output of ALV Grid display.

    Hi Friends,
    I wan to add a Push button in the output of ALV GRID display with STANDARD ikons.
    How to copy standard ikons of GRID output.
    How to apply the copied status into my code.
    Regards,
    Viji

    Hi,
    Goto SE41, create a pf-status for your alv report program.
    On the next screen, click menu EXTRAS --> click option ADJUST TEMPLATES and select radiobutton LIST VIEWER --> you will get all standard buttons of alv in the pf-status.
    Delete the unwanted buttons and also you can add new buttons if reqd.
    Activate pf-status --> and apply in alv program.
    Now to apply this pf-status in your alv report follow code:-
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = v_rep_id       " report id
         i_callback_pf_status_set          = 'PF'           " for PF-STATUS
         i_callback_user_command           = 'USER_COMMAND' " for User-Command
         is_layout                         = wa_layout      " for layout
         it_fieldcat                       = it_field       " field catalog
         it_sort                           = it_sort        " sort info
        TABLES
          t_outtab                          = it_final      " internal table
       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
    *       SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
    *       ON WHICH THE ALV GRID IS DISPLAYED
    *       -->RT_EXTAB
    FORM pf USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZTG_STAT'. "<--pass pf-status name here
    ENDFORM.                    "pf
    *&      Form  USER_COMMAND
    *       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
    *       AND EXECUTE THE APPROPIATE CODE
    *      -->LV_OKCODE   used to capture the function code
    *                     of the user-defined push-buttons
    *      -->L_SELFIELD   text
    FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
    * assign the function code to variable v_okcode
      lv_okcode = sy-ucomm.
    * handle the code execution based on the function code encountered
      CASE lv_okcode.
        WHEN '<function_code>'. "<--to handle user actions
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    Hope this helps you.
    Regards,
    Tarun

  • Problem in handling double click in the second alv grid control

    Hi all,
    I have a screen. In the screen , I have 2 custom container and each custom container has 1 alv grid control.
    I need to handle double click event for both of alv grid controls in my screen.
    I defined 2 local event handler class for each alv grid and defined 2 handle_double_click event.
    In the first Alv grid double click works fine , everything is ok, world is peaceful.
    But in the second alvgrid, the row parameters (E_ROW, E_COLUMN, ES_ROW_NO) comes initial so i cannot handle it.
    All i need is to call a different transaction (displaying the equipment-IE03) when user double-click on a field in the second alv grid control. I tried to use hotspot_click event too but it does'nt give the row id either.
    I read some posts in the forms ([Double click event of alv grid control|Double click event of alv grid control]).
    I tried everything but nothing works.
    Please help. Your answers will be appreciated.

    Hello Eagle
    I am not sure where the problem lies in your case but sample report ZUS_SDN_THREE_ALV_GRIDS_01 shows that you can always find out the current cell after the double-click event (in any case you have the current cell already as IMPORTING parameters of the event):
    *& Report  ZUS_SDN_THREE_ALV_GRIDS_01
    *& Flow logic of screen '0100' (no screen elements, ok-code => GD_OKCODE):
    **    PROCESS BEFORE OUTPUT.
    **      MODULE STATUS_0100.
    **    PROCESS AFTER INPUT.
    **      MODULE USER_COMMAND_0100.
    *& Thread: problem in handling double click in the second alv grid control
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1172052"></a>
    REPORT  zus_sdn_three_alv_grids_01.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syst-repid,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
      go_splitter_2    TYPE REF TO cl_gui_splitter_container,
      go_cell_top      TYPE REF TO cl_gui_container,
      go_cell_bottom   TYPE REF TO cl_gui_container,
      go_cell_left     TYPE REF TO cl_gui_container,
      go_cell_right    TYPE REF TO cl_gui_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      go_grid3         TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_outtab        TYPE STANDARD TABLE OF vbak,
      gt_outtab_2      TYPE STANDARD TABLE OF vbap,
      gt_outtab_3      TYPE STANDARD TABLE OF vbep.
    **PARAMETERS:
    **  p_bukrs          TYPE bukrs  DEFAULT '1000'.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          ms_row      TYPE lvc_s_row,
          ms_col      TYPE lvc_s_col.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_double_click.
    *   define local data
        DATA:
          ls_outtab      TYPE vbak,
          ls_outtab_2    TYPE vbap,
          ls_outtab_3    TYPE vbep.
        "   Initialize class data
        CLEAR: ms_row,
               ms_col.
        CASE sender.
          WHEN go_grid1.
            ms_row = e_row.
            ms_col = e_column.
    *       Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code
              EXPORTING
                new_code = 'GET_ITEMS'
    *          IMPORTING
    *            rc       =
          WHEN go_grid2.
            ms_row = e_row.
            ms_col = e_column.
    *       Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code
              EXPORTING
                new_code = 'GET_SCHEDULE_LINES'
    *          IMPORTING
    *            rc       =
          WHEN go_grid3.
    **        READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
    **        CHECK ( ls_vbap-matnr IS NOT INITIAL ).
    **        SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
    **        CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
            RETURN.
        ENDCASE.
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  vbak INTO TABLE gt_outtab UP TO 100 ROWS.
      PERFORM init_controls.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAK'
        CHANGING
          it_outtab        = gt_outtab
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      REFRESH: gt_outtab_2.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAP'
        CHANGING
          it_outtab        = gt_outtab_2    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      REFRESH: gt_outtab_3.
      CALL METHOD go_grid3->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBEP'
        CHANGING
          it_outtab        = gt_outtab_3    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    * Flow logic of dynpro:
    *PROCESS BEFORE OUTPUT.
    *  MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    *  MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "ORDERS"
    *  SET TITLEBAR 'xxx'.
    * Refresh display of detail ALV list
      CALL METHOD go_grid2->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Refresh display of detail ALV list
      CALL METHOD go_grid3->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        " Double-click on first or second ALV grid
        WHEN 'GET_ITEMS'  OR
             'GET_SCHEDULE_LINES'.
          PERFORM get_details.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = 1
          columns           = 2
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Get cell container
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_left.
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 2
        RECEIVING
          container = go_cell_right.
    * Create 2nd splitter container
      CREATE OBJECT go_splitter_2
        EXPORTING
          parent            = go_cell_left
          rows              = 2
          columns           = 1
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Get cell container
      CALL METHOD go_splitter_2->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_top.
      CALL METHOD go_splitter_2->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = go_cell_bottom.
    * Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent = go_cell_top
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent = go_cell_bottom
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid3
        EXPORTING
          i_parent = go_cell_right
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Set event handler
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid2.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid3.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  GET_DETAILS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_details .
    * define local data
      DATA: ls_row      TYPE lvc_s_row,
            ls_col      TYPE lvc_s_col.
      data: ls_outtab   type vbak,
            ls_outtab_2 type vbap,
            ls_outtab_3 type vbep.
      BREAK-POINT.
      CASE gd_okcode.
        WHEN 'GET_ITEMS'.
          CALL METHOD go_grid1->get_current_cell
            IMPORTING
    *          e_row     =
    *          e_value   =
    *          e_col     =
              es_row_id = ls_row
              es_col_id = ls_col
    *          es_row_no =
          read TABLE gt_outtab into ls_outtab index ls_row-index.
          refresh: gt_outtab_2,
                   gt_outtab_3.
          SELECT        * FROM  vbap into TABLE gt_outtab_2
                 WHERE  vbeln  = ls_outtab-vbeln.
        WHEN 'GET_SCHEDULE_LINES'.
          CALL METHOD go_grid2->get_current_cell
            IMPORTING
    *          e_row     =
    *          e_value   =
    *          e_col     =
              es_row_id = ls_row
              es_col_id = ls_col
    *          es_row_no =
          READ TABLE gt_outtab_2 into ls_outtab_2 index ls_row-index.
          refresh: gt_outtab_3.
          SELECT        * FROM  vbep into TABLE gt_outtab_3
                 WHERE  vbeln  = ls_outtab_2-vbeln
                 AND    posnr  = ls_outtab_2-posnr.
        WHEN OTHERS.
          RETURN.
      ENDCASE.
      IF ( lcl_eventhandler=>ms_row = ls_row  AND
           lcl_eventhandler=>ms_col = ls_col ).
        MESSAGE 'Current cell identical'  TYPE 'I'.
      ELSE.
        MESSAGE 'Current cell NOT identical'  TYPE 'I'.
      ENDIF.
    ENDFORM.                    " GET_DETAILS
    Regards
      Uwe

  • Urgent :  how to select the rows in the ALV Grid Control

    How to select the rows in the ALV Grid control,
    I am facing the situation where i need to select the row/rows in the Grid control and then to lock the entries,
    If anyone have the solution please help me out
    <b>Its very Urgent</b>

    Hi Bharath,
    Go through this hope u can understand.
    SEL_MODE. Selection mode, determines how rows can be selected. Can have the following values:
    A Multiple columns, multiple rows with selection buttons.
    B Simple selection, listbox, Single row/column
    C Multiple rows without buttons
    D Multiple rows with buttons and select all ICON
    Setting and getting selected rows (Columns) and read line contents
    You can read which rows of the grid that has been selected, and dynamic select rows of the grid using methods get_selected_rows and set_selected_rows. There are similar methods for columns.
    Note that the grid table always has the rows in the same sequence as displayed in the grid, thus you can use the index of the selected row(s) to read the information in the rows from the table. In the examples below the grid table is named gi_sflight.
    Data declaration:
    DATA:
    Internal table for indexes of selected rows
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    Example 1: Reading index of selected row(s) and using it to read the grid table
      CALL METHOD go_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines = 0.
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
             EXPORTING
                  textline1 = 'You must choose a valid line'.
        EXIT.
      ENDIF.
      LOOP AT gi_index_rows INTO g_selected_row.
         READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
        ENDIF.
      ENDLOOP.
    Example 2: Set selected row(s).
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines > 0.
        CALL METHOD go_grid->set_selected_rows
            exporting
              it_index_rows = gi_index_rows.
      ENDIF.
    Reward points if helpful.
    Thanks
    Naveen khan

  • How to inactive the push button on tool bar of alv report

    hi masters,
    i m working on the ALV interactive report, in this report i have to do 2 different operation on 2 screen.
    eg.- on first screen i have the push button for 'data' and on second screen i will have the push button for 'upload'.
    in this i don't want to give the 'upload' button on first screen and same i don't want to give the 'data' button on 2nd screen.
    i tried with using the 2 different gui status and 2 different PF-STATUS but its not working.
    anyone can tell me how i can deactivate the 'upload' button on first screen and how i can do same for 'get' buttton on 2nd screen.
    regards,
    vicky

    HI Vicky ,
                      if u want an interactive ALV report , there are lot of forums already having the solution for that , but let me give u the solution anyway.
    In the function module "REUSE_ALV_GRID_DISPLAY" , import parameters
         I_CALLBACK_PF_STATUS_SET          = 'FLIGHT'
         I_CALLBACK_USER_COMMAND           = 'BUTTON_CLICK'
    has to be supplied to this function module . The PF status is where u hav created the two buttons , that PF status has to be given here .If the user clicks on the button then it is handled by the form routines . Inside the sub-routine based on the button the user has selected u could perform the action.
    FORM FLIGHT    USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'FLIGHT' EXCLUDING RT_EXTAB.
    ENDFORM.
    Here the "Flight" is the PF_status .
    FORM BUTTON_CLICK USING UCOMM type SY-UCOMM
                           SELFIELD type SLIS_SELFIELD.
      CASE UCOMM.
        WHEN 'BUTTON!' .
    write ur code for button 1.
      WHEN "BUTTON"
      *Write ur code for button2 .
    end case.
    endform.
    for any queries reply back.
    regards

  • Event for the List Box in ALV Grid Control

    Hello,
    I have the below urgent requirment.
    I have an ALV Grid Control built using ABAP Objects. In the grid, I have few fields and one of these fields is a List Box. Depending on the values selected, I need to enable or disable some fields. So, is there any event for the List box in ALV Grid Control.
    For ex: I have 2 Fields, Designation and Commission. The designation field is a List Box field having 'Software Engineer' and 'Manager' as values. When I select 'Software Engineer', the commission field should be disabled. When I select 'Manager', the comission field should be enabled.
    Early reply is hightly appreciated.
    Priya

    REPORT  ZTEST1234    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    DATA:BEGIN OF  ITAB OCCURS 0,
         VBELN LIKE LIKP-VBELN,
         POSNR LIKE LIPS-POSNR,
         COMISN(10),
         CELLCOLOR TYPE LVC_T_SCOL, "required for color
         DROP(20),
        <b> HANDLE_STYLE TYPE LVC_T_STYL,</b>
         END OF ITAB.
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    <b>**Handler to Check the Data Change
        HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                             OF CL_GUI_ALV_GRID
                             IMPORTING ER_DATA_CHANGED
                                       E_ONF4
                                       E_ONF4_BEFORE
                                       E_ONF4_AFTER,</b>
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
        MESSAGE I000 WITH V_ROW 'clicked'.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
      ENDMETHOD.                    "handle_double_click
    <b>**Handle Data Change
      METHOD HANDLE_DATA_CHANGED.
        DATA: X_CHANGE TYPE LVC_S_MODI,
                X_FINAL TYPE ITAB,
                L_FLAG,
                LS_OUTTAB LIKE LINE OF ITAB.
        DATA: LS_EDIT TYPE LVC_S_STYL,
              LT_EDIT TYPE LVC_T_STYL.
        LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
          IF X_CHANGE-FIELDNAME = 'DROP' AND X_CHANGE-VALUE = 'S/W ENGINEER'.
            LS_EDIT-FIELDNAME = 'COMISN'.
            LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
            LS_EDIT-STYLE2 = SPACE.
            LS_EDIT-STYLE3 = SPACE.
            LS_EDIT-STYLE4 = SPACE.
            LS_EDIT-MAXLEN = 8.
            INSERT LS_EDIT INTO TABLE LT_EDIT.
            INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
            MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB  TRANSPORTING
                                              HANDLE_STYLE .
          else.
            LS_EDIT-FIELDNAME = 'COMISN'.
            LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
            LS_EDIT-STYLE2 = SPACE.
            LS_EDIT-STYLE3 = SPACE.
            LS_EDIT-STYLE4 = SPACE.
            LS_EDIT-MAXLEN = 8.
            INSERT LS_EDIT INTO TABLE LT_EDIT.
            INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
            MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB  TRANSPORTING
                                              HANDLE_STYLE .
          ENDIF.
        ENDLOOP.
        CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
          EXCEPTIONS
            FINISHED = 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.
      ENDMETHOD.                    "HANDLE_DATA_CHANGED</b>
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      CREATE OBJECT G_CUSTOM_CONTAINER
             EXPORTING CONTAINER_NAME = G_CONTAINER1.
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
       <b>GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.</b>
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
    <b>  CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.</b>
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
    <b>  SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.</b>
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Comissn'(025).
      X_FIELDCAT-FIELDNAME = 'COMISN'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-EDIT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  SET_DRDN_TABLE
    *       text
    FORM SET_DRDN_TABLE.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LS_DRAL-HANDLE = '1'.
      LS_DRAL-VALUE =  'S/W Engineer'.
      LS_DRAL-INT_VALUE =  'S/W Engineer'.
      APPEND LS_DRAL TO LT_DRAL.
      LS_DRAL-HANDLE = '1'.
      LS_DRAL-VALUE =  'Manager'.
      LS_DRAL-INT_VALUE =  'Manager'.
      APPEND LS_DRAL TO LT_DRAL.
    **Setting the Drop down table for Reason Code
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM.                               " set_drdn_table
    Regards
    vijay

  • Displaying a Push button in the application toolbar for an ALV report

    Hello everyone,
    Query:
    Is it possible to display a custom push button in the application tool bar while displaying an ALV report(1st one)?
    On pressing this custom push button will I be able to display another ALV report(2nd one) based on the selection made on the current ALV report(1st one)?

    Yes u can have pushbutton on application toolbar.
    You just have to use the new pf status in your report program.
    You should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 >Programming SubObjects> Gui Status.
    Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.
    Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.
    Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality.
    Have a look at below code for using the new status.
    TYPE-POOLS: slis.
    DATA: i_qmel LIKE qmel OCCURS 0.
    data v_repid type repid.
    SELECT * FROM qmel INTO TABLE i_qmel.
    v_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = v_repid
    I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    i_structure_name = 'QMEL'
    TABLES
    t_outtab = i_qmel
    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 set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'TEST'.
    endform.
    FORM user_command USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
    data lv_ucomm type sy-ucomm.
    lv_ucomm
    = sy-ucomm.
    CASE lv_ucomm.
    WHEN 'BUTTON'. "Double Click line Item
    **Write ur functinality here
    endcase.
    endform.
    Also have a look at below links.
    http://www.sap-basis-abap.com/abap/add-button-to-alv-toolbar-with-reuse-alv-list-display.htm
    ALV report
    Best Regards,
    Vibha
    *Please mark all the helpful answers

Maybe you are looking for

  • Need Help in using ssrs action how to open outlook window to send an email

    Hi Everyone, I have a scenario i will get  E-mail id as part of the database Fields as a column in report. When i click on the E-mail id it as to open the "OUTLOOK" window. How can i achieve this please.... Thanks in Advance..... Sreekanth Note: Plea

  • Splitting audio tracks

    ok, so i have a vocal track, and the friend of mine who did it said some pretty vile things (and trust me, when i say vile, i mean viiiiiiiiiiiile! haha) so what id like to do is go in and cut out the small pieces of audio where those lovely words re

  • Form response tables

    Hello, Is it possible to add tables in your View Responses tab that are also linked to the form fields? Right now the All Responses table has columns that are linked to Form fields, but when you add a new table I cannot seem to find the option to add

  • IMovie DVD Cannot be read by Bluray Player

    How to resolve a problem with getting a DVD (with a correct DVD type) to play on a Samsung Bluray player that has IMovie files burned to it?  The problem is not the DVD type.  Could it be the settings for burning the DVD?

  • Synch to iPad from Photoshop Album

    When I synch photos to iPad using Photoshop Album not all my photos synch. They were all taken with teh same camera & are the same size. I thought maybe the ones I edited were not synching, but that's not so. I have 63 photos in an album adn only 34