14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Enhancing Custom Reports with ABAP2XLSX 11.2

* Fill a table with any attachments the email you have,

* which in this case is only one, the spreadsheet

ld_filelen = ld_bytecount.

DATA lt_att_head TYPE soli_tab.

DATA lv_text_line TYPE soli.

CONCATENATE '&SO_FILENAME=' id_attachment_subject

INTO lv_text_line.

APPEND lv_text_line TO lt_att_head.

lo_document->add_attachment(

i_attachment_type = 'EXT' "#EC NOTEXT

i_attachment_subject = id_attachment_subject

i_attachment_size = ld_filelen

i_att_content_hex = lt_file_tab

i_attachment_header = lt_att_head ).

* Separation of concerns – the document class’s job is to be a

* document. The send request class is concerned with sending things

lo_send_request->set_document( lo_document ).

* You have a table of email addresses. Usually for multiple people

* you would define a distribution list

LOOP AT it_email_addresses INTO ld_email.

* Email recipients are objects too, everything is an object

lo_recipient =

cl_cam_address_bcs=>create_internet_address( ld_email ).

* One more object for the send request

lo_send_request->add_recipient( lo_recipient ).

ENDLOOP.”Email addresses

* The actual send method has a return parameter that is blank if

* the send fails

lf_sent_to_all =

lo_send_request->send( i_with_error_screen = 'X' ).

COMMIT WORK.

IF lf_sent_to_all IS INITIAL.

"Document not sent to &1

MESSAGE i500(sbcoms) WITH ld_email

ELSE.

MESSAGE s022(so). "Document sent

"kick off the send job so the email goes out immediately

WAIT UP TO 2 SECONDS. "ensure the mail has been queued

SUBMIT rsconn01

WITH mode = '*' "process everything you find.

WITH output = ' '

495

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!