2011 Nov 04 4:32 PM
Hello people!
I have a problem in a SmartForms purchase order, the conversion to PDF and in sequence, sending it by e-mail.
When the parameter "job_output_info" returns the form, the OTF table "otfdata" is coming with some strange characters, Chinese characters appear.
So, I'm not getting to the correct treatment to attach the PDF to send the email.
comments:
There is no error displayed and e-mail is sent normally. However, when trying to open PDF attached is the message "There was an error opening this document. The file is damaged and can not be restored.".
Downloading the file, it opens normally.
I'm using the "CONVERT_OTF," but I believe the problem is before this function, since, as I said earlier, the function returns the SmartForms with Chinese characters.
I believe it should have some notes or configuration to solve this problem ...
Has anyone experienced this?
Can you help me please??
Best Reguards,
Thank you!
Raquel
2011 Nov 04 4:39 PM
Hello Raquel,
Have you, by any chance, searched the forum first? This sounds like a familiar problem.
I did a quick search and found several threads related to this problem.
Micky.
2011 Nov 07 12:25 PM
Hello Micky,
Yes, I have researched enough about the problem and used the suggestions of the forums to try to solve my problem, but it still fails.
Thank you,
Raquel
2011 Nov 07 12:35 PM
Hi,
Please use CONVERT_OTF_2_PDF and use the output PDF internal table and attach it in the email. You can use the attachment type as PDF while sending the email. This should resolve the issue.
Thanks
Senthil
2011 Nov 07 1:25 PM
Hello Senthil,
I have also tried to use this FM, exactly this way. The file is sent with an attachment but when trying to open the file the same error occurs ...
Do you know if there is a note regarding the Smartfotms, PDF, ...?
Thank you very much!
Raquel
2011 Nov 07 1:38 PM
Hi,
Do you have a spool that you want to convert into PDF?? If yes, please try CONVERT_OTFSPOOLJOB_2_PDF this FM as in this you can give the Spool number and directly it gives it as pdf.
Thanks
senthil
2011 Nov 07 1:59 PM
Hi ,
FORM SENT_MAIL1 .
DATA:IT_NFAL TYPE NFAL OCCURS 0 WITH HEADER LINE.
DATA:FM_NAME TYPE RS38L_FNAM.
DATA:IT_OTF_FINAL TYPE ITCOO OCCURS 0 WITH HEADER LINE.
DATA:BIN_FILESIZE TYPE I.
DATA:IT_PDFDATA TYPE TABLE OF TLINE.
DATA:IT_PDF TYPE TABLE OF SOLISTI1.
*--------------------------------------------------------*
" Mail related declarations
*--------------------------------------------------------*
"Variables
DATA :
G_SENT_TO_ALL TYPE SONV-FLAG,
G_TAB_LINES TYPE I.
"Types
TYPES:
T_DOCUMENT_DATA TYPE SODOCCHGI1,
T_PACKING_LIST TYPE SOPCKLSTI1,
T_ATTACHMENT TYPE SOLISTI1,
T_BODY_MSG TYPE SOLISTI1,
T_RECEIVERS TYPE SOMLRECI1,
T_PDF TYPE TLINE.
"Workareas
DATA :
W_DOCUMENT_DATA TYPE T_DOCUMENT_DATA,
W_PACKING_LIST TYPE T_PACKING_LIST,
W_ATTACHMENT TYPE T_ATTACHMENT,
W_BODY_MSG TYPE T_BODY_MSG,
W_RECEIVERS TYPE T_RECEIVERS,
W_PDF TYPE T_PDF.
"Internal Tables
DATA :
I_DOCUMENT_DATA TYPE STANDARD TABLE OF T_DOCUMENT_DATA,
I_PACKING_LIST TYPE STANDARD TABLE OF T_PACKING_LIST,
I_ATTACHMENT TYPE STANDARD TABLE OF T_ATTACHMENT,
I_BODY_MSG TYPE STANDARD TABLE OF T_BODY_MSG,
I_RECEIVERS TYPE STANDARD TABLE OF T_RECEIVERS,
I_PDF TYPE STANDARD TABLE OF T_PDF.
SSFCTRLOP-NO_DIALOG = 'X'.
SSFCTRLOP-PREVIEW = 'X'.
SSFCTRLOP-GETOTF = 'X'.
SSFCOMPOP-TDDEST = 'LP01'.
************appending the otf data into the final table**********************
IT_OTF_FINAL[] = IT_OTF_DATA-OTFDATA[].
************ converting OTF data into pdf data**************************
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = BIN_FILESIZE
* bin_file =
TABLES
OTF = IT_OTF_FINAL
LINES = IT_PDFDATA[]
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
Edited by: praveenreddys on Nov 7, 2011 7:30 PM
2011 Nov 07 2:02 PM
contiue
* To send data as email attachment, we need to have a table of SOLISTI1.
* This table contains line size of 255 characters. Below function module
* does the trick of changing the table from X character sized lines into
* any given Y character sized lines.
REFRESH IT_PDF[].
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
LINE_WIDTH_DST = '255'
TABLES
CONTENT_IN = IT_PDFDATA[]
CONTENT_OUT = IT_PDF[]
EXCEPTIONS
ERR_LINE_WIDTH_SRC_TOO_LONG = 1
ERR_LINE_WIDTH_DST_TOO_LONG = 2
ERR_CONV_FAILED = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
"Subject of the mail.
W_DOCUMENT_DATA-OBJ_NAME = 'MAIL_TO_HEAD'.
CONCATENATE 'Payslip for the month' '-' P_MONTH INTO W_DOCUMENT_DATA-OBJ_DESCR.
* w_document_data-obj_descr = 'Regarding Mail Program by SAP ABAP'.
"Body of the mail
* W_BODY_MSG = 'This is body of mail msg.'.
* APPEND W_BODY_MSG TO I_BODY_MSG.
* CLEAR W_BODY_MSG.
CONCATENATE 'Dear ' WA-EMP_NAME ',' INTO W_BODY_MSG.
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
*
*
W_BODY_MSG = 'Please find the Payslip in the attachment'(018).
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
*
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
*
W_BODY_MSG = 'Regards'.
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
*
W_BODY_MSG = 'HR & Adminstration Department'.
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
**
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
*
W_BODY_MSG = 'This is an auto-generated message, please do not reply to this message.'.
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
*
CONCATENATE 'In case any clarification is needed,'
' please contact the HR & Administration Department'
INTO W_BODY_MSG.
APPEND W_BODY_MSG TO I_BODY_MSG.
CLEAR: W_BODY_MSG.
"Write Packing List for Body
DESCRIBE TABLE I_BODY_MSG LINES G_TAB_LINES.
W_PACKING_LIST-HEAD_START = 1.
W_PACKING_LIST-HEAD_NUM = 0.
W_PACKING_LIST-BODY_START = 1.
W_PACKING_LIST-BODY_NUM = G_TAB_LINES.
W_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND W_PACKING_LIST TO I_PACKING_LIST.
CLEAR W_PACKING_LIST.
"Write Packing List for Attachment
W_PACKING_LIST-TRANSF_BIN = 'X'.
W_PACKING_LIST-HEAD_START = 1.
W_PACKING_LIST-HEAD_NUM = 1.
W_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_PDF LINES W_PACKING_LIST-BODY_NUM.
W_PACKING_LIST-DOC_TYPE = 'PDF'.
W_PACKING_LIST-OBJ_DESCR = 'PDF Attachment'.
W_PACKING_LIST-OBJ_NAME = 'PDF_ATTACHMENT'.
W_PACKING_LIST-DOC_SIZE = W_PACKING_LIST-BODY_NUM * 510.
APPEND W_PACKING_LIST TO I_PACKING_LIST.
CLEAR W_PACKING_LIST.
"Fill the document data and get size of attachment
W_DOCUMENT_DATA-OBJ_LANGU = SY-LANGU.
READ TABLE IT_PDF INTO W_PDF INDEX G_TAB_LINES.
W_DOCUMENT_DATA-DOC_SIZE = ( G_TAB_LINES - 1 ) * 255 + STRLEN( W_ATTACHMENT ).
"Receivers List.
W_RECEIVERS-REC_TYPE = 'U'."Internet address
W_RECEIVERS-RECEIVER = WA-EMP_MAIL.
W_RECEIVERS-COM_TYPE = 'INT'.
* W_RECEIVERS-NOTIF_DEL = 'X'.
* W_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND W_RECEIVERS TO I_RECEIVERS .
CLEAR:W_RECEIVERS.
"Function module to send mail to Recipients
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOCUMENT_DATA
* PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = G_SENT_TO_ALL
TABLES
PACKING_LIST = I_PACKING_LIST
CONTENTS_BIN = IT_PDF
CONTENTS_TXT = I_BODY_MSG
RECEIVERS = I_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.
IF SY-SUBRC = 0 .
MESSAGE S303(ME) WITH 'Mail has been Successfully Sent.'.
ENDIF.
ENDIF.
ENDFORM. " SENT_MAIL1
Regards,
Praveen
Edited by: praveenreddys on Nov 7, 2011 7:29 PM
2011 Nov 07 2:39 PM
Hello Senthil,
I had tried this way too, using the number of spool, but the error is the same, ie, the table PDF FM 'CONVERT_OTFSPOOLJOB_2_PDF' comes with characters in Japanese / Chinese.
Thank you!
Raquel.
2011 Nov 07 2:57 PM
Hi Praveen,
This coding was my first attempt.
The following return table OUTPUT-OTFDATA:
1 // |XPDF1 0700 00000000001 <
2 IN |04PZMMPO_PED_COMPRA <
3 IN |05FIRST <
4 OP |DINA4 P 72 240 1683811906000010000100001 <
5 IN |06COMLOGO <
6 MT |0056700567 <
7 BM |0281300960 D BDS_LOC3 4E77F55F22870BA9E10080020A0100190 <
8 RD |I 66佔䙢楴浡ȁက#૽#u03C0#Ɋ#u00C8Ĭ#Ā#㿿##########################<
9 RD |I 66##########################<
10 RD |I 66퀀쀀퀀ꀀ쀀耀뀀퀀怀退쀀倀退쀀䀀耀뀀u2002瀀뀀က怀뀀##########################<
11 RD |I 66က怀ꀀ#怀ꀀ 瀀뀀瀀ꀀ퀀뀀퀀#倀ꀀ䀀耀쀀退뀀퀀뀀쀀瀀ꀀ쀀##########################<
12 RD |I 66倀耀쀀耀ꀀ퀀u2002怀뀀怀ꀀ쀀退쀀퀀퀀 耀뀀쀀ꀀ쀀퀀ꀀ뀀耀耀##########################<
13 RD |I 66ꀀꀀ怀怀ကu2002倀倀퀀퀀쀀쀀뀀뀀쀀퀀 䀀 ##########################<
Have you seen something?
Thank you!
Raquel.
2011 Nov 07 3:13 PM
Hello Raquel,
I also had some problems with smartforms sent by mail in pdf a couple of times. Please try this two things. First,if your smartform has a logo picture remove it and try to sent it with out it. I do not why but sometimes the problem are the images. If that does not help, when filling the doc size instead of doing this
W_DOCUMENT_DATA-DOC_SIZE = ( G_TAB_LINES - 1 ) * 255 + STRLEN( W_ATTACHMENT ).
change the number 255 by 254. I found a couple of references in internet suggesting this and in my case that was de solution to my problems.
Hope it helps.
Kind regards,
Jorge
2011 Nov 07 6:33 PM
Hello George, how are you?
I deleted the logo SmartForms and executed. The Chinese characters no longer appear in the return table OTF, but when using the FM 'CONVERT_OTF' LINES table comes with these Chinese characters.
The e-mail is sent normally, however, the attachment does not open.
I also tried changing the numbers from 255 to 254 and also did not solve ...
= (
Reguards,
Raquel.
2011 Nov 08 8:41 AM
Hi Raquel,
Can you please check if the output of the smartform is A4 size. Sometimes that will also cause some problem while converting it into the PDF. Please let me know.
thanks
Senthil
2011 Nov 08 12:04 PM
Hi Senthil,
Yes, the output of the smartform is A4 size..
I performed a test with the same form and program in another environment and it worked correctly.
I believe the error is corrected with some sap notes..
I'll keep searching for...
Thank you very much for your help! 😃
Raquel
2011 Nov 08 7:50 PM
Hello people,
My problem was finally resolved by applying the note 1430123.
Thank you all for your help!
Raquel.
2011 Nov 09 5:59 AM
Hi Friend,
can you please share your Solution. even i am facing the same issue.