2005 Dec 16 11:39 AM
Hi all,
I need to send a sapscript via email.
I convert the spool in pdf.
If I try to download the internal table with pdf content I'm able to create correctly the pdf file on my pc.
Insted, if I send the contet of internal table with the pdf data via email, an error occured when I try to open the attached pdf file.
regards
enzo
2005 Dec 16 12:44 PM
Hi Enzo,
1. There can be many possible causes for it.
2. a) Checkout the SCOT settings
(basis team may help u out)
b) In ur pgoram code,
mention attachment type as 'PDF'
instead of 'BIN'.
I Hope it helps.
Regards,
Amit M.
2005 Dec 16 12:33 PM
Hi,
This below code may help you in case:
DATA WA_OBJBIN LIKE SOLISTI1.
DESCRIBE TABLE OBJTXT LINES PDFLINES.
*-- A funtion module to convert otf to pdf format
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
FORMAT_SRC = 'OTF'
FORMAT_DST = 'PDF'
DEVTYPE = 'PRINTER'
FUNCPARA =
LEN_IN = PDFLINES
IMPORTING
LEN_OUT = PDFLINES
TABLES
CONTENT_IN = OBJTXT
CONTENT_OUT = OBJBIN
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.
DESCRIBE TABLE OBJBIN LINES PDFLINES.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
*-- a perform to do the email
*-- creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
*-- creation of the entry for the attachment
CLEAR OBJPACK.
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = PDFLINES.
objpack-objname =
OBJPACK-OBJ_DESCR = '%PDF-FILE.PDF'.
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-DOC_SIZE = PDFLINES * 255.
APPEND OBJPACK.
*-- populating the t_receivers with mail address
READ TABLE t_adr6 INDEX 1.
IF NOT T_ADR6[] IS INITIAL.
LOOP AT T_ADR6.
T_RECEIVERS-RECEIVER = T_ADR6-SMTP_ADDR.
T_RECEIVERS-REC_TYPE = 'U'.
APPEND T_RECEIVERS.
CLEAR T_RECEIVERS.
ENDLOOP.
ENDIF.
*-- Calling a function module to send an E-mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_DATA
PUT_IN_OUTBOX = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
contents_hex = objbin
OBJECT_PARA =
OBJECT_PARB =
RECEIVERS = T_RECEIVERS
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
.
It may help you.
try to rectify the mistake that you have in your program by checking this sample code....
2005 Dec 16 12:44 PM
Hi Enzo,
1. There can be many possible causes for it.
2. a) Checkout the SCOT settings
(basis team may help u out)
b) In ur pgoram code,
mention attachment type as 'PDF'
instead of 'BIN'.
I Hope it helps.
Regards,
Amit M.
2005 Dec 16 1:55 PM
Hi all,
I'm using the PDF type.
More, I have opened the 2 pdf file on my pc:
one downloaded with download FM,
one downloaded from the email.
The first one opens normaly, the other no.
I try to open they with a notepad.
I have seen that in the attached file missing some rows (many, eg. the line with EOF) that are present in the file downloaded with FM.
Does it suggest nothing to anyone?
Bye
enzo
2005 Dec 16 2:00 PM
How can you open a Pdf file with Notepad.
i don't know,
check out some problem lies in mail attachment...
regards
vijay
2005 Dec 16 2:04 PM
Hi Enzo,
You can also try this.. it is a Table entry but this is usually done by BASIS..
TABLE: SXSERV
KEY: NODE = INTIMAL, ADDR_TYPE = INT
change the fields CONVERT_S, CONVERT_L, CONVERT_O, and CONVERT_T to 'PDF'.
Regards,
Suresh Datti
2005 Dec 16 2:04 PM
I open the pdf with a program named ConText is an simple text editor.
2005 Dec 16 2:10 PM
Hi Suresh,
I saw the table SXSERV, but there aren't the fields you said to change?
2005 Dec 16 2:59 PM
Hi Enzo,
What version are you on? I am on 47 and used this very table to fix our PDF email issue..
Regards,
Suresh Datti
2005 Dec 19 11:09 AM
2005 Dec 16 2:12 PM
Hi,
Once you are ready with pdf data in an internal table try to use the following code:
count the number of lines in an internal table and store them in tab_lines
CLEAR objpack-transf_bin.
objpack-transf_bin = 'X'.
objpack-head_start = 0.
objpack-head_num = 0.
objpack-body_start = 0.
objpack-body_num = tab_lines.
objpack-doc_type = 'pdf'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
CLEAR objpack.
objbin: contains the attachment contents
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
contents_txt = objtxt
contents_bin = objbin
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc = 0.
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
ENDIF.
Try to give app. points if it helps your requirement.
Regards,
Suman