2007 May 01 2:49 PM
Hi Friends,
I need expertise help in pdf email attachment. I have data in internal table which has to be sent as pdf mail attachment. I need help in converting the data to pdf format. After conversion I can use SO_NEW_DOCUMENT_ATT_SEND_API1 to send the mail.
Expect earliest reply.
Thanks,
Nidhya
thanks nilesh ,
you had given me solution in just one line thanks again .
2007 May 01 2:56 PM
DATA : LEN_OUT LIKE SOOD-OBJLEN.
OTFDATA LIKE ITCOO OCCURS 0 WITH HEADER LINE,
CONTENT_OUT LIKE TLINE OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 134
IMPORTING
BIN_FILESIZE = LEN_OUT
TABLES
OTF = OTFDATA
LINES = CONTENT_OUT
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
2007 May 01 3:08 PM
Check the program RSTXPDFT4 to see how the data is formatted as per pdf requirements in the perform download_w_ext(RSTXPDFT).
Regards,
Ravi
2007 May 01 3:22 PM
Hi,
email to SAP Inbox
Send mail to User's SAP Inbox also
RECLIST-RECEIVER = IT_ZMMTACCUID-ACCTUSRID.
RECLIST-REC_TYPE = 'B'.
APPEND RECLIST.
CLEAR RECLIST.
SEND THE DOCUMENT BY CALLING THE SAPOFFICE API1 MODULE FOR SENDING
DOCUMENTS WITH ATTACHMENTS
************************************************************************
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
IMPORTING
SENT_TO_ALL = SENT_TO_ALL
NEW_OBJECT_ID =
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
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.
following options are available for field
RECLIST-REC_TYPE
Name
P Private distribution list
C Shared distribution list
O SAPoffice user
B SAP user
U Internet address
X X.400 address
R SAP user in another SAP System
A External address
F Fax number
D X.500 Address
L Telex number
H Organizational unit/position
J SAP object
G Organization object/ID
Regards
Amole
2007 May 01 5:18 PM
DATA DECLERATION FOR PDF CONVERT AND SENDING EMAIL
I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE.
************************************************************************
CONVERT PDF FORMAT
************************************************************************
CLEAR: I_OTF,
I_TLINE.
I_OTF[] = WA_RETURN-OTFDATA[].
call function 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = V_LEN_IN
TABLES
otf = I_OTF
lines = I_TLINE
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
others = 4.
if sy-subrc <> 0.
endif.
************************************************************************
CONVERT PDF TO BIN FORMAT
************************************************************************
DESCRIBE TABLE I_TLINE LINES V_LINES_BIN.
DESCRIBE FIELD I_TLINE LENGTH FLE1.
DESCRIBE FIELD I_OBJCONT LENGTH FLE2.
CLEAR I_OBJCONT[].
CALL FUNCTION 'QCE1_CONVERT'
TABLES
T_SOURCE_TAB = I_TLINE
T_TARGET_TAB = I_OBJCONT
EXCEPTIONS
CONVERT_NOT_POSSIBLE = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
The output of the above function module you can send to SO_NEW_DOCUMENT_ATT_SEND_API1 function module.
Actually you cann't send the PDF file directly from SAP you have to convert it to the binary format and then you can send from SAP.
2009 Feb 12 3:11 PM
thanks nilesh ,
you had given me solution in just one line thanks again .
2012 Sep 19 4:54 PM
I had a problem to view the attachments created by my program in SOST.
I was doing a manual conversion and was sure the output device was the problem. By modifying output device the error message when opening the pdf kept changing: "A number is out of range", "There was an error in processing a page. There was a problem reading this document (135)." and so on.. and sometimes i even got bits of the document.
With little QCE1_CONVERT all is peachy!
Thanks Nilesh!!
2007 May 02 3:50 AM
Dear Friends,
Thanks for your reply, but I need help in converting the data in internal table to pdf.
Pls find my code below: With this code, I get email send with PDF attach, but the data inside the file is not in correct format.
Pls help me to correct.
DATA : mailrec LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
mailbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
mailbin1 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
mailtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
mailhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_otf LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_pdf LIKE solisti1 OCCURS 0 WITH HEADER LINE,
mailstruc LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
maildata LIKE sodocchgi1 OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF i_sotf OCCURS 0.
INCLUDE STRUCTURE itcoo.
DATA : END OF i_sotf.
DATA : i_itcpo LIKE itcpo,
i_itcpp LIKE itcpp.
DATA : v_tlines TYPE i,
v_len_in LIKE sood-objlen,
v_len_out LIKE sood-objlen.
maildata-obj_name = 'Document'.
maildata-obj_descr = 'Transfer Details'.
maildata-obj_prio = 1.
maildata-doc_size = strlen( mailtxt ).
mailstruc-head_start = 1.
mailstruc-head_num = 0.
mailstruc-body_start = 1.
mailstruc-body_num = 1.
mailstruc-obj_name = 'transfer'.
mailstruc-doc_type = 'RAW'.
APPEND mailstruc.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
APPEND mailrec.
CLEAR i_itcpo.
i_itcpo-tdgetotf = 'X'.
REFRESH mailbin.CLEAR mailbin.
WRITE 'Report Title:' TO mailbin-line+3.
WRITE sy-repid TO mailbin-line+18.
APPEND mailbin. CLEAR mailbin.
WRITE 'User : ' TO mailbin-line.
WRITE sy-uname TO mailbin-line+11.
APPEND mailbin. CLEAR mailbin.
WRITE 'Date of Report : ' TO mailbin-line+3.
WRITE sy-datum USING EDIT MASK mask MM/DD/YYYY TO mailbin-line+21.
APPEND mailbin. CLEAR mailbin.
WRITE 'Time of Report : ' TO mailbin-line+3.
WRITE sy-uzeit TO mailbin-line+21.
APPEND mailbin. CLEAR mailbin.
APPEND mailbin.
WRITE 'Transfer ' to mailbin-line+3.
APPEND mailbin. CLEAR mailbin.
APPEND mailbin.
WRITE sy-uline TO mailbin-line+3.
APPEND mailbin. CLEAR mailbin.
LOOP AT i_disp.
SHIFT i_disp-index LEFT DELETING LEADING '0'.
WRITE i_disp-index TO mailbin+3.
WRITE i_disp-pernr TO mailbin+6.
WRITE i_disp-ename TO mailbin+16.
WRITE i_disp-persk TO mailbin+57.
WRITE i_disp-btrtl TO mailbin+60.
APPEND mailbin. CLEAR mailbin.
ENDLOOP.
CALL FUNCTION 'SX_OBJECT_CONVERT_SCR_OTF'
EXPORTING
FORMAT_SRC = 'RAW'
FORMAT_DST = 'OTF'
DEVTYPE = 'POSTSCPT'
FUNCPARA = ''
LEN_IN = v_len_in
IMPORTING
LEN_OUT = v_len_out
TABLES
CONTENT_IN = mailbin
CONTENT_OUT = mailbin1
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH mailbin.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
FORMAT_SRC = 'OTF'
FORMAT_DST = 'PDF'
DEVTYPE = 'POSTSCPT'
FUNCPARA =
LEN_IN = v_len_in
IMPORTING
LEN_OUT = v_len_out
TABLES
CONTENT_IN = mailbin1
CONTENT_OUT = mailbin
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH mailbin1.
DESCRIBE TABLE mailbin LINES v_tlines.
mailstruc-head_start = 1.
mailstruc-head_num = 0.
mailstruc-body_start = 1.
mailstruc-body_num = v_tlines.
mailstruc-transf_bin = 'X'.
mailstruc-doc_type = 'PDF'.
mailstruc-obj_name = 'Mid-month transfer'.
mailstruc-doc_size = v_tlines * 255.
APPEND mailstruc.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = maildata
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = mailstruc
OBJECT_HEADER = mailhead
CONTENTS_BIN = mailbin
RECEIVERS = mailrec
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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
But i dont get the result in expected format. I am not getting first 2 characers of the line. instead of report, date, time in separate line I get everything in a single line as follows :
Report Title: ZHRPY0003
er : VACNIDHYA Date of Report : 02.05.2007 Time of Report
: 10:31:27 Mid-month Inter-Company Transfer
-
-
--- 1 00002609 Carla Pineda FT
2010
- 1 -
2012 Sep 19 11:05 PM
Hi,
search for CL_BCS & PDF &CL_CONV.
Forget about buggy unsupported SO_NEW_DOCUMENT_ATT_SEND_API1,
Regards
Clemens
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |