2014 Feb 03 1:39 PM
Hi all,
I have a report with alv grid display.I am using the standard mail functionality icon to send mails.When i select a single row and click on the icon to send the mail,my entire list gets sent in the attachment whereas i need only the row which i selected to be send.Could anyone guide me in this issue?
2014 Feb 03 1:44 PM
Hi,
Try to have the main table transferred to tremporary.
Check get_selected_rows method and try to get the selected ones in another table and then transfer to main table before the standard functionality is trigerred. You may want to use another custom icon for achieving this and call the standard in this.
2014 Feb 03 1:44 PM
Hi,
Try to have the main table transferred to tremporary.
Check get_selected_rows method and try to get the selected ones in another table and then transfer to main table before the standard functionality is trigerred. You may want to use another custom icon for achieving this and call the standard in this.
2014 Feb 03 1:59 PM
Hi Reema ,
Please debugg the your program where the mail content are passing.. there please give some condition i.e transfer the internal table to one work area where selected row is 'X'. here pass the work area content to mail .
if you not getting mean place your coding..
Regards,
Thangam.P
2014 Feb 04 5:03 AM
Hi Jayanthi,
Could you provide me with the sample code as am new to this.
Thanks.
2014 Feb 04 5:09 AM
Hi Thangam,
When debugging,the control enters into the standard program where i cant do any modification.
Thanks.
2014 Feb 04 5:11 AM
Hi Reema,
If you are using REUSE_ALG_GRID_DISPLAY, in Usercommand routine you can capture the selected row index with variable rs_selfield-tabindex. So, then select the content from output table with index and pass that to mail body.
Have a look on this example to capture the selected row.
ABAP Interactive ALV Program - Code Gallery - SCN Wiki
Thanks & Regards,
Vijay
2014 Feb 04 5:21 AM
Just move that row to the internal table that is passed to the mail Sending FM.
case ok_code. (In the user command for classic ALV, or in the PAI module for OOPs ALV)
Here I am illustrating as for classic ALV.
DATA: lt_mailtxt TYPE STANDARD TABLE OF soli WITH HEADER LINE.
DATA: lt_mailsubject TYPE sodocchgi1.
DATA: lt_mailrecipients TYPE STANDARD TABLE OF somlrec90 WITH HEADER LINE.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&MAIL'.
* IF data was changed use this too.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
* Read the selected row into work area.
READ TABLE it_data INTO wa_data INDEX rs_selfield-tabindex.
* Fill the recipient details in lt_mailrecipients table
lt_mailrecipients-rec_type = 'U'.
lt_mailrecipients-receiver = 'abc@xyz.com'.
APPEND lt_mailrecipients .
CLEAR lt_mailrecipients .
* Fill the subject details in lt_mailsubject table.
lt_mailsubject-obj_name = 'Subject'.
lt_mailsubject-obj_langu = sy-langu.
lt_mailsubject-obj_descr = 'Row wise mailing'.
*append lt_mailsubject.
* Move only the details of selected row to the internal table for the contents of the mail.
CLEAR lt_mailtxt.
* move values in wa_data to lt_mailtxt
APPEND lt_mailtxt.
* Send Mail using the FM.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = lt_mailsubject
TABLES
object_content = lt_mailtxt
receivers = lt_mailrecipients
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.
IF sy-subrc EQ 0.
commit work and wait.
* Push mail out from SAP outbox
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
ENDIF.
By the way, you need to create your own GUI Status, (Copy of standard GUI) include the custom mail sending icon with function code and write the above code to implement your functionality.
2014 Feb 04 7:33 AM
Hi Reema,
As susmitha as posted just pass user command form name in your ALV grid FM and handle user command for email functionality of your ALV display in user command subroutine.
** Declare a field in your final Data table which you will pass in ALV grid FM as below,
********* SELID TYPE C ********
** In fieldcatalog declare NO_OUT parameter for above field as 'X".
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gc_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = gt_fieldcat[]
is_layout = gt_layout
TABLES
t_outtab = gt_final_alv
EXCEPTIONS
program_error = 1
OTHERS = 2
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&MAIL'.
* for Email functionality.
**** Create an internal table for inporting the selected entry by
**** looping at your final ALV data table as below,
**** I Assumed gt_final_alv as final data table.
LOOP AT GT_FINAL_ALV ASSIGNING <LF_WA_ALV>
WHERE SELID EQ ABAP_TRUE. " 'X'
**** The Field SELID will be 'X' only for selected line from ALV Display
**** Append entries to a internal table as pass this new internal table **** for email funcationality.
ENDLOOP.
ENDFORM
Note: For Email Functionality you can use Function module as Susmitha as posted or else you can use OOPS concept by using class Interface CL_BCS.
You can sreach SCN as there are lot of post related to CL_BCS.
Thanks,
M Nair
2014 Feb 05 7:21 AM
Hi ManiKandan,
I need to send the mail using the standard functionality only .Any idea how to do that would be helpful.
Thanks.
2014 Feb 05 7:30 AM
Hi Reema,
In your final internal table must have the one column like below (COL).
DATA: BEGIN OF FIN_REV OCCURS 0,
COL,
MATNR TYPE VBRP-MATNR,
WERKS TYPE VBRP-WERKS,
MAKTX TYPE MAKT-MAKTX,
MTART TYPE MARA-MTART,
MATKL TYPE MARA-MATKL,
KUNAG TYPE VBRK-KUNAG,
NAME1 TYPE KNA1-NAME1,
QUANT TYPE VBRP-LMENG,
END OF FIN_REV.
Then you have to set your layout like below.
LAYOUT-BOX_FIELDNAME = 'COL'.
While sending a mail, write a code...
Selected row value will be COL = 'X'.
LOOP AT FIN_REV WHERE COL = 'X'.
ENDLOOP.
Hope you understand.
Arivazhagan S