Home | SAP Object | Thread | CL_DOCUMENT_BCS
Class (ABAP Objects)
» See all 132 related threads
Jul 11 05

Aattach an existing Excel file to an email from SAP system.  

07:33 // Kevin Dass

Hi,

How can I attach an existing Excel file from SAP system (Example in 'DIR_TEMP' folder) & send a mail. Guess this requires a class with a method which picks up the file using the file path. Does CL_DOCUMENT_BCS provides this???? boz CL_DOCUMENT_BCS->ADD_DOCUMENT_AS_ATTACHMENT is for Add Existing Document as an Attachment,if so please let me know how with few lines of code??

Thankx in advance.

 
Jul 11 06

Re: Aattach an existing Excel file to an email from SAP system.  

17:57 // Greetson Shunmugasundaram

Hello Kevindass,

                            Check the below thread:-

[Upload and attach existing document using CL_DOCUMENT_BCS Upload and attach existing document using CL_DOCUMENT_BCS]

Hope this helps.

Thanks,

Greetson

00

 

 
Aug 11 09

Re: Aattach an existing Excel file to an email from SAP system.  

24:41 // Sindhuja Ravi

Hi,

you can get a formatted excel attachemnt using cl_bcs_convert=>string_to_solix

U need to pass the Line heading in the first time of the loop ,

from the next cycle of the loop , u need to take the values for the flds in order and concatenate and pass to the method mentioned above .

And remember the codepage to be given for the case of Excel is '4103'.

Like eg ,

Step 1: For header line =>

as ,

CONCATENATE

lv_string

'col1' cl_bcs_convert=>gc_tab "table value

'col2' cl_bcs_convert=>gc_tab "table value

cl_bcs_convert=>gc_crlf "to go to next line

INTO lv_string.

Step 2 : Now pass this to class cl_bcs_convert=>string_to_solix

as,

CALL METHOD cl_bcs_convert=>string_to_solix

EXPORTING

iv_string = lv_string

iv_codepage = '4103'

iv_add_bom = 'X'

IMPORTING

et_solix = l_content "excel content

ev_size = l_size.

CATCH cx_bcs .

ENDTRY.

Step 3 : loop the internal value to pass the values for all the 3 cols, concatenate in the same manner and pass to the above mentioned method for excel conversion.

Then , u can attach the excel content in the mail ( l_content) using

l_document->add_attachment(

              i_attachment_type    = 'XLS'             

              i_attachment_subject =  'Subject'

              i_att_content_hex    = l_content ).

Thanks,

Sindhuja

Aug 11 10

Re: Aattach an existing Excel file to an email from SAP system.  

14:59 // shahid mohammed syed

*  Local Data declarations   DATA: ls_rec          TYPE somlreci1.   DATA: lp_send_request    TYPE REF TO cl_bcs,         lp_document        TYPE REF TO CL_DOCUMENT_BCS         lp_sender          TYPE REF TO if_sender_bcs,         lp_recipient       TYPE REF TO if_recipient_bcs,         lp_bcs_exception   TYPE REF TO cx_bcs.   DATA: lt_text TYPE soli_tab,         ls_text LIKE LINE OF lt_text,         lv_flag.   DATA: lt_tline TYPE TABLE OF tline.   DATA lv_receiver TYPE ad_smtpadr. *  DATA lt_attach  TYPE soli_tab.   DATA ls_tline TYPE tline.   TRY. *   create persistent send request       lp_send_request = cl_bcs=>create_persistent( ). * Get the text       IF iv_stxt IS NOT INITIAL.         CALL METHOD zfi_flexgl_common=>read_text           EXPORTING             iv_stxt   = iv_stxt           IMPORTING             et_tline  = lt_tline             ev_failed = ev_failed.         LOOP AT lt_tline INTO ls_tline.           APPEND ls_tline-tdline TO lt_text.         ENDLOOP.       ENDIF. *  create and set document *     create document from internal table with text       lp_document = cl_document_bcs=>create_document(                       i_type    = iv_format_type   "'XLS' "HTM'                       i_text    = lt_text                       i_subject = iv_msg_subj ).       IF it_attach IS NOT INITIAL. * Add attachment *        DATA:      l_size      TYPE sood-objlen,              " Size of Attachment *                   l_lines     TYPE i.                        " Lines count * *        l_lines = LINES( it_attach ). *        l_size = l_lines * 255.         CALL METHOD lp_document->add_attachment           EXPORTING             i_attachment_type    = 'RAW'             i_attachment_subject = 'My attachment' *            i_attachment_size    = l_size             i_att_content_text   = it_attach.       ENDIF. *     add document to send request       CALL METHOD lp_send_request->set_document( lp_document ). * Sender addess *l_sender = cl_sapuser_bcs=>create( sy-uname ). *call method l_send_request->set_sender *  exporting *    i_sender = l_sender.  *      LOOP AT it_rec INTO ls_rec.       lv_receiver = iv_rec.       TRY.           CALL METHOD cl_cam_address_bcs=>create_internet_address             EXPORTING               i_address_string = lv_receiver             RECEIVING               result           = lp_recipient.         CATCH cx_address_bcs .       ENDTRY.       CALL METHOD lp_send_request->add_recipient         EXPORTING           i_recipient  = lp_recipient           i_blind_copy = abap_true           i_express    = abap_true. *      ENDLOOP.       IF sy-subrc <> 0.         ev_failed = abap_true.         EXIT.       ENDIF. *     ---------- send document ---------------------------------------       CALL METHOD lp_send_request->send(         RECEIVING           result              = lv_flag ).     CATCH cx_send_req_bcs.       ev_failed = abap_true.     CATCH cx_document_bcs.       ev_failed = abap_true.   ENDTRY.   IF iv_commit = abap_true.     COMMIT WORK.   ENDIF.
Date Views Headline Answers
23.01.2013 173 abap2xlsx output as mail attachment 7
21.01.2013 111 How to send a mail with XLS attachment using class with subject line > 255. 4
11.01.2013 124 E-Mail Attachment is missing 7
11.01.2013 19 E-Mail Attachment is missing 1
08.01.2013 33 How to send mail with .xlsx/.docu/.txt/.pdf/.doc/.xls docuemnts 1
04.01.2013 79 Variable Column Length of XLS Doc Using Class CL_BCS and CL_DOCUMENT_BCS. 3
07.12.2012 88 Missing line feeds in mail using SO10 standard text converted to ASCII 5

Feedback