Validation of data in editable ALV report output for particular field

Hi Experts,
I have one input enabled field in ALV output. How to validate the data once user enters  in that field and press enter? Is it possible to capture the value, hit the enter after user enters the data?
Thanks,
Surya Prakash

Halo Prakash,
1 First you should registeer the ENTER Event.
call method g_grid->register_edit_event
               exporting
                  i_event_id = cl_gui_alv_grid=>mc_evt_enter.
2 Declare event handler method for Event data_changed of cl_gui_alv_grid.
handle_data_changed
         for event data_changed of cl_gui_alv_grid
             importing er_data_changed.
3 Inside the Event handler method , you get the event parameter er_data_changed type ref to CL_ALV_CHANGED_DATA_PROTOCOL.
loop at er_data_changed->mt_good_cells into ls_good.
      case ls_good-fieldname.
        when 'FIELD1'.
          call method check_FIELD1.
        when 'FIELD2 '.
          call method check_FIELD2
      endcase.
    endloop.
4 Inside the Method check_FIELD1 and check_FIELD2 you can do the validation check .
call method er_data_changed->get_cell_value( Passing the row no and field name).
if the check  fails you can use add_protocol_entry to write the error.
5 Finally call
er_data_changed->display_protocol.
Regards
Arshad

Similar Messages

  • How can we edit alv report output.

    hi all,
    how can we edit alv report output

    \[removed by moderator as it was just a copy and paste answer of someone else's work without giving a source\]
    Edited by: Jan Stallkamp on Aug 25, 2008 4:35 PM

  • How to validate data in editable ALV report after making changes

    Hi Folks,
    My requirement is to display data in ALV format with quantity field is editable. Once we get the data in display mode only quantity field is enabled right. I am going to make changes to that quantity field and updating that modifed value to the database table. Before updating databse table i want to validate the data for perticluar field which I edidted(Quantity).
    Can you guide me on this.
    Currently I am using FM: GET_GLOBALS_FROM_SLVC_FULLSCR and calling the method CHECK_CHANGED_DATA.
    I want to validate the quantity data.
    If I entered negative value like -100 instead of 100. It should validate and show some popup screen or message.
    Pls guide me on this or give some code to do that.
    Thanks&Regards,
    Surendra

    Hey Surendra,
    Check if this helps: Link:[Click here|Edit Field in Oops Alv;
    There are many posts available for this requirement. Please look SDN/web for same.
    Regards,
    Santosh

  • Report Output for Currency Field--EKBE-WRBTR

    Hello ABAP Experts
    Since the Issue is related with Related Report output. Thought ABAP General Forum would be right place to post.
    If not Suggest an appropriate forum for the same. I shall post them in Correct Forum.
    Currently the report display Currency value From EKBE- WRBTR field
    Actual Record Stored in EKBE is like this
    0,00
    400,00
    1.600,00
    client requirement is
    0, 00
    400,00
    1600, 00
    Option-1
    I have tried option for conversion to CHAR & printing in Output, the issue I face is when I export to Excel I am getting an ABAP Error CONVT_NO_NUMBER(Short Dump)-This dump is due to conversion while exporting to excel.
    Option-2(from SDN)
    Give a logic based on T005 table i.e. this table has the decimal place setting for a each country (this I need to Verify)u2014But the I fear that report output can be confusing.
    Expecting all your expert inputs!!
    BR
    Bharath

    Hi Bharat,
    You can set it using user--profile I guess.
    For own data go to
    system>user profile>own data---> defaults.
    There you can select the currency format.
    Hope this helps you.
    Thanks,
    Arun

  • Adding/Enabling Totals & Subtotals Button in ALV Report Output

    Hi Guys,
    I would like to know , how to add / enable Totals & Subtotals Button on the application tool bar in alv report output.
    Regards,
    Kishan

    ok so here i am sending my code....its also interactive...
    and in second list i am displaying quantity....
    *& Report  ZINT_ALV
    REPORT  zint_alv.
    TYPE-POOLS:slis.
    TABLES:mara,
           makt,
           mseg.
    DATA:BEGIN OF itab OCCURS 0,
          matnr LIKE mara-matnr,
          maktx LIKE makt-maktx,
         END OF itab.
    DATA:BEGIN OF itab1 OCCURS 0,
          mblnr LIKE mseg-mblnr,
          menge LIKE mseg-menge,
          meins LIKE mseg-meins,
          werks LIKE mseg-werks,
         END OF itab1.
    DATA:fcat TYPE slis_t_fieldcat_alv,
         fcat1 TYPE slis_t_fieldcat_alv,
         eve TYPE slis_t_event,
         eve1 TYPE slis_t_event.
    DATA:t_mat LIKE mara-matnr,
         s_mat LIKE mara-matnr,
         g_repid LIKE sy-repid.
    SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:mat FOR mara-matnr OBLIGATORY.
    SELECTION-SCREEN:END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_fcat USING fcat.
      PERFORM build_eve.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM dis_data.
    *&      Form  build_fcat
          text
         -->T_FCAT     text
    FORM build_fcat USING t_fcat TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat TYPE slis_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-ref_fieldname = 'MATNR'.
      wa_fcat-ref_tabname = 'MARA'.
      wa_fcat-seltext_m = 'Material'.
    wa_fcat-input = ' '.
    wa_fcat-edit = 'X'.
      wa_fcat-input = 'X'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Description'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
    ENDFORM.                    "build_fcat
    *&      Form  build_eve
          text
    FORM build_eve.
      DATA:t_eve TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type           = 0
       IMPORTING
         et_events             = eve
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "build_eve
    *&      Form  get_data
          text
    FORM get_data.
      SELECT maramatnr maktmaktx INTO CORRESPONDING FIELDS OF TABLE itab
      FROM mara INNER JOIN makt
      ON maramatnr = maktmatnr
      WHERE mara~matnr IN mat.
    ENDFORM.                    "get_data
    *&      Form  dis_data
          text
    FORM dis_data.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = g_repid         "'ZINT_ALV'
         i_callback_user_command           = 'USER_COMMAND'
         i_grid_title                      = 'Interactive ALV'
         it_fieldcat                       = fcat
         it_events                         = eve
        TABLES
          t_outtab                          = itab
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "dis_data
    *&      Form  user_command
          text
         -->U_COM      text
    FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.
      CLEAR fcat1.
      CASE u_com.
        WHEN '&IC1'.
          READ TABLE itab INDEX sel_field-tabindex.
          IF sel_field-fieldname = 'MATNR'.
            IF sy-subrc = 0.
              t_mat = itab-matnr.
              PERFORM build_cat1 USING fcat1.
              PERFORM build_eve1.
              PERFORM get_data1.
              PERFORM dis_data1.
            ENDIF.
          ENDIF.
         SET PARAMETER ID 'MAT' FIELD t_mat.
         CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  build_fcat1
          text
         -->T_FCAT1    text
    FORM build_cat1 USING t_fcat1 TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat1 TYPE slis_fieldcat_alv.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MBLNR'.
      wa_fcat1-seltext_m = 'Material Doc.'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MENGE'.
      wa_fcat1-seltext_m = 'Quantity'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MEINS'.
      wa_fcat1-seltext_m = 'UOM'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'WERKS'.
      wa_fcat1-seltext_m = 'Plant'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
    ENDFORM.                    "build_fcat1
    *&      Form  build_eve1
          text
    FORM build_eve1.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = eve1
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                                    "build_eve1
    *&      Form  get_data1
          text
    FORM get_data1.
      SELECT mblnr menge meins werks FROM mseg
      INTO CORRESPONDING FIELDS OF TABLE itab1
      WHERE matnr = t_mat.
    ENDFORM.                                                    "get_data1
    *&      Form  dis_data1
          text
    FORM dis_data1.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = g_repid              "'ZINT_ALV'
         i_callback_user_command           = 'USER_COMMAND1'
         it_fieldcat                       = fcat1
         it_events                         = eve1
        TABLES
          t_outtab                          = itab1
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                                    "dis_data1

  • Doubt regarding editable ALV report using Classes

    I need to create an ALV report and make few fields editable
    and i need to update the changes  to the corresponding database tables
    for that please suggest me some idea or provide me sample code for that
    urgent

    Hi ramesh,
    Please check this example program. I think it will help for some extent.
    [code]&----
    *& Report  ZSUMA_INTERACTIVEREPORT                                     *
    report zsuma_interactivereport.
    tables: vbak.
    data :gr_alvgrid type ref to cl_gui_alv_grid,
          gr_cc_name type scrfname value 'CC_ALV',
          gr_ccontainer type ref to cl_gui_custom_container,
          gr_fieldcat type lvc_t_fcat,
          gr_layout type lvc_s_layo,
          gr_sort type lvc_t_sort,
          gr_get_cell type lvc_t_cell,
          gr_set_cell type lvc_t_cell,
          gr_hyper type lvc_t_hype,
          gr_drop_down type lvc_t_drop,
          is_variant type disvariant,
          line_number type lvc_s_roid-row_id,
          line(5) type c ,
          cell_value type lvc_value.
    data: begin of it_vbak occurs 0,
          vbeln type vbak-vbeln,
          erdat like vbak-erdat,
          erzet like vbak-erzet,
          netwr like vbak-netwr,
          waerk like vbak-waerk,
    *Below field is useful for making the entire row with different colors.
    it must be a char of 4.and layout-info_fname should populate with
    *this field.
          rowcolor(4) type c,
    *Below field is useful for making the INDIVIDUAL CELL with different
    *colors.for this we have to include structure of type lvc_t_scol.
    *layout-ctab_fname should be populate with this field.
          cellcolor type lvc_t_scol,
    *below field is added for for providing the hyperlinks to perticular
    *field. at the time of field catalog , it_fcatalog-web_field should be
    *populate with this field.
          vbeln_hyper type int4,
    *For displaying one cell as button.we have to declare one styles
    *internal table .it has to be populate.at layout structure this table
    *name has to be populate at layout-stylename.
         cellstyle type lvc_t_styl,
          end of it_vbak.
    *&   SELECTION SCREEN
    selection-screen begin of block b1 with frame title text-001.
    select-options s_vbeln for vbak-vbeln.
    selection-screen end of block b1.
    start-of-selection.
    select vbeln
           erdat
           erzet
           netwr
           waerk
           from vbak
           into corresponding fields of table it_vbak
           where vbeln in s_vbeln.
    data: wa_cellcolor type lvc_s_scol,
          wa_style type lvc_s_styl.
    loop at it_vbak.
    FOR ROW COLORING
    if sy-tabix = 1.
    it_vbak-rowcolor = 'C511'.
    FOR PUTTING THE HYPERLINKS ON VBELN FIELD
    it_vbak-vbeln_hyper = '1'.
    modify it_vbak.
    endif.
    FOR CELL COLORING
    if sy-tabix = 2.
    wa_cellcolor-fname = 'ERZET'.
    wa_cellcolor-color-col = '6'.
    wa_cellcolor-color-int = '1'.
    wa_cellcolor-color-inv = '1'.
    append wa_cellcolor to it_vbak-cellcolor.
    modify it_vbak index 2.
    endif.
    FOR DISPLAYING THE CELL AS A BUTTON
    clear it_vbak-cellstyle.
    at last.
    read table it_vbak index sy-tabix.
    wa_style-fieldname = 'NETWR'.
    wa_style-style = cl_gui_alv_grid=>mc_style_button.
    append wa_style to it_vbak-cellstyle .
    modify it_vbak .
    endat.
    endloop.
    if not it_vbak[] is initial.
      call screen 100.
    endif.
    *CLASS DEFINITION FOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler definition.
    public section.
    methods:handle_hotspot_click
                  for event hotspot_click of cl_gui_alv_grid
                   importing e_row_id e_column_id es_row_no.
    endclass.
    *CLASS IMPLEMENTATIONFOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler implementation.
    method handle_hotspot_click.
    perform handle_hotspot_click using e_row_id e_column_id es_row_no.
    endmethod.
    endclass.
    *&      Form  BUILDING_FIELDCATALOG
          text
         <--P_GR_FIELDCAT  text
    form building_fieldcatalog  changing p_gr_fieldcat type lvc_t_fcat.
    data s_fieldcat type lvc_s_fcat.
    s_fieldcat-fieldname = 'VBELN'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '1'.
    s_fieldcat-coltext   = 'DOCCUMENT NO.'.
    s_fieldcat-key   = ' '.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-web_field = 'VBELN_HYPER'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERDAT'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '2'.
    s_fieldcat-coltext   = 'REC CREATE DATE.'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-hotspot = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERZET'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '3'.
    s_fieldcat-coltext   = 'TIME ENTRY.'.
    *S_FIELDCAT-EMPHASIZE = 'C311'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'NETWR'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '4'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-coltext   = 'NET WEIGHT.'.
    s_fieldcat-do_sum   = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'WAERK'.
    s_fieldcat-outputlen = '5'.
    s_fieldcat-col_pos   = '5'.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-coltext   = 'CURR.'.
    FOR PUTTING THE DROP DOWN BOX.
    s_fieldcat-drdn_hndl = '1'.
    s_fieldcat-edit = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    endform.                    " BUILDING_FIELDCATALOG
    *&      Form  CREATE_CCONTAINER_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_ccontainer_instance .
    create object gr_ccontainer
    exporting
    container_name              = gr_cc_name
    exceptions
    cntl_error                  = 1
    cntl_system_error           = 2
    create_error                = 3
    lifetime_error              = 4
    lifetime_dynpro_dynpro_link = 5
    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.
    endform.                    " CREATE_CCONTAINER_INSTANCE
    *&      Form  CREATE_ALVGRID_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_alvgrid_instance .
    create object gr_alvgrid
      exporting
        i_parent          = gr_ccontainer
      exceptions
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        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.
    endform.                    " CREATE_ALVGRID_INSTANCE
    *&      Form  DISPLAYING_ALVGRID
          text
    -->  p1        text
    <--  p2        text
    form displaying_alvgrid .
    call method gr_alvgrid->set_table_for_first_display
      exporting
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
        is_variant                    = is_variant
        i_save                        = 'A'
       I_DEFAULT                     = 'X'
        is_layout                     = gr_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
        it_hyperlink                  = gr_hyper
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = it_vbak[]
        it_fieldcatalog               = gr_fieldcat
       it_sort                       = gr_sort
       IT_FILTER                     =
    EXCEPTIONS
       INVALID_PARAMETER_COMBINATION = 1
       PROGRAM_ERROR                 = 2
       TOO_MANY_LINES                = 3
       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.
    *CALL METHOD GR_ALVGRID->GET_FRONTEND_LAYOUT
    IMPORTING
       ES_LAYOUT = GR_LAYOUT
    *GR_LAYOUT-GRID_TITLE = 'HAI ALV'.
    *CALL METHOD GR_ALVGRID->SET_FRONTEND_LAYOUT
    EXPORTING
       IS_LAYOUT = GR_LAYOUT
    endform.                    " DISPLAYING_ALVGRID
    *&      Form  REFRESH_DISPLAY_TABLE
          text
    -->  p1        text
    <--  p2        text
    form refresh_display_table .
    call method gr_alvgrid->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.
    endform.                    " REFRESH_DISPLAY_TABLE
    *&      Form  SETTING_LAYOUT
          text
         <--P_GR_LAYOUT  text
    form setting_layout  changing p_gr_layout type lvc_s_layo.
    p_gr_layout-grid_title = 'ALV GRID USING ABAP OBJECTS'.
    p_gr_layout-zebra = 'X'.
    p_gr_layout-no_toolbar = ''.
    p_gr_layout-sel_mode = 'D'.
    p_gr_layout-info_fname = 'ROWCOLOR'.
    p_gr_layout-ctab_fname = 'CELLCOLOR'.
    p_gr_layout-stylefname = 'CELLSTYLE'.
    endform.                    " SETTING_LAYOUT
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    set pf-status 'MENU'.
    if gr_alvgrid is initial.
    *CREATING THE CONTAINER INSTANCE BY SENDING THE CONTAINER NAME( IT HAS
    *TO COINSIDE WITH COSTUM CONTROL NAME OF TRANSACTION SCREEN
    perform create_ccontainer_instance.
    perform create_alvgrid_instance.
    *VARIANT POPULATION.
    perform setting_variants changing is_variant.
    *BELOW FORM IS USEFUL TO FILL THE HYPER LINK TABLE AND WE PASS THAT
    *TABLE TO 'IT_HYPERLINK' PARAMETER IN FIRST DISPLAY METHOD.
    perform setting_hyperlinks_field changing gr_hyper.
    *TO MAKE THE COLOUMN AS DROP DOWN.
    perform setting_dropdown_column changing gr_drop_down.
    perform building_fieldcatalog changing gr_fieldcat.
    perform setting_layout changing gr_layout.
    perform setting_sorting changing gr_sort.
    perform setting_cells changing gr_set_cell.
    perform displaying_alvgrid.
    *PERFORM GETTING_CELL_DETAILS CHANGING GR_GET_CELL. " IT IS NOT WORKING
                                                 FOR ME AND I HAVE DOUBT .
    perform creating_event_object.
    *PERFORM REFRESH_DISPLAY_TABLE.
    endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
    case sy-ucomm.
      when 'BACK'.
      leave to screen 000.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  SETTING_SORTING
          text
         <--P_GR_SORT  text
    form setting_sorting  changing p_gr_sort type lvc_t_sort.
    data: lr_sort type lvc_s_sort.
    lr_sort-spos = '1'.
    lr_sort-fieldname = 'VBELN'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    lr_sort-spos = '2'.
    lr_sort-fieldname = 'ERDAT'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    endform.                    " SETTING_SORTING
    *&      Form  GETTING_CELL_DETAILS
          text
         <--P_GR_GET_CELL  text
    form getting_cell_details  changing p_gr_get_cell.
    call method gr_alvgrid->get_selected_cells
      importing
        et_cell = p_gr_get_cell
    *CELL_VALUE = P_GR_GET_CELL-VALUE.
    endform.                    " GETTING_CELL_DETAILS
    *&      Form  SETTING_CELLS
          text
         <--P_GR_SET_CELL  text
    form setting_cells  changing p_gr_set_cell type lvc_t_cell.
    data:s_gr_set_cell type lvc_s_cell.
    s_gr_set_cell-col_id-fieldname = 'NETWR'.
    s_gr_set_cell-row_id-index = '3'.
    append s_gr_set_cell to p_gr_set_cell.
    call method gr_alvgrid->set_selected_cells
      exporting
        it_cells = p_gr_set_cell.
    endform.                    " SETTING_CELLS
    *&      Form  SETTING_HYPERLINKS_FIELD
          text
         <--P_GR_HYPER  text
    form setting_hyperlinks_field  changing p_gr_hyper type lvc_t_hype.
    data: is_hype type lvc_s_hype.
    is_hype-handle = '1'.
    is_hype-href = 'HTTP://WWW.GOOGLE.CO.IN'.
    append is_hype to p_gr_hyper.
    is_hype-handle = '2'.
    is_hype-href = 'HTTP://SDN.SAP.COM'.
    append is_hype to p_gr_hyper.
    endform.                    " SETTING_HYPERLINKS_FIELD
    *&      Form  SETTING_DROPDOWN_COLUMN
          text
         <--P_GR_DROP_DOWN  text
    form setting_dropdown_column  changing p_gr_drop_down type lvc_t_drop.
    data: wa_drop type lvc_s_drop.
    wa_drop-handle = '1'.
    wa_drop-value = '$'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'Rs'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'CUR'.
    append wa_drop to p_gr_drop_down.
    call method gr_alvgrid->set_drop_down_table
      exporting
        it_drop_down       = p_gr_drop_down
       IT_DROP_DOWN_ALIAS =
    endform.                    " SETTING_DROPDOWN_COLUMN
    *&      Form  SETTING_VARIANTS
          text
         <--P_IS_VARIANT  text
    form setting_variants  changing p_is_variant type disvariant.
    p_is_variant-report = sy-repid.
    endform.                    " SETTING_VARIANTS
    *&      Form  HANDLE_HOTSPOT_CLICK
          text
         -->P_E_ROW  text
         -->P_E_COLUMN  text
         -->P_E_ROW_NO  text
    form handle_hotspot_click  using    p_e_row_id type lvc_s_row
                                        p_e_column_id type lvc_s_col
                                        p_es_row_no type lvc_s_roid.
    read table it_vbak index p_es_row_no-row_id.
    if sy-subrc = 0 and p_e_column_id-fieldname = 'ERDAT'.
    line = p_es_row_no-row_id.
    line_number = p_es_row_no-row_id.
    leave to screen 200.
    endif.
    endform.                    " HANDLE_HOTSPOT_CLICK
    *&      Form  CREATING_EVENT_OBJECT
          text
    -->  p1        text
    <--  p2        text
    form creating_event_object .
    data event_handle type ref to gr_event_handler.
    create object event_handle.
    set handler event_handle->handle_hotspot_click for gr_alvgrid.
    endform.                    " CREATING_EVENT_OBJECT
    *&      Module  STATUS_0200  OUTPUT
          text
    module status_0200 output.
      set pf-status 'BB'.
    SET TITLEBAR 'xxx'.
    *LINE = LINE_NUMBER.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    module user_command_0200 input.
    if sy-ucomm = 'BACK'.
    leave to screen 100.
    endif.
    endmodule.                 " USER_COMMAND_0200  INPUT[/code]
    Reward points if helpful
    Thanks,
    Suma.

  • Editable ALV reports

    hi,
    do we have an option of creating Editable ALV reports in SAP.If yes can u plz explain me how to ? wht function modules should be used?

    use -> wa_fieldcat-edit = 'X'. "sets whole column to be editable
    here is a code i did for editable ALV,
    *& Report ZDEMO_ALVGRID_EDIT *
    *& Example of a simple ALV Grid Report *
    *& The basic ALV grid, Enhanced to display specific fields as *
    *& editable depending on field value *
    REPORT ZDEMO_ALVGRID_EDIT .
    TABLES: ekko.
    TYPE-POOLS: slis. "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
    ebeln TYPE ekpo-ebeln,
    ebelp TYPE ekpo-ebelp,
    statu TYPE ekpo-statu,
    aedat TYPE ekpo-aedat,
    matnr TYPE ekpo-matnr,
    menge TYPE ekpo-menge,
    meins TYPE ekpo-meins,
    netpr TYPE ekpo-netpr,
    peinh TYPE ekpo-peinh,
    field_style TYPE lvc_t_styl, "FOR DISABLE
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
    wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
    wa_fieldcat TYPE lvc_s_fcat,
    gd_tab_group TYPE slis_t_sp_group_alv,
    gd_layout TYPE lvc_s_layo, "slis_layout_alv,
    gd_repid LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    PERFORM data_retrieval.
    PERFORM set_specific_field_attributes.
    PERFORM build_fieldcatalog.
    PERFORM build_layout.
    PERFORM display_alv_report.
    *& Form BUILD_FIELDCATALOG
    Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
    wa_fieldcat-fieldname = 'EBELN'.
    wa_fieldcat-scrtext_m = 'Purchase Order'.
    wa_fieldcat-col_pos = 0.
    wa_fieldcat-outputlen = 10.
    wa_fieldcat-emphasize = 'X'.
    wa_fieldcat-key = 'X'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'EBELP'.
    wa_fieldcat-scrtext_m = 'PO Item'.
    wa_fieldcat-col_pos = 1.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'STATU'.
    wa_fieldcat-scrtext_m = 'Status'.
    wa_fieldcat-col_pos = 2.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'AEDAT'.
    wa_fieldcat-scrtext_m = 'Item change date'.
    wa_fieldcat-col_pos = 3.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-scrtext_m = 'Material Number'.
    wa_fieldcat-col_pos = 4.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'MENGE'.
    wa_fieldcat-scrtext_m = 'PO quantity'.
    wa_fieldcat-col_pos = 5.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'MEINS'.
    wa_fieldcat-scrtext_m = 'Order Unit'.
    wa_fieldcat-col_pos = 6.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'NETPR'.
    wa_fieldcat-scrtext_m = 'Net Price'.
    wa_fieldcat-edit = 'X'. "sets whole column to be editable
    wa_fieldcat-col_pos = 7.
    wa_fieldcat-outputlen = 15.
    wa_fieldcat-datatype = 'CURR'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'PEINH'.
    wa_fieldcat-scrtext_m = 'Price Unit'.
    wa_fieldcat-col_pos = 8.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    ENDFORM. " BUILD_FIELDCATALOG
    *& Form BUILD_LAYOUT
    Build layout for ALV grid report
    FORM build_layout.
    Set layout field for field attributes(i.e. input/output)
    gd_layout-stylefname = 'FIELD_STYLE'.
    gd_layout-zebra = 'X'.
    ENDFORM. " BUILD_LAYOUT
    *& Form DISPLAY_ALV_REPORT
    Display report using ALV grid
    FORM display_alv_report.
    gd_repid = sy-repid.
    call function 'REUSE_ALV_GRID_DISPLAY'
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
    i_callback_program = gd_repid
    i_callback_user_command = 'USER_COMMAND'
    is_layout_lvc = gd_layout
    it_fieldcat_lvc = it_fieldcat
    i_save = 'X'
    TABLES
    t_outtab = it_ekko
    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_REPORT
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
    SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
    UP TO 10 ROWS
    FROM ekpo
    INTO CORRESPONDING FIELDS OF TABLE it_ekko.
    ENDFORM. " DATA_RETRIEVAL
    *& Form set_specific_field_attributes
    populate FIELD_STYLE table with specific field attributes
    form set_specific_field_attributes .
    DATA ls_stylerow TYPE lvc_s_styl .
    DATA lt_styletab TYPE lvc_t_styl .
    Populate style variable (FIELD_STYLE) with style properties
    The NETPR field/column has been set to editable in the fieldcatalog...
    The following code sets it to be disabled(display only) if 'NETPR'
    is gt than 10.
    LOOP AT it_ekko INTO wa_ekko.
    IF wa_ekko-netpr GT 10.
    ls_stylerow-fieldname = 'NETPR' .
    ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
    "set field to disabled
    APPEND ls_stylerow TO wa_ekko-field_style.
    MODIFY it_ekko FROM wa_ekko.
    ENDIF.
    ENDLOOP.
    endform. " set_specific_field_attributes
    Thanks
    Seshu

  • Double Click on ALV Report Output, Bringing to selections creen

    Hello Gurus,
    Please help me When i do double click on ALV Report  output , it is going back to Selection screen, actually its working as Back button. Now how to stop it.. I did debugging but i cannot trace it.

    PERFORM SUB_CREATE_FCAT.
    DATA W_REPID LIKE SY-REPID.
        W_REPID = SY-REPID.
    ls_layout-colwidth_optimize = 'X'.
    ls_layout-zebra = 'X'.
    PERFORM SUB_SORT.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
          I_CALLBACK_PROGRAM                 = SY-CPROG
          I_CALLBACK_PF_STATUS_SET          = 'STATUS'
           I_CALLBACK_USER_COMMAND           = 'C_USERCOMMAND '
    *     I_CALLBACK_TOP_OF_PAGE            = ' '
    *     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *     I_CALLBACK_HTML_END_OF_LIST       = ' '
    *     I_STRUCTURE_NAME                  =
    *     I_BACKGROUND_ID                   = ' '
    *     I_GRID_TITLE                      =
    *     I_GRID_SETTINGS                   =
           IS_LAYOUT                         = ls_layout
           IT_FIELDCAT                       = IT_FIELDCAT
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS                 =
           IT_SORT                           = IT_SORT
    *     IT_FILTER                         =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
          I_SAVE                            = 'U'
    *     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                          = T_FINAL
    *   EXCEPTIONS
    *     PROGRAM_ERROR                     = 1
    *     OTHERS                            = 2
       IF sy-subrc <> 0.
    * Implement suitable error handling here
       ENDIF.

  • ALV Report output in Excel format

    Hi ,
    I am facing a different behaviour in two computers , while trying to take an Excel format of an ALV report output. After generating the ALV output ,in one , when I click on the Excel Format button - the Excel spreadsheet opens with the output data. In the second computed , under the same action , a blank Excel sheet opens .
    Could someone tell me a solution . What aspect is responsible for this ?
    Regards ,
    Sujata

    Reduce the MACRO security settings in the Excel to Medium.
    Open an execl sheet, Chose from menu Tootls->Macro->Security.
    Chose the radio-buton medium. Close the file and all excel applications.Then try downloading again.
    Regards,
    Ravi

  • 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

  • Select  mutiple rows in ALV report output

    Hi All,
    I want to select the Multiple records i in ALV report output with out holding the CNTL(Control Key).
    Is there any options in Layout?
    Please let me know
    regards,
    Ajay
    Edited by: Ajay reddy on May 30, 2010 3:27 PM

    Hi Ajay,
    To select several rows without Control button, if the rows are adjacent:
    - select the first and the last of the desired rows with Shift button pressed
    or
    - select a row, keep the mouse button pressed, and pass over the desired rows
    I don't know an option without Control if the rows are not adjacent.
    http://help.sap.com/saphelp_bw/helpdata/en/d1/7d9d37664e4d45e10000009b38f8cf/content.htm
    Regards,
    Paulo Carvalho

  • Problem when dowloading the ALV report output to Excel Sheet.

    Hi ,
    I am dowloading the ALV report output to Excel Sheet.
    There is field Condition Unit(KOMP-KMEIN) in the output of the ALV, this has values PC and CSE , but when I download to Excel Sheet, CSE is appearing as CSE ,but PC is appearing as ******.
    Can you please help me in knowing the reson for this.
    Regards,
    Madhu.

    hi
    refer to following link
    http://www.****************/Tutorials/ALV/ColorSALV/Demo.htm
    http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
    Cheers
    Snehi
    Edited by: snehi chouhan on Jul 11, 2008 12:42 PM

  • Download alv report output to excel format with out header line

    Hi experts,
    i want to download a alv report output into excel formatt with out the header line but it has to download including field description. as this output will fed into another transaction, the downloaded excel file should be with out header line.
    fro eg:
    Report   : Zabc                      ABAP Development          Page  :     1
    Run Date : 12/14/06                                                     System: UD400 
    Run Time : 08:45:37
    this header details should not be downloaded into the excel file.
    could somebody help me please.
    thanks
    deepu

    hi jayanti,
    thanks for your response.
    i have delclared all the field types as character but still it is not downloading and it 's sy-subrc is 4... the code is as below.
    *field names
      lt_fieldnames-value = 'Material Number'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Plant'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Material Group'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Material Description'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'UOM'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Price Unit'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Material Type'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'X-Plant Status'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Valuation Class'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = lw_avmng.
      APPEND lt_fieldnames.
      lt_fieldnames-value = lw_avntp.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Latest PO Qty'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Latest PO Cost'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'PO Creation Date'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = lw_fcaqt.
      APPEND lt_fieldnames.
      lt_fieldnames-value = 'Prev. Yr. Std. Cost'.
      APPEND lt_fieldnames.
      lt_fieldnames-value = lw_stcst.
      APPEND lt_fieldnames.
      CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
        EXPORTING
          file_name                       = 'XLSHEET'
        CREATE_PIVOT                    = 0
        DATA_SHEET_NAME                 = ' '
        PIVOT_SHEET_NAME                = ' '
        PASSWORD                        = ' '
        PASSWORD_OPTION                 = 0
        TABLES
        PIVOT_FIELD_TAB                 =
          data_tab                        = t_output1
          fieldnames                      = lt_fieldnames
        EXCEPTIONS
          file_not_exist                  = 1
          filename_expected               = 2
          communication_error             = 3
          ole_object_method_error         = 4
          ole_object_property_error       = 5
          invalid_pivot_fields            = 6
          download_problem                = 7
          OTHERS                          = 8
      IF sy-subrc <> 0.
        MESSAGE e001 WITH 'Data could not be downloaded'.
      ENDIF.
    ENDFORM.                               " z_dwn_xl
    thanks
    deepu

  • Mailing ALV report OUTPUT

    Hi Experts,
    Can you give an example program on mailing ALV report output to any ID.
    Thanks in advance.
    Regards,
    Ram

    Hi ram
    Here i'm posting u sample code try to execute it. It will convert all the data in the related tables to excel format and transfer it to respective mail id
    *& Report  ZTESTMAIL                                                   *
    REPORT  ZTESTMAIL                               .
    tables: ekko.
    parameters: p_email type somlreci1-receiver default
    '[email protected]'.
    types: begin of t_ekpo,
    ebeln type ekpo-ebeln,
    ebelp type ekpo-ebelp,
    aedat type ekpo-aedat,
    matnr type ekpo-matnr,
    end of t_ekpo.
    data: it_ekpo type standard table of t_ekpo initial size 0,
    wa_ekpo type t_ekpo.
    types: begin of t_charekpo,
    ebeln(10) type c,
    ebelp(5) type c,
    aedat(8) type c,
    matnr(18) type c,
    end of t_charekpo.
    data: wa_charekpo type t_charekpo.
    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.
    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.
    t_object_header = 'Text.xls'. append t_object_header.
    *START_OF_SELECTION
    start-of-selection.
    * Retrieve sample data from table ekpo
    perform data_retrieval.
    * Populate table with detaisl to be entered into .xls file
    perform build_xls_data_table.
    *END-OF-SELECTION
    end-of-selection.
    * Populate message body text
    perform populate_email_message_body.
    * Send file by email as .xls speadsheet
    perform send_file_as_email_attachment
    tables it_message
    it_attach
    using p_email
    'Example .xls documnet attachment'
    'XLS'
    'filename'
    changing gd_error
    gd_reciever.
    * Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *& Form DATA_RETRIEVAL
    * Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp aedat matnr
    up to 10 rows
    from ekpo
    into table it_ekpo.
    endform. " DATA_RETRIEVAL
    *& Form BUILD_XLS_DATA_TABLE
    * Build data table for .xls document
    form build_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 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    loop at it_ekpo into wa_charekpo.
    concatenate wa_charekpo-ebeln wa_charekpo-ebelp
    wa_charekpo-aedat wa_charekpo-matnr
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    endloop.
    endform. " BUILD_XLS_DATA_TABLE
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    * Send email
    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
    object_header = t_object_header
    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.
    *& 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 ekpo records'.
    append it_message.
    endform. " POPULATE_EMAIL_MESSAGE_BODY
    *PARAMETERS: psubject(40) type c default 'Testing',
    *p_email(40) type c default '[email protected]'. "use ur email id
    *data: it_packing_list like sopcklsti1 occurs 0 with header line,
    *it_contents like solisti1 occurs 0 with header line,
    *it_receivers like somlreci1 occurs 0 with header line,
    *it_attachment like solisti1 occurs 0 with header line,
    *gd_cnt type i,
    *gd_sent_all(1) type c,
    *gd_doc_data like sodocchgi1,
    *gd_error type sy-subrc.
    *data: it_message type standard table of SOLISTI1 initial size 0
    *with header line.
    **START-OF-SELECTION.
    *START-OF-SELECTION.
    *Perform populate_message_table.
    **Send email message, although is not sent from SAP until mail send
    **program has been executed(rsconn01)
    *PERFORM send_email_message.
    **Instructs mail send program for SAPCONNECT to send email(rsconn01)
    *perform initiate_mail_execute_program.
    **& Form POPULATE_MESSAGE_TABLE
    ** Adds text to email text table
    *form populate_message_table.
    *Append 'Line1' to it_message.
    *Append 'Line2' to it_message.
    *Append 'Line3' to it_message.
    *Append 'Test- 1' to it_message.
    *endform. " POPULATE_MESSAGE_TABLE
    **& Form SEND_EMAIL_MESSAGE
    ** Send email message
    *form send_email_message.
    ** Fill the document data.
    *gd_doc_data-doc_size = 1.
    ** DATA: TAB_LINES LIKE sy-tabix.
    ** DESCRIBE TABLE it_message LINES TAB_LINES.
    ** READ TABLE it_message INDEX TAB_LINES.
    ** gd_doc_data-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( it_message )
    ** Populate the subject/generic message attributes
    *gd_doc_data-obj_langu = sy-langu.
    *gd_doc_data-obj_name = 'SAPRPT'.
    *gd_doc_data-obj_descr = psubject.
    *gd_doc_data-sensitivty = 'F'.
    ** Describe the body of the message
    ** Information about structure of data tables
    *clear it_packing_list.
    *refresh it_packing_list.
    *it_packing_list-transf_bin = space.
    *it_packing_list-head_start = 1.
    *it_packing_list-head_num = 0.
    *it_packing_list-body_start = 1.
    *describe table it_message lines it_packing_list-body_num.
    *it_packing_list-doc_type = 'RAW'.
    *append it_packing_list.
    ** Add the recipients email address
    *clear it_receivers.
    *refresh it_receivers.
    *it_receivers-receiver = p_email.
    *it_receivers-rec_type = 'U'.
    ** it_receivers-com_type = 'INT'.
    ** it_receivers-notif_del = 'X'.
    ** it_receivers-notif_ndel = 'X'.
    *append it_receivers.
    ** Call the FM to post the message to SAPMAIL
    *call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    *exporting
    *document_data = gd_doc_data
    *put_in_outbox = 'X'
    *importing
    *sent_to_all = gd_sent_all
    *tables
    *packing_list = it_packing_list
    *contents_txt = it_message
    *receivers = it_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.
    ** Store function module return code
    *gd_error = sy-subrc.
    ** Get it_receivers return code
    *loop at it_receivers.
    *endloop.
    *endform. " SEND_EMAIL_MESSAGE
    **& Form INITIATE_MAIL_EXECUTE_PROGRAM
    ** Instructs mail send program for SAPCONNECT to send email.
    *form initiate_mail_execute_program.
    *wait up to 2 seconds.
    *if gd_error eq 0.
    *submit rsconn01 with mode = 'INT'
    *with output = 'X'
    *and return.
    *endif.
    *endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    Rewards if helpfull
    Regards
    Pavan

  • How to send the ALV report output by automated email.

    Hi All,
    Can any one advice how to send ALV report output by automated email.
    Thanks in advance.
    Vikram.
    Edited by: vikram mallavaram. on Oct 13, 2011 3:26 PM
    Moderator message: FAQ, please search for previous discussions of this topic.
    Edited by: Thomas Zloch on Oct 13, 2011 3:27 PM

    Hi Ramya,
    Check the links below :
    http://wiki.sdn.sap.com/wiki/display/Snippets/Sending+Mail
    http://wiki.sdn.sap.com/wiki/display/Snippets/AbapEMAILProgram
    http://wiki.sdn.sap.com/wiki/display/ABAP/SendMessagetoExternalemailidandSAPUseridvia+ABAP
    They will explain you to send an email.
    Regards,
    Kittu

Maybe you are looking for

  • Album shuffle in iTunes 8.1

    Since i have downloaded iTunes 8.1, i've got a strange problem with the album shuffle function. The normal behaviour of itunes while playing in album shuffle mode is to play : 1. first track of the album 2. second track 3. third track. Itunes 8.1 wil

  • Using 2 green screen clips and need to resize as one

    I am using 2 green screen clips - one is a prop and the other shows kids.  I have successfully loaded both into the Premiere timeline.  I would like for the two to act as one so that I can resize them at the same time so I can zoom in on the kids.  

  • Db sequence work in bc4j tester but not at jsp editform? !

    According to "HOWTO#:Use BC4J With or Without DB Triggers",i use db trigger and db sequence to realize insert primary key value from sequence. It work fine at bc4j tester ,however at jsp it produce error. error information: Error Message: ORA-01401:

  • How does one connect to an Oracle Database using OO4O as sysdba using VB 6?

    Hi, Can any one give suggestion to connect an Oracle Database using OO4O as sysdba using VB 6.0. Generally it supports only database, userid/password only. For Eg: Option Explicit Dim m_oraSession As Object Dim m_oraDatabase As Object Private Sub Com

  • Windows 2008 R2 ODBC connect to Oracle Linux with 11g db

    Hi i installed a fresh oracle linux and installes 11.2.0 database server. the server works fine but i have a proplem to connect to the database from a windows 2008 r2 client. For the client connection i installed the oracle instantclient on the windo