Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV mail button popuplate email

kroly_horvth
Participant
0 Kudos
1,550

HI,

In the standard ALV grid there is a MAIL button in the standard ALV toolbar. Is it possible to populate fields and content before it is displaying the SAP standard mail sending interface? I would like to populate subject, content and adressees from an ABAP code (like put SO10 text there). Is this possible?

Thanks!

1 ACCEPTED SOLUTION

gabmarian
Active Contributor
0 Kudos
481

The mail sending dialog of the ALV GRID is called via FM 'SO_DYNP_DOCUMENT_TRANSFER_API1' tru RFC. As far as I can see there is no standard way to influence the behavior it is called.

However, it seems to have quite similar interface to SO_NEW_DOCUMENT_SEND_API1, so I'd say it could worth a try to call this directly in an own event handler. You can add your mail content thru parameter NOTE_TEXT (I've tested this during debugging).

BR,

Gábor

8 REPLIES 8

kroly_horvth
Participant
0 Kudos
481

Please note I am talking about the standard ALV send mail button. I could create my own send mail function, but then I would have to create a dialog for editing email content,subject etc...

0 Kudos
481

What exactly are you calling "standard ALV grid"?

0 Kudos
481

I simply call REUSE_ALV_GRID_DISPLAY fncmodule without any special parameters, it displays its own toolbar. Now when I click on the MAIL button it pops up the standard email sending interface. This is all inside the SAP ALV code, there is no external ABAP code used.

Now I would like to populate fields in this mail popup window, if possible.

Richa_Gupta
Contributor
0 Kudos
481

Hi Karoly,

Please check below link if it helps you :

How to enhance mailing function ALV grid | SCN

Regards,

Richa

kumar_sp
Explorer
0 Kudos
481

Hi karoly,

   You should pass custom GUI status in REUSE_ALV_GRID_DISPLAY after that you have to defined mail button and developed subroutine for custom GUI Status. in that you will write what function you want.

please check the follow the below mentioned screen shot.

Regards,

Kumar

0 Kudos
481

Thanks for the tip, I know about adding my own event handler, but then I have to create a mail sending dialog with ABAP code along with the SO_NEW_DOCUMENT... fncmodule.

gabmarian
Active Contributor
0 Kudos
482

The mail sending dialog of the ALV GRID is called via FM 'SO_DYNP_DOCUMENT_TRANSFER_API1' tru RFC. As far as I can see there is no standard way to influence the behavior it is called.

However, it seems to have quite similar interface to SO_NEW_DOCUMENT_SEND_API1, so I'd say it could worth a try to call this directly in an own event handler. You can add your mail content thru parameter NOTE_TEXT (I've tested this during debugging).

BR,

Gábor

gabmarian
Active Contributor
0 Kudos
481

I've dug a bit deeper into the topic and was able to create an example report using 'SO_DYNP_DOCUMENT_TRANSFER_API1'. I have to say its pretty impressive, and could prove useful.

[The tricky thing in the story was how to save the ALV data into list format to be able to attach it to the mail. (for this I submitted the original report and exported the list to memory). Maybe there is a neater way to do that....]

But its working!

Here is the code:

REPORT y_alv_mail_enh.

DATA :
   gt_sflight TYPE TABLE OF sflight,
   gd_repid   TYPE sy-repid VALUE sy-repid.

*---------------------------------------------------------------------*
START-OF-SELECTION.
*---------------------------------------------------------------------*

   SELECT * FROM sflight INTO TABLE gt_sflight.

*---------------------------------------------------------------------*
END-OF-SELECTION.
*---------------------------------------------------------------------*

   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program       = gd_repid
       i_structure_name         = 'SFLIGHT'
       i_callback_user_command  = 'ALV_USER_COMMAND'
       i_callback_pf_status_set = 'ALV_PF_STATUS'
     TABLES
       t_outtab                 = gt_sflight.

*&---------------------------------------------------------------------*
*&      Form  ALV_PF_STATUS
*&---------------------------------------------------------------------*
FORM alv_pf_status
   CHANGING
     ct_extab TYPE slis_t_extab.

   SET PF-STATUS 'STANDARD_FULLSCREEN'.

ENDFORM.                    "ALV_PF_STATUS

*&---------------------------------------------------------------------*
*&      Form  ALV_USER_COMMAND
*&---------------------------------------------------------------------*
FORM alv_user_command
   USING
     id_ucomm    TYPE sy-ucomm
   CHANGING
     rs_selfield TYPE slis_selfield.

   CASE id_ucomm.

     WHEN '$MAIL'.

       SUBMIT (gd_repid) EXPORTING LIST TO MEMORY AND RETURN.

       PERFORM list_to_office
         USING
           'example_email_address'
           'This is some example text'.

   ENDCASE.

ENDFORM.                    "ALV_USER_COMMAND


*&---------------------------------------------------------------------*
*&      Form  LIST_TO_OFFICE
*&---------------------------------------------------------------------*
FORM list_to_office
   USING
     id_receiver TYPE clike
     id_notetext TYPE clike.

* Source code based on FM LIST_TO_OFFICE
   DATA :
     lt_listobject TYPE STANDARD TABLE OF abaplist,
     lt_solix      TYPE solix_tab,
     lt_soli       TYPE soli_tab,
     ls_doc_data   TYPE sodocchgi1,
     lt_receivers  TYPE STANDARD TABLE OF somlrec90,
     ls_receivers  LIKE LINE OF lt_receivers,
     lt_note_text  TYPE STANDARD TABLE OF solisti1,
     ls_note_text  LIKE LINE OF lt_note_text.

   CALL FUNCTION 'LIST_FROM_MEMORY'
     TABLES
       listobject = lt_listobject
     EXCEPTIONS
       OTHERS     = 1.

   CALL FUNCTION 'TABLE_COMPRESS'
     TABLES
       in     = lt_listobject
       out    = lt_solix
     EXCEPTIONS
       OTHERS = 1.

   IF sy-subrc <> 0.
     RETURN.
   ENDIF.

   CALL FUNCTION 'SO_SOLIXTAB_TO_SOLITAB'
     EXPORTING
       ip_solixtab = lt_solix
     IMPORTING
       ep_solitab  = lt_soli.

   ls_doc_data-doc_size   = lines( lt_soli ) * 255.
   ls_doc_data-obj_langu  = sy-langu.
   ls_doc_data-obj_name   = 'List'.
   ls_doc_data-obj_descr  = 'Enhanced mail functionality'.
   ls_doc_data-sensitivty = 'O'.

   ls_note_text-line = id_notetext.
   APPEND ls_note_text TO lt_note_text.

   ls_receivers-receiver = id_receiver.
   ls_receivers-rec_type = 'U'.
   APPEND ls_receivers TO lt_receivers.

   CALL FUNCTION 'SO_DYNP_DOCUMENT_TRANSFER_API1'
     EXPORTING
       document_data  = ls_doc_data
       document_type  = 'ALI'
       method         = 'SNDA'
       starting_at_x  = '5'
       starting_at_y  = '5'
     TABLES
       object_content = lt_soli
       note_text      = lt_note_text
       receivers      = lt_receivers
     EXCEPTIONS
       OTHERS         = 1.

ENDFORM.                    "LIST_TO_OFFICE