Hello Peter,
David is correct.
In addition, you have
1) to prevent emailing by the system from processing:
set the field LVS_ITCPO-TDGETOTF = 'X'. before open form and retrieve otf data in close form.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = I_ITCPP
TABLES
OTFDATA = OTF_DATA
EXCEPTIONS
OTHERS = 1.
2) Then you have to convert the otf to pdf an create a send request for the spool.
FORM CONVERT_OTF_TO_PDF
TABLES LT_OTFDATA STRUCTURE ITCOO.
LT_LINES STRUCTURETLINE,
DATA: LV_OTF_MEMORY_SWITCH TYPE BOOLEAN,
LT_OTF TYPE TABLE OF ITCOO,
LV_BINFILESIZE TYPE I,
LV_BIN_FILE TYPE XSTRING,
LV_PDF TYPE FPCONTENT.
* convert to otf
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = LV_BINFILESIZE
BIN_FILE = LV_BIN_FILE
TABLES
OTF = LT_OTFDATA
LINES = LT_LINES
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
RETCODE = SY-SUBRC.
SYST-MSGTY = 'E'.
PERFORM PROTOCOL_UPDATE.
EXIT.
ENDIF.
.ENDFORM.
3) Then you have to create an own send document. (i would also use CL_BCS). (If you create the spool as PDF attachment, you can also use an individual body text for the email.)
4) Then you can attach the document from the GOS.
But you have to do this in the printing program itself, so you have to modify or copy RFACIN01
Regards
-Jürgen-
some snippets for sending with BCS
TRY.
LO_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
...
With a text as mail body text
LO_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'RAW' "
I_TEXT = LI_MAILBODY
I_SUBJECT = LW_SUBJECT ).
With an HTML as mail body
LO_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'HTM'"'RAW' " cf. RAW, DOC
I_TEXT = LI_MAILBODY
I_SUBJECT = LW_SUBJECT ).
add pdf attachment
CALL METHOD LO_DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE = 'PDF'
I_ATTACHMENT_SUBJECT = LW_FILENAME
I_ATT_CONTENT_HEX = LI_PDF_CONTENT.
* add document to send request
LO_SEND_REQUEST->SET_DOCUMENT( LO_DOCUMENT ).
* add recipient (e-mail address)
LO_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
I_ADDRESS_STRING = LW_EMAILADDR ).
* add recipient to send request
LO_SEND_REQUEST->ADD_RECIPIENT( I_RECIPIENT = LO_RECIPIENT ).
....
* ---------- send document ---------------------------------------
LW_SENT_TO_ALL = LO_SEND_REQUEST->SEND(
I_WITH_ERROR_SCREEN = 'X' ).
IF LW_SENT_TO_ALL = 'X'.
* add here a success message
ENDIF.
... catch errors
CATCH CX_BCS INTO LO_BCS_EXCEPTION.
MESSAGE E019(MS) "with LO_BCS_EXCEPTION->ERROR_TYPE
RAISING SEND_ERROR.
* Sending fax/mail failed
EXIT.
ENDTRY.
see also