2016 Jan 26 3:20 PM
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!
2016 Jan 30 10:28 AM
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
2016 Jan 26 3:21 PM
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...
2016 Jan 27 11:11 PM
2016 Jan 29 10:18 AM
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.
2016 Jan 28 12:50 AM
Hi Karoly,
Please check below link if it helps you :
How to enhance mailing function ALV grid | SCN
Regards,
Richa
2016 Jan 29 10:41 AM
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
2016 Jan 30 9:07 AM
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.
2016 Jan 30 10:28 AM
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
2016 Feb 04 9:43 PM
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