How to show traffic lights on push button in ALV Grid?

Hi Experts,
I have an requirement where I have to show traffic lights on push button in ALV grid of a container. I am showing access sequence for each condition type in my grid. Now, if the access sequence contains 'PLANT', it should show 'green' on push button or else it should show 'red'. How I can I achieve this?
Thanks in advance.

Try This One.
DATA: gs_fieldcat TYPE slis_fieldcat_alv,
          gt_fieldcat TYPE slis_t_fieldcat_alv,
          gs_layout   TYPE  slis_layout_alv.
TYPES :BEGIN OF gty_temp,
            col(10) TYPE c,
           END OF gty_temp.
DATA : gt_temp TYPE STANDARD TABLE OF gty_temp,
            gs_temp TYPE gty_temp.
   gs_temp-col  ='@0A@'. "ERROR RED LIGHT
       APPEND gs_temp TO   gt_temp.
    CLEAR GS_TEMP.
gs_temp-col  = '@08@'." SUCCESS GREEN LIGHT
APPEND gs_temp TO   gt_temp.
CLAER GS_TEMP.
gs_temp-col  = '@09@'. WARNING YELLOW LIGHT
APPEND gs_temp TO   gt_temp.
CLAER GS_TEMP.
gs_fieldcat-fieldname   = ' COL'.
gs_fieldcat-tabname   =  'GT_TEMP'.
gs_fieldcat-seltext_m = 'ERROR'."
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program = 'ZPROG1' " PROGRAM NAME
     i_grid_title       = 'Details'
*   is_layout          = gs_layout
     it_fieldcat        = gt_fieldcat
   TABLES
     t_outtab           = gt_temp.
* EXCEPTIONS
*   PROGRAM_ERROR                     = 1
*   OTHERS                            = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

Similar Messages

  • PUSH-BUTTON in ALV GRID

    How can we create a push-button in ALV-GRID.
    How will u handle a push-button in ALV.

    Hello,
    To add a push button and handle it,you have to define a local class and use the methods <b>handle_toolbar</b> and <b>handle_user_command</b>.Here is a sample code:
          CLASS lcl_eh DEFINITION
    CLASS lcl_eh DEFINITION.
      PUBLIC SECTION.
        DATA:
             <b>ls_toolbar  TYPE stb_button</b>.
        METHODS:
                <b>handle_toolbar</b>
                    FOR EVENT toolbar OF cl_gui_alv_grid
                        IMPORTING e_object e_interactive,
                <b>handle_user_command</b>
                    FOR EVENT user_command OF cl_gui_alv_grid
                        IMPORTING e_ucomm.
    ENDCLASS.                    "lcl_eh DEFINITION
    *Type referencing an object of the class
    <b>DATA: lo_obj TYPE REF TO lcl_eh.</b>
          CLASS lcl_eh IMPLEMENTATION
    CLASS lcl_eh IMPLEMENTATION.
    *METHOD:      HANDLE_TOOLBAR
    *DESCRIPTION: This method provides the necessary detail required to
                 create an extra button in the toolbar.
      METHOD <b>handle_toolbar.</b>
        CLEAR ls_toolbar.
        MOVE 'CREATE' TO ls_toolbar-function.
        MOVE 0 TO ls_toolbar-butn_type.
        MOVE 'CREATE' TO ls_toolbar-text.
        MOVE 'ICON_DETAIL' TO ls_toolbar-icon.
        MOVE 'CREATE' TO ls_toolbar-quickinfo.
        <b>APPEND ls_toolbar TO e_object->mt_toolbar.</b>
      ENDMETHOD.                    "handle_toolbar
    *METHOD:      HANDLE_USER_COMMAND
    *DESCRIPTION: This method is used to handle the push button
      <b>METHOD handle_user_command.</b>
    <b>    CASE e_ucomm.</b>
    <b>      WHEN 'CREATE'.</b>
    **logic
            ENDCASE.
    ENDMETHOD.
    ENDCLASS.
    Regards,
    Beejal
    **reward if this helps

  • Traffic lights on push button

    Hi all,
              In my requirement i have a field as push button , now i require to put traffic lights on this push button.I am displaying alv grid through
    class cl_gui_alv_grid
    please help me with a sample code.
    regards,
    kushagra

    Hi,
    Pass below codes as texts for the push buttons:
    @0A@ - Red
    @09@ - Orange
    @08@ - Green
    Below code can help you understanding handling normally without pushbuttons:
    DATA: ok_code TYPE syucomm.
    TYPES: BEGIN OF ty_data,
             num TYPE i,
             icon TYPE icon_d,
           END OF ty_data.
    DATA: wa_data TYPE ty_data,
          i_data TYPE TABLE OF ty_data.
    DATA: i_fieldcat TYPE lvc_t_fcat,
          wa_fieldcat TYPE lvc_s_fcat.
    DATA: g_cust_cont   TYPE REF TO cl_gui_custom_container,
          g_container   TYPE scrfname VALUE 'GRID1',
          g_grid        TYPE REF TO cl_gui_alv_grid.
    START-OF-SELECTION.
      DO 10 TIMES.
        wa_data-num = sy-index.
        IF sy-tabix < 4.
          wa_data-icon = '@0A@'.
        ELSEIF sy-tabix < 7.
          wa_data-icon = '@09@'.
        ELSE.
          wa_data-icon = '@08@'.
        ENDIF.
        APPEND wa_data TO i_data.
      ENDDO.
    END-OF-SELECTION.
      CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAINTITLE'.
      IF g_grid IS INITIAL.
        PERFORM display_list.
      ENDIF.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      DATA: l_event TYPE REF TO cl_gui_event.
      CASE ok_code.
        WHEN 'EXIT' OR 'BACK' OR 'CANC'.
          PERFORM exit_program.
      ENDCASE.
      CLEAR: ok_code.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  DISPLAY_LIST
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_list .
      IF g_cust_cont IS INITIAL.
    * Create Custom Container
        CREATE OBJECT g_cust_cont
               EXPORTING container_name = g_container.
    * Create Ojbect for Grid Display
        CREATE OBJECT g_grid
               EXPORTING i_parent = g_cust_cont.
    * Build Field Catalog
        PERFORM build_catalog.
    * Display Output in Grid Form
        CALL METHOD g_grid->set_table_for_first_display
          CHANGING
            it_fieldcatalog = i_fieldcat
            it_outtab       = i_data[].
      ELSE.
    * Refresh Display
        CALL METHOD g_grid->refresh_table_display.
      ENDIF.
    ENDFORM.                    " DISPLAY_LIST
    *&      Form  BUILD_CATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_catalog .
      PERFORM build_fld_catalog USING:
         1 'NUM'   'I_DATA'   space     'Number'   10,
         2 'ICON'   'I_DATA'   'X'     'Icon'      10.
    ENDFORM.                    " BUILD_CATALOG
    *&      Form  BUILD_FLD_CATALOG
    *       text
    *      -->P_1      text
    *      -->P_0182   text
    *      -->P_0183   text
    *      -->P_C_X  text
    *      -->P_0185   text
    *      -->P_12     text
    FORM build_fld_catalog  USING    p_col
                                     p_fld
                                     p_tab
                                     p_icon
                                     p_text
                                     p_len.
      CLEAR: wa_fieldcat.
      wa_fieldcat-col_pos = p_col.
      wa_fieldcat-fieldname = p_fld.
      wa_fieldcat-tabname = p_tab.
      wa_fieldcat-icon = p_icon.
      wa_fieldcat-scrtext_l = p_text.
      wa_fieldcat-outputlen = p_len.
      APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " BUILD_FLD_CATALOG
    *&      Form  EXIT_PROGRAM
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM exit_program .
      CALL METHOD g_grid->free.
      LEAVE TO SCREEN 0.
    ENDFORM.                    " EXIT_PROGRAM

  • How to add a push button in ALV Grid Top-of-page

    Is it possible to add a push button to the top-of-page in Alv grid display?if yes, then how? I am not using OO ABAP and am using reuse_alv_grid_display with top-of-page event.

    Hi,
    I am not sure whether we can add push button in top-of -page or not. But instead of that if you want to add button on toolbar as per your requirement then follow below link. it will useful.
    http://www.sap-img.com/abap/example-of-a-simple-alv-grid-report.htm
    Ram.

  • Push Button on Alv Grid display

    Hi experts,
       I strcuk in the middle of one program, i need to have push buttons on the output ALV Grid display, i have copied the standard status and used the same in the Function module for pf-status, iam able to get the output
    but my requirement is how to add the push buttons to the out put screen, as when iam clicking on status which i have copied iam unable to find where to add these push button in the application tool bar, iam unable to edit the push button can any body help me out, thanks in advance.

    Hello Madan
    I cannot help you with the FM-based ALV lists. However, for OO-based ALV grids (CL_GUI_ALV_GRID) I have a sample program that simulates radio buttons by using icons with hotspots.
    PROGRAM ZUS_SDN_BCALV_GRID_DEMO_2.
    * Based on: BCALV_GRID_DEMO.
    TYPE-POOLS: icon.
    TYPES: BEGIN OF ty_s_sflight.
    INCLUDE TYPE sflight.
    TYPES: button1    TYPE lvc_emphsz.
    TYPES: button2    TYPE lvc_emphsz.
    TYPES: button3    TYPE lvc_emphsz.
    TYPES: button4    TYPE lvc_emphsz.
    TYPES: END OF ty_s_sflight.
    DATA:
      gt_sflight    TYPE STANDARD TABLE OF ty_s_sflight,
      gt_fcat       TYPE lvc_t_fcat.
    DATA: ok_code LIKE sy-ucomm,
    *      gt_sflight TYPE TABLE OF sflight,
          g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
          grid1  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          md_cnt    TYPE i.
        CLASS-METHODS:
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_hotspot_click.
    * define local data
        FIELD-SYMBOLS:
          <ls_entry>    TYPE ty_s_sflight,
          <ld_fld>      TYPE ANY.
        READ TABLE gt_sflight ASSIGNING <ls_entry> INDEX es_row_no-row_id.
        CHECK ( <ls_entry> IS ASSIGNED ).
    *   Set all radio buttons "unselected"
        <ls_entry>-button1 =  icon_wd_radio_button_empty.
        <ls_entry>-button2 =  icon_wd_radio_button_empty.
        <ls_entry>-button3 =  icon_wd_radio_button_empty.
        <ls_entry>-button4 =  icon_wd_radio_button_empty.
        ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE <ls_entry>
                                                  TO <ld_fld>.
        IF ( <ld_fld> IS ASSIGNED ).
    *     Set selected radio button "selected".
          <ld_fld> = icon_wd_radio_button.
        ENDIF.
    *   Force PAI followed by refresh of table display in PBO
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'DUMMY'
    *      IMPORTING
    *        RC       =
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
    *       MAIN                                                          *
      PERFORM select_data.
      CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
               EXPORTING container_name = g_container.
        CREATE OBJECT grid1
               EXPORTING i_parent = g_custom_container.
        PERFORM build_fieldcatalog.
        CALL METHOD grid1->set_table_for_first_display
    *      EXPORTING
    *        i_structure_name = 'SFLIGHT'
          CHANGING
            it_fieldcatalog  = gt_fcat
            it_outtab        = gt_sflight.
    *   Set event handler for event TOOLBAR
        SET HANDLER:
          lcl_eventhandler=>handle_hotspot_click FOR grid1.
      else.
        CALL METHOD grid1->refresh_table_display
    *      EXPORTING
    *        IS_STABLE      =
    *        I_SOFT_REFRESH =
          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.
      ENDIF.
    ENDMODULE.                    "PBO OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
    *   to react on oi_custom_events:
      CALL METHOD cl_gui_cfw=>dispatch.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN OTHERS.
    *     do nothing
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                    "PAI INPUT
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
    *  CALL METHOD G_CUSTOM_CONTAINER->FREE.
    *  CALL METHOD CL_GUI_CFW=>FLUSH.
      LEAVE PROGRAM.
    ENDFORM.                    "EXIT_PROGRAM
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat,
        ls_hype        TYPE lvc_s_hype.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'LVC_S_FCAT'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        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.
      DELETE gt_fcat WHERE ( fieldname <> 'EMPHASIZE' ).
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'SFLIGHT'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        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 gt_fcat INTO ls_fcat
           WITH KEY fieldname = 'EMPHASIZE'.
      IF ( syst-subrc = 0 ).
        DELETE gt_fcat INDEX syst-tabix.
      ENDIF.
      ls_fcat-fieldname = 'BUTTON4'.
      ls_fcat-icon    = 'X'.
      ls_fcat-hotspot = 'X'.
      INSERT ls_fcat INTO gt_fcat INDEX 4.
      ls_fcat-fieldname = 'BUTTON3'.
      INSERT ls_fcat INTO gt_fcat INDEX 4.
      ls_fcat-fieldname = 'BUTTON2'.
      INSERT ls_fcat INTO gt_fcat INDEX 4.
      ls_fcat-fieldname = 'BUTTON1'.
      INSERT ls_fcat INTO gt_fcat INDEX 4.
      LOOP AT gt_fcat INTO ls_fcat.
        ls_fcat-col_pos = syst-tabix.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDLOOP.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  SELECT_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM select_data .
    * define local data
      DATA:
        ls_sflight    TYPE ty_s_sflight.
      SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
      ls_sflight-button1 = icon_wd_radio_button.
      ls_sflight-button2 = icon_wd_radio_button_empty.
      ls_sflight-button3 = icon_wd_radio_button_empty.
      ls_sflight-button4 = icon_wd_radio_button_empty.
      MODIFY gt_sflight FROM ls_sflight
          TRANSPORTING button1 button2 button3 button4
        WHERE ( carrid IS NOT INITIAL ).
    ENDFORM.                    " SELECT_DATA
    Regards
    Uwe

  • Push button in ALV Grid Display

    Hi all,
    I have a requirement wherin i need to place a button in the ALV Grid Display which should update all the records whatever are displayed in the specified infotype. This is to be done in a report.
    Can anybody give me any pointers or sample code for the above query.
    Regards,
    Amrita

    Simply add a button on your GUI status. Then when pushed, code your logic for update IT0008.
    AT USER-COMMAND event block will be triggered when you press your button.
    AT USER-COMMAND.
      if sy-ucomm = 'PUSHBUTTON'.    "here comes function code of your pushbutton
         "update your diplayed records
      endif.

  • How to print traffic lights in ALV reports

    hi how to print traffic lights on selection screen in alv reports

    HI,
    check below code
    TYPE-POOLS : icon.
    types:  BEGIN OF ty_display,
            status     TYPE icon-id,
            bukrs      TYPE bseg-bukrs,
            gjahr      TYPE bseg-gjahr,
            monat      TYPE monat,
            work_order TYPE z_work_order,
            glaccount  TYPE saknr,
            message    TYPE string,
          END OF ty_display.
    data : it_display     TYPE TABLE OF ty_display,
             wa_display TYPE ty_display.
    WRITE icon_led_green AS ICON TO wa_display-status.
            wa_display-gjahr = p_year.
            wa_display-bukrs = p_cc.
            wa_display-monat = p_period.
            wa_display-work_order = v_aufnr.
            wa_display-glaccount = wa_bseg-hkont.
        APPEND wa_display TO it_display.
    WRITE icon_led_red AS ICON TO wa_display-status.
              wa_display-gjahr      = p_year.
              wa_display-bukrs      = p_cc.
              wa_display-monat      = p_period.
              wa_display-work_order = v_aufnr.
              wa_display-glaccount  = wa_bseg-hkont.
              wa_display-message    = text-010.
              APPEND wa_display TO it_display.
    change the icon color based on your requirement and append it to the internal table which you have to display in ALV.
    reward points if it is helpful.
    Regards,
    Srilatha

  • How to give  push button in alv report  output

    hi,
    my requirement is that , i have to give push button in alv report output(item level) not in application toolbar, i am using reuse_alv_grid_display FM, can any body provide me sample code
    regards,
    siva kumar

    have a look at this thread, also has a sample report at the end from Uwe Schieferstein.
    [button on alv list|How to add and program a pushbutton on ALV grid line;
    seems not to work try this:
    How to add and program a pushbutton on ALV grid line
    Edited by: Micky Oestreich on May 15, 2008 10:20 PM

  • How can we place a push button in ALV  report

    hi
    could anybody inform me
    how can we place a push button in ALV  report
    thanx
    regards
    kals.

    Hi kals.
    please have a look at demoprogram
    SALV_DEMO_TABLE_FUNCTIONS
    BCALV_GRID_05
    Regards
    Bernd

  • How to use traffic lights concept in alv in webdynpro abap

    Hai ,
              How to use traffic lights concept for alv in webdynpro abap. If possible give me some code.

    Hi Ravi,
    You can create ICON  to get traffic light.
    Go through this step by step.. in this example
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1190424a-0801-0010-84b5-ef03fd2d33d9?quicklink=index&overridelayout=true
    Please go through this...
    Re: Display ICON in the ALV table column
    Re: Image in ALV
    cheers,
    Kris.

  • Push button in alv report

    Dear Experts,
             How to add pushbutton in alv report.....
    *& Report  ZTT_TEST_ALV
    REPORT  ZTT_TEST_ALV.
    *data declarations
    type-pools : SLIS.
    *  data : BEGIN OF wa_kna1,
    *                kunnr type kunnr,
    *                name1 type name1,
    *         end of wa_kna1,
    * it_kna1 like tABLE OF wa_kna1.
    data : begin of wa_mara,
      matnr type matnr,
      end of wa_mara,
      it_mara like table of wa_mara.
      data : it_fcat type slis_t_fieldcat_alv,
             wa_fcat like line of it_fcat.
    *selection screen
      SELECTION-SCREEN begin of block k with frame title text-001.
    *  select-OPTIONS : s_kunnr for wa_kna1-kunnr.
         select-OPTIONS : s_matnr for wa_mara-matnr.
      SELECTION-SCREEN end of block k.
    *select auery
    *SELECT kunnr name1 INTO table it_kna1 from kna1 where kunnr in s_kunnr.
    select matnr into table it_mara from mara where matnr in s_matnr.
    *for displaying fieldcatalog
      PERFORM fcat using '1' 'MATNR' 'material Number' 'C410' '20'.
    *  PERFORM fcat using '2' 'NAME1' 'Customer Name' 'C410' '36'.
    *for displaying output
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
    *   I_CALLBACK_PROGRAM                = ' '
       I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
    *   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                      = 'Report for Customer Details'
    *   I_GRID_SETTINGS                   =
    *   IS_LAYOUT                         =
       IT_FIELDCAT                       = it_fcat[]
    *   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_mara.
    * 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.
    *CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    *  EXPORTING
    ****   I_INTERFACE_CHECK              = ' '
    ****   I_CALLBACK_PROGRAM             =
    ****   I_CALLBACK_PF_STATUS_SET       = ' '
    ****   I_CALLBACK_USER_COMMAND        = ' '
    ****   IS_LAYOUT                      =
    *   IT_FIELDCAT                    = it_fcat
    ****   IT_EXCLUDING                   =
    ****   IT_SPECIAL_GROUPS              =
    ****   IT_SORT                        =
    ****   IT_FILTER                      =
    ****   IS_SEL_HIDE                    =
    ****   I_SCREEN_START_COLUMN          = 0
    ****   I_SCREEN_START_LINE            = 0
    ****   I_SCREEN_END_COLUMN            = 0
    ****   I_SCREEN_END_LINE              = 0
    ****   I_DEFAULT                      = 'X'
    ****   I_SAVE                         = ' '
    ****   IS_VARIANT                     =
    ****   IT_EVENTS                      =
    ****   IT_EVENT_EXIT                  =
    ***    i_tabname_header               =
    ***    i_tabname_item                 =
    ****   I_STRUCTURE_NAME_HEADER        =
    ****   I_STRUCTURE_NAME_ITEM          =
    ***    is_keyinfo                     =
    ****   IS_PRINT                       =
    ****   IS_REPREP_ID                   =
    ****   I_BYPASSING_BUFFER             =
    ****   I_BUFFER_ACTIVE                =
    ****   IR_SALV_HIERSEQ_ADAPTER        =
    ****   IT_EXCEPT_QINFO                =
    ****   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    **** IMPORTING
    ****   E_EXIT_CAUSED_BY_CALLER        =
    ****   ES_EXIT_CAUSED_BY_USER         =
    *  tables
    **    t_outtab_header                = it_
    *    t_outtab_item                  = it_kna1.
    **** 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  FCAT
    *       text
    *      -->P_0052   text
    *      -->P_0053   text
    *      -->P_0054   text
    form FCAT  using    fp_col_pos
                        fp_fieldname
                        fp_seltext_m
                        fp_emphasize
                        fp_outputlen..
    wa_fcat-col_pos = fp_col_pos.
    wa_fcat-fieldname = fp_fieldname.
    wa_fcat-seltext_m = fp_seltext_m.
    wa_fcat-emphasize = fp_emphasize.
    wa_fcat-outputlen = fp_outputlen.
    append wa_fcat to it_fcat.
    clear : wa_fcat.
    endform.                    " FCAT
    FORM SET_PF_STATUS                                         .
    SET PF-STATUS 'ZNEWSTATUS' .
    "Copy of 'STANDARD' pf_status from fgroup SALV
    endform.
    i need one push button in alv output display.
    Thanks and Regards,
    Thirukumaran. R

    HI THIRU TRY FOLLOWING CODES:
    *& Report  ZSAMPLE
    REPORT  ZSAMPLE.
    TABLES:MARA.
    TYPE-POOLS: SLIS.
    TYPES:BEGIN OF TY_ITAB,
          MATNR LIKE MARA-MATNR,
          ERSDA LIKE MARA-ERSDA,
          END OF TY_ITAB.
    DATA:ITAB TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV,
              WA_FCAT TYPE SLIS_FIELDCAT_ALV,
              LAYOUT TYPE SLIS_LAYOUT_ALV,
              WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:P_MATNR TYPE MARA-MATNR.
    SELECTION-SCREEN END OF BLOCK B1.
    START-OF-SELECTION.
      PERFORM FIELDCAT.
      LAYOUT-ZEBRA = 'X'.
      PERFORM OUTPUT.
    *&      Form  PF_STATUS
          text
         -->RT_EXTAB   text
    FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'BUTT'.
    ENDFORM.                    "PF_STATUS
    *&      Form  PUSH_BUTT1
          text
         -->R_UCOMM      text
         -->RS_SELFIELD  text
    FORM GET USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN 'GET'.
          IF SY-SUBRC EQ 0.
            CALL TRANSACTION 'SE11'.
          ELSE.
          ENDIF.
        WHEN 'EXIT' OR 'CANCEL' .
          LEAVE PROGRAM.
      ENDCASE.
    ENDFORM.                                                    "PUSH_BUTT1
    *&      Form  FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCAT .
      WA_FCAT-SELTEXT_L = 'Select'.
      WA_FCAT-COL_POS = '1'.
      WA_FCAT-FIELDNAME = 'CHECK'.
      WA_FCAT-CHECKBOX = 'X'.
      WA_FCAT-TABNAME = 'ITAB'.
      WA_FCAT-OUTPUTLEN =  '4'.
      WA_FCAT-INPUT(1) = 'X'.
    WA_FCAT-EDIT_MASK(1) = 'X'.
      WA_FCAT-EDIT(1) = 'X'.
      APPEND WA_FCAT TO FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-SELTEXT_L = 'Material Number'.
      WA_FCAT-COL_POS = '2'.
      WA_FCAT-FIELDNAME = 'MATNR'.
      WA_FCAT-TABNAME = 'ITAB'.
      WA_FCAT-OUTPUTLEN =  '18'.
      APPEND WA_FCAT TO FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-SELTEXT_L = 'Date'.
      WA_FCAT-COL_POS = '3'.
      WA_FCAT-FIELDNAME = 'ERSDA'.
      WA_FCAT-TABNAME = 'ITAB'.
      WA_FCAT-OUTPUTLEN =  '8'.
      APPEND WA_FCAT TO FCAT.
      CLEAR WA_FCAT.
    ENDFORM.                    " FIELDCAT
    *&      Form  OUTPUT
          text
    -->  p1        text
    <--  p2        text
    FORM OUTPUT .
      SELECT MATNR ERSDA FROM MARA
        INTO TABLE ITAB
        WHERE MATNR EQ  P_MATNR.
      IF SY-SUBRC EQ 0.
        PERFORM GRID.
      ELSE.
        MESSAGE 'No Records Found' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " OUTPUT
    *&      Form  GRID
          text
    -->  p1        text
    <--  p2        text
    FORM GRID .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
       I_CALLBACK_PROGRAM              = SY-REPID
       I_CALLBACK_PF_STATUS_SET        = 'PF_STATUS'
       I_CALLBACK_USER_COMMAND         = 'GET'
       IS_LAYOUT                         = LAYOUT
         IT_FIELDCAT                     = FCAT
       I_DEFAULT                         = 'X'
        TABLES
          T_OUTTAB                          = ITAB.
    ENDFORM.                    " GRID
    REGARDS,
    SAKTHIVEL.VT

  • Creating push button on ALV application toolbar

    Hi Abapers,
    I have created one ALV in HR module using function module 'display_basic_list'. now my requirement is to create a push button on ALV application tool bar so that when user clicks on this push button another list has to appear..
    kindly gimme valid inputs which would help me.. Also provide me sample code...
    Thanks in Advance,
    Radhika.

    Hi,
    GO to SE41 copy the status STANDARD from the program SAPLKKBL..And give the status name and your program name...
    Add your buttons..
    In the parameter I_CALLBACK_PF_STATUS_SET give the form name 'PF_STATUS_SET'.
    In the subroutine.
    FORM PF_STATUS_SET.
    SET PF-STATUS 'STATUS NAME THAT YOU GAVE IN SE41'.
    ENDFORM.
    For user command pass the parameter I_CALLBACK_USER_COMMAND with the user command subroutine name..
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
    IF R_UCOMM = ''.
    ENDIF.
    ENDFORM.
    Example
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = lv_repid
    I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    Thanks,
    Naren

  • PUSH BUTTON IN ALV

    Hi all,
    To add a push button in alv, I have copie the  pf-status  'Standard'  to my program, named 'Zstandard' ,and  added button to the status.
    and  added parameters in ALV function like:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = repname
          i_callback_pf_status_set = 'SET_PF_STATUS'
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      DATA: wa_extab TYPE slis_extab.
      wa_extab-fcode = '&OAD'.
      APPEND wa_extab TO rt_extab.
      wa_extab-fcode = '&AVE'.
      APPEND wa_extab TO rt_extab.
      SET PF-STATUS 'ZSTANDARD' EXCLUDING rt_extab .
    ENDFORM. "Set_pf_status
    But still I am not able to display the pf-status.
    can anybody tell me step bu step procedure to add push button in ALV.
    thanks,
    sudheer

    >
    sudheer kumar wrote:
    > Hi all,
    >
    > To add a push button in alv, I have copie the  pf-status  'Standard'  to my program, named 'Zstandard' ,and  added button to the status.
    >
    > and  added parameters in ALV function like:
    >   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    >     EXPORTING
    >       i_callback_program       = repname
    >       i_callback_pf_status_set = 'SET_PF_STATUS'
    >
    > FORM set_pf_status USING rt_extab TYPE slis_t_extab.
    >   DATA: wa_extab TYPE slis_extab.
    >   wa_extab-fcode = '&OAD'.
    >   APPEND wa_extab TO rt_extab.
    >   wa_extab-fcode = '&AVE'.
    >   APPEND wa_extab TO rt_extab.
    >   SET PF-STATUS 'ZSTANDARD' EXCLUDING rt_extab .
    > ENDFORM. "Set_pf_status
    >
    > But still I am not able to display the pf-status.
    >
    > can anybody tell me step bu step procedure to add push button in ALV.
    >
    > thanks,
    > sudheer
    hi sudheer can u post the complete code may be u have not passed the form name to the events table or events table to the function module check it

  • Button in alv grid cell using REUSE_ALV_GRID_DISPLAY

    Hi all,
      I want to make the contents of 2 columns of my alv grid as push button with values as text on it. I am not using classes or methods but alv grid fm. On clicking the button one dialog box has to pop up which gives edit option for the values in that coloumn, my question is how to introduce button in alv grid cell? if i can use t_fieldcatalog-icon, then please give me the complete steps for that.
    Thanks.

    this may helps u
    u need to copy stadard screen elemetn to MARATAB1(at PF -STATUS)
    You should copy the 'STANDARD' GUI status from program <b>SAPLSLVC_FULLSCREEN</b>
    type this one in SE41 program name is:<b>SAPLSLVC_FULLSCREEN</b>
    status : <b>STANDARD_FULLSCREEN</b>
    and copy it ...
             Type-pool
    type-pools slis.
             Tables
    tables: mara,sscrfields.
           Selection screen
    select-options: s_matnr for mara-matnr.
    PARAMETERS: p_email TYPE somlreci1-receiver.
    TYPES: BEGIN OF t_charmara,
      matnr(18)  TYPE c,                   " Material Number
      ernam(12)  TYPE c,                   " Person Credited
      aenam(12)  TYPE c,                   " Person Changed Object
      pstat(15)  TYPE c,                   " Maintenance Status
    END OF t_charmara.
             Data Declarations
    data: rt_extab    type slis_t_extab,   " Table of inactive function
                                           codes
          wa_charmara TYPE t_charmara,     " work area of mara Table
          fs_fieldcat type slis_t_fieldcat_alv,
                                           " Field catalog with field
                                           descriptions
          t_fieldcat  like line of fs_fieldcat,
                                           " Table of Field catalog
          r_ucomm     like sy-ucomm,       " User Command
          rs_selfield TYPE slis_selfield.  " cursor position ALV
    data: filedlayout   type slis_layout_alv,
          heading       type slis_t_listheader with header line,
          t_event       type slis_t_event.
    data: fs_event      like line of t_event.
    data: fs_sort type slis_sortinfo_alv,
           t_sort type slis_t_sortinfo_alv.
    data: w_char(200) type c,
          w_matnr     type mara-matnr.
    fs_sort-fieldname = 'MATNR'.
    fs_sort-up        = 'X'.
    fs_sort-group     = '*'.
    append fs_sort to t_sort.
    clear fS_sort.
    DATA:   t_packing_list  LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents      LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            t_receivers     LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
            t_attachment    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            w_cnt           TYPE i,
            w_sent_all(1)   TYPE c,
            w_doc_data      LIKE sodocchgi1,
            gd_error        TYPE sy-subrc,
            gd_reciever     TYPE sy-subrc.
             Internal Tables
    data: begin of it_mara occurs 0,
            matnr like mara-matnr,         " Material Number
            ernam like mara-ernam,         " Person Credited
            aenam like mara-aenam,         " Person Changed Object
            pstat like mara-pstat,         " Maintenance Status
          end of it_mara.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    *at selection-screen on field event
    AT SELECTION-SCREEN on s_matnr.
    PERFORM f0100_VALIDATE_MATERIAL_NUMBER.
    start-of-selection.
    retrive Data from the data base table Mara
    perform retrive_data_from_mara.
    end-of-selection.
    *Field catalog with field descriptions
    perform fieldcat.
    *perform top_of_page.
    PERFORM EVENT_LIST.
    *ALV Grid Display
    perform alv_display.
    Creating one Push button ENTER
    perform maratab1 USING    RT_EXTAB.
    *&      Form  f0100_VALIDATE_MATERIAL_NUMBER
          text
    There are no interface parameters to be passed to this subroutine
    FORM F0100_VALIDATE_MATERIAL_NUMBER .
    select matnr                          " Material Number
       from mara
      up to 1 rows
       into mara-matnr
      where matnr in s_matnr.
      endselect.
    IF sy-subrc NE 0.
          clear sscrfields-ucomm.
          MESSAGE e000 WITH 'Enter valid Material number'(003).
        ENDIF.                             " IF sy-subrc NE 0
    ENDFORM.                               " f0100_VALIDATE_MATERIAL_NUMBER
    *&      Form  retrive_data_from_mara
          text
    *There are no interface parameters to be passed to this subroutine
    FORM retrive_data_from_mara .
    select   matnr                         " Material Number
             ernam                         " Person Credited
             aenam                         " Person Changed Object
             pstat                         " Maintenance Status
        from mara
        into table It_mara
       where matnr in s_matnr.
    IF sy-subrc NE 0.
          MESSAGE i001 WITH 'Records are not found'.
          exit.
          stop.
        ENDIF.                             " IF sy-subrc NE 0
    ENDFORM.                               " retrive_data_from_mara
    *&      Form  fieldcat
          text
    *There are no interface parameters to be passed to this subroutine
    FORM fieldcat .
    *field catalog for MATNR
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'MATNR'.
      t_fieldcat-col_pos     = 1.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for ERNAM
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'ERNAM'.
      t_fieldcat-col_pos     = 2.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for AENAM
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'AENAM'.
      t_fieldcat-col_pos     = 3.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for PSTAT
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'PSTAT'.
      t_fieldcat-col_pos     = 4.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    ENDFORM.                               " fieldcat
    *&      Form  EVENT_LIST
          text
    *There are no interface parameters to be passed to this subroutine
    FORM EVENT_LIST .
      fs_event-name ='TOP_OF_PAGE'.
      fs_event-form = 'TOP_PAGE'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
      fs_event-name ='END_OF_PAGE'.
      fs_event-form = 'END_PAGE'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
      fs_event-name ='END_OF_LIST'.
      fs_event-form = 'LIST_END'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
    ENDFORM.                               " EVENT_LIST
    *&      Form  alv_display
          text
    *There are no interface parameters to be passed to this subroutine
    FORM alv_display .
    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       = 'MARATAB1'
       I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      =
       IT_FIELDCAT                    = FS_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
       IT_SORT                        = T_SORT
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
       IT_EVENTS                      = T_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_MARA[]
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                               " alv_display
    form TOP_PAGE.
      data:tbl_listheader type slis_t_listheader,
            wa_listheader type slis_listheader .
       wa_listheader-typ = 'S'.
       wa_listheader-info = 'Created by : Vijay Pawar'.
       append wa_listheader to tbl_listheader.
       wa_listheader-typ = 'S'.
       concatenate ' Date ' sy-datum into
                  wa_listheader-info separated by space.
        append wa_listheader to tbl_listheader.
       wa_listheader-typ = 'S'.
       concatenate ' From ' s_matnr-low '  To  ' s_matnr-high into
                           wa_listheader-info separated by space.
       append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    endform.                               " form TOP_PAGE.
    form END_PAGE.
      STATICS W_PAGE TYPE I .
      data:tbl_listheader type slis_t_listheader,
            wa_listheader type slis_listheader .
      wa_listheader-typ   = 'S'.
      wa_listheader-info  = W_PAGE.
      append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    add 1 to w_page.
    endform.                               " form END_PAGE.
    form list_end.
      data:tbl_listheader type slis_t_listheader,
      wa_listheader type slis_listheader .
      wa_listheader-typ = 'S'.
      wa_listheader-info = '......................................Last Page'
      append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    endform.                               " form list_end.
    *&      Form  maratab1
          text
         -->P_RT_EXTAB  text
    FORM maratab1  USING    P_RT_EXTAB.
      SET PF-STATUS 'MARATAB1' EXCLUDING rt_extab.
    ENDFORM.                               " maratab1
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                         rs_selfield TYPE slis_selfield.
    case r_ucomm.
       when 'ENTER'.
       perform bulid_xls_data_table.
       PERFORM send_file_as_email_attachment
                                      tables it_message
                                             it_attach
                                       using p_email "'[email protected]'
                                    'Example .xls documnet attachment'
                                             'XLS'
                                             'filename'
                                    changing gd_error
                                             gd_reciever.
        perform populate_email_message_body.
        PERFORM initiate_mail_execute_program.
      endcase.                             " case r_ucomm.
    endform.                               " FORM user_command
    perform populate_email_message_body.
    PERFORM initiate_mail_execute_program.
         CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
    EXPORTING
       DATA_FILENAME             = 'MARA.XLS'
       DATA_PATH_FLAG            = 'W'
      DATA_ENVIRONMENT          =
       DATA_TABLE                = ITAB[]
      MACRO_FILENAME            =
      MACRO_PATH_FLAG           = 'E'
      MACRO_ENVIRONMENT         =
       WAIT                      = 'X'
      DELETE_FILE               = 'X'
    EXCEPTIONS
       NO_BATCH                  = 1
       EXCEL_NOT_INSTALLED       = 2
       INTERNAL_ERROR            = 3
       CANCELLED                 = 4
       DOWNLOAD_ERROR            = 5
       NO_AUTHORITY              = 6
       FILE_NOT_DELETED          = 7
       OTHERS                    = 8
       IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
       leave to list-processing.
    endcase.
    *&      Form  bulid_xls_data_table
          text
    *There are no interface parameters to be passed to this subroutine
    FORM bulid_xls_data_table .
    CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    constants:
        con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
        con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'matnr' 'ernam' 'aenam' 'pstat'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT It_mara INTO wa_charmara.
        CONCATENATE wa_charmara-matnr wa_charmara-ernam
                    wa_charmara-aenam wa_charmara-pstat
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.                             " LOOP AT it_mara INTO...
    ENDFORM.                               " bulid_xls_data_table
    *&      Form  send_file_as_email_attachment
       Send email
         -->P_IT_MESSAGE  text
         -->P_IT_ATTACH  text
         -->P_P_EMAIL  text
         -->P_0387   text
         -->P_0388   text
         -->P_0389   text
         -->P_0390   text
         -->P_0391   text
         -->P_0392   text
         <--P_GD_ERROR  text
         <--P_GD_RECIEVER  text
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error               TYPE sy-subrc,
            ld_reciever            TYPE sy-subrc,
            ld_mtitle              LIKE sodocchgi1-obj_descr,
            ld_email               LIKE  somlreci1-receiver,
            ld_format              TYPE  so_obj_tp ,
            ld_attdescription      TYPE  so_obj_nam ,
            ld_attfilename         TYPE  so_obj_des ,
            ld_sender_address      LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver            LIKE  sy-subrc.
      ld_email               = p_email.
      ld_mtitle              = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin  = space.
      t_packing_list-head_start  = 1.
      t_packing_list-head_num    = 0.
      t_packing_list-body_start  = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type    = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver   = ld_email.
      t_receivers-rec_type   = 'U'.
      t_receivers-com_type   = 'INT'.
      t_receivers-notif_del  = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.                               " send_file_as_email_attachment
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                               " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test mara records'.
      APPEND it_message.
    endform.                               "form populate_email_message_bod
    rewards if it helps u

  • Buttons in ALV Grid cell need focus to be clicked :-(

    Hi,
    I have an ALV Grid with single cells displayed as buttons (dependend on the data in the corresponding row). Unfortunatelly the button-cells need focus to be clicked. So you need two clicks: one to get the focus to the desired cell and one to really click the button.
    Any ideas how to make this work with one single click ? (Setting a hotspot does not work, cause hotspots have the same problem.)
    Regards,
    Tobi

    Hello Tobias
    The proposal by Naimesh is valid for CL_GUI_ALV_GRID, too. You may have a look at sample report ZUS_SDN_ALVGRID_EVENTS_HOTSPOT. Put the focus on any non-button cell and next click on any customer button.
    *& Report  ZUS_SDN_ALVGRID_EVENTS_HOTSPOT
    *& Thread: Buttons in ALV Grid cell need focus to be clicked :-(
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1009251"></a>
    REPORT  zus_sdn_alvgrid_events_hotspot.
    DATA:
      gd_okcode        TYPE ui_func,
      gt_fcat          TYPE lvc_t_fcat,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid.
    DATA:
      go_table              TYPE REF TO cl_salv_table,
      go_grid_adapter       TYPE REF TO cl_salv_grid_adapter.
    DATA:
      gt_knb1          TYPE STANDARD TABLE OF knb1.
    PARAMETERS:
      p_bukrs      TYPE bukrs  DEFAULT '2000'  OBLIGATORY.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender,  " grid instance that raised the event
          handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
            IMPORTING
              es_col_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_hotspot_click.
    *   define local data
        DATA:
          ls_knb1     TYPE knb1,
          ls_col_id   TYPE lvc_s_col.
        READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        CASE e_column_id-fieldname.
          WHEN 'KUNNR'.
            SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
            SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
            CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
          WHEN 'ERNAM'.
    *        SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
    *        NOTE: no parameter id available, yet simply show the priciple
            CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
    *       do nothing
        ENDCASE.
    *   Set active cell to field BUKRS otherwise the focus is still on
    *   field KUNNR which will always raise event HOTSPOT_CLICK
        ls_col_id-fieldname = 'BUKRS'.
        CALL METHOD go_grid1->set_current_cell_via_id
          EXPORTING
            is_row_id    = e_row_id
            is_column_id = ls_col_id.
      ENDMETHOD.                    "handle_hotspot_click
      METHOD handle_button_click.
    *   define local data
        DATA:
          ls_knb1     TYPE knb1.
        READ TABLE gt_knb1 INTO ls_knb1 INDEX es_row_no-row_id.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
        SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
        CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
      ENDMETHOD.                    "handle_button_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  knb1 INTO TABLE gt_knb1
             WHERE  bukrs  = p_bukrs.
    **  TRY.
    **      CALL METHOD cl_salv_table=>factory
    ***      EXPORTING
    ***      LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
    ***      R_CONTAINER    =
    ***      CONTAINER_NAME =
    **        IMPORTING
    **          r_salv_table   = go_table
    **        CHANGING
    **          t_table        = gt_knb1.
    **    CATCH cx_salv_msg .
    **  ENDTRY.
    **  go_table->display( ).
    **  go_table->get_metadata( ).
    **  EXIT.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc <> 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_hotspot_click FOR go_grid1,
        lcl_eventhandler=>handle_button_click  FOR go_grid1.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog_knb1.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = gt_knb1
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          OTHERS          = 4.
      IF sy-subrc <> 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
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    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.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FIELDCATALOG_KNB1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog_knb1 .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNB1'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        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.
      LOOP AT gt_fcat INTO ls_fcat
              WHERE ( fieldname = 'KUNNR'  OR
                      fieldname = 'ERNAM'  OR
                      fieldname = 'BUKRS' ).
        IF ( ls_fcat-fieldname = 'BUKRS' ).
          ls_fcat-style = cl_gui_alv_grid=>mc_style_button.
          " column appears as button
        ELSEIF ( ls_fcat-fieldname = 'KUNNR' ).
          ls_fcat-style = cl_gui_alv_grid=>mc_style_button.
          ls_fcat-hotspot = abap_true.
        ELSE.
          ls_fcat-hotspot = abap_true.
        ENDIF.
        MODIFY gt_fcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    Regards
      Uwe

Maybe you are looking for

  • A page that lists what was changed in Firefox 10.0.1 over 10.0

    Copy pasted from http://support.mozilla.org/en-US/questions/906503 Despite its title, the entire point of the thread is really not to see at some distant point in the future (for historical purposes) what the difference b/w incremental versions was.

  • How can I fix "catalog could not be opened due to an unexpected error"?

    I have many catalogs and this is only happening with one of them. I've done a Google search on the error message and tried some things that I found from those search results in forums.adobe.com and www.lightroomforums.net. I've tried deleting prefere

  • Installing Windows XP Pro or Vista on a MacBook

    Yes, i've backed up all my information onto a image disk. Now, i want to install Windows XP Pro or Vista onto my MacBook. What is the easiest way of doing this without slowing down my performance of my macbook??? I would like step by step instruction

  • Need to create .MP4 that works with iPhone/iPad

    Hi all, I'm under the gun here and running into a wall and would appreciate anyone's help: I'm currently creating video content that's being hosted on an HTML5-based site. Because of this, we have specific requirements about what we can/cannot use fo

  • How to publish a Captivate piece to Import as Animation with Media Player Controls

    I want to record a demonstration of an application using Captivate 3. Then, I want to publish this as a flash piece. (swf). Then, I want to "import as animation" into a WBT template using Captivate. The issue I am having is importing the flash piece