Hello Expert,
The program convert Smartform as PDF format in email attachment.
I copied the same code from 4.6C non-unicode system to ECC5.0 unicode system, but PDF attachment can not be opened by Adobe Reader 8.0 with the message 'There is an error opening this document.The file is damaged and could not be repaired.'.
Making user can input email receiver manually, use FM 'SO_DYNP_DOCUMENT_TRANSFER_API1'.
Here is the source code.
DATA: lsDocumentData TYPE SODOCCHGI1,
lsSize TYPE I,
ltPDFData TYPE STANDARD TABLE OF TLINE,
ltDocContent TYPE STANDARD TABLE OF SOLISTI1,
ltPDFData LIKE tline OCCURS 0 WITH HEADER LINE,
ltDocContent LIKE soli OCCURS 0 WITH HEADER LINE.
Convert otf data into pdf data
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 134
IMPORTING
BIN_FILESIZE = lsSize
TABLES
OTF = OUTPUT_INFO-OTFDATA
LINES = ltPDFData
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 2
OTHERS = 3.
Change table format from TLINE -> SOLISTI1
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
LINE_WIDTH_SRC = 134
LINE_WIDTH_DST = 255
TABLES
CONTENT_IN = ltPDFData
CONTENT_OUT = ltDocContent
EXCEPTIONS
ERR_LINE_WIDTH_SRC_TOO_LONG = 1
ERR_LINE_WIDTH_DST_TOO_LONG = 2
ERR_CONV_FAILED = 3
OTHERS = 4.
Create new email - Go to email edition screen
lsDocumentData-obj_name = 'PDF'.
lsDocumentData-obj_descr = sy-title.
lsDocumentData-obj_langu = sy-langu.
lsDocumentData-doc_size = lsSize.
CALL FUNCTION 'SO_DYNP_DOCUMENT_TRANSFER_API1'
EXPORTING
DOCUMENT_DATA = lsDocumentData
DOCUMENT_TYPE = 'PDF'
METHOD = 'SNDA'
TABLES
OBJECT_CONTENT = ltDocContent
EXCEPTIONS
DOCUMENT_TYPE_NOT_EXIST = 1
OPERATION_NO_AUTHORIZATION = 2
PARAMETER_ERROR = 3
X_ERROR = 4
DOCUMENT_NOT_SENT = 5
OTHERS = 6.
Your help will be highly appreciated.
Regards,
Wei