on 11-02-2011 11:57 AM
Dear all,
I developed the Report program which will send payslip as PDF attachement to all employees.i am able to receive the mail along with Payslip as PDF Format.
but i am unable to open the PDF format.its showing error message as
"Adobe reader could not open the PDF file because it is either not a supported file or because the file has been damaged (for example it was sent as an email attachment and was not correctly decoded"
Can any one help regarding this issue
Thanks in advance.
Sudheer
Hi,
Many times it could be reason of updated version of Adobe reader.
Get installed latest version and check.
Thanks
Umakanth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Companions,
I would like to contribute on this subject which will be helpful to our SDN Society.
I have developed the program to send the standard remuneration statement thru eMail to the employees in PDF. Its working very fine and employees are very delighted owing to this facility. The code snapshot of sending mail form is as per below.
FORM send_email .
DATA : g_totrec(4) TYPE n,
g_ctr(4) TYPE n,
v_prc TYPE string.
DESCRIBE TABLE itab[] LINES g_totrec.
LOOP AT itab.
g_ctr = g_ctr + 1.
CONCATENATE g_totrec ' - ' g_ctr ' : Emp. ' itab-pernr INTO v_prc.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 100
text = v_prc.
itab-ctr = 1.
MODIFY itab TRANSPORTING ctr.
IF p_ind = 'X'.
IF itab-usrid_long IS INITIAL.
itab-mtext = 'eMail-ID Not Found'.
MODIFY itab TRANSPORTING mtext.
CLEAR:itab.
CONTINUE.
ENDIF.
ENDIF.
CLEAR:v_pdf_size,x_payslip,i_return.
CALL FUNCTION 'BAPI_GET_PAYSLIP_PDF'
EXPORTING
employeenumber = itab-pernr
sequencenumber = itab-seqnr
payslipvariant = pay_var
IMPORTING
return = i_return
payslip = x_payslip
pdf_fsize = v_pdf_size.
IF sy-subrc NE 0.
itab-mtext = 'Payslip not Generated.'.
MODIFY itab TRANSPORTING mtext.
CLEAR:itab.
CONTINUE.
ENDIF.
IF p_save = 'X'.
CLEAR:data_tab.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = x_payslip
TABLES
binary_tab = data_tab[].
CLEAR:fullpath,w_outlen.
CONCATENATE 'C:\SAP\' itab-pernr '.PDF' INTO fullpath.
DESCRIBE TABLE objhex LINES w_outlen.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = w_outlen
filename = fullpath
filetype = 'BIN'
APPEND = ' '
CODEPAGE = ' '
NO_BYTEORDER_MARK = ' '
IMPORTING
FILELENGTH = c
TABLES
data_tab = data_tab[]
FORMAT_TAB =
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6.
IF sy-subrc = 0.
itab-mtext = 'ePayslip Saved.'.
ELSE.
itab-mtext = 'ePayslip Not Saved.'.
ENDIF.
MODIFY itab TRANSPORTING mtext.
CLEAR:itab,docdata,objpack,objtxt,objtxt[],objhex,objhex[],objhex1,objhex[],objpack,objpack[].
WAIT UP TO 5 SECONDS.
CONTINUE.
ENDIF.
Convert OTF to PDF
CLEAR:x,x1,y,z,w_outlen,tab_lines,objhex1.
x = v_pdf_size / 255.
z = v_pdf_size - 255.
DO x TIMES.
IF x1 > z .
EXIT.
ENDIF.
objhex1-line = x_payslip+x1(255).
APPEND objhex1 TO objhex.
x1 = x1 + 255.
ENDDO.
y = v_pdf_size - x1 .
objhex1-line = x_payslip+x1(y).
APPEND objhex1 TO objhex.
preparing subject
CONCATENATE w_endda(6) '-Payslip-(' itab-pernr+0(8) ')- ' itab-atext ' ' itab-ename+0(35) '.' INTO docdata-obj_descr RESPECTING BLANKS.
docdata-obj_name = 'Pay Slip'.
docdata-obj_langu = sy-langu.
CONDENSE itab-atext.
CONDENSE itab-ename.
CONCATENATE ' Dear ' itab-atext ' ' itab-ename '.' INTO objtxt RESPECTING BLANKS.
objtxt = 'Pay Slip.'.
APPEND objtxt.
CLEAR:objtxt.
APPEND objtxt.
objtxt = docdata-obj_descr.
objtxt = 'Please find enclosed herewith your Payslip in PDF format.'.
APPEND objtxt.
CLEAR:objtxt.
APPEND objtxt.
objtxt = 'Have a nice day.'.
APPEND objtxt.
CLEAR:tab_lines.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines TRANSPORTING ALL FIELDS.
Write Packing List (Main)
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
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'.
APPEND objpack.
pack to pdf.
CLEAR:w_outlen.
DESCRIBE TABLE objhex LINES w_outlen.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = w_outlen.
objpack-doc_type = 'PDF'.
objpack-obj_name = 'ATTACHMENT'.
objpack-doc_size = v_pdf_size.
CONCATENATE itab-pernr '.PDF' INTO objpack-obj_descr.
objpack-obj_descr = 'payslip.pdf'.
APPEND objpack.
Create receiver list
REFRESH reclist.
CLEAR reclist.
IF p_adm = 'X'.
reclist-receiver = admailid.
TRANSLATE reclist-receiver TO LOWER CASE.
itab-usrid_long = reclist-receiver.
reclist-rec_type = 'U'.
APPEND reclist.
ELSEIF p_ind = 'X'.
reclist-receiver = itab-usrid_long.
TRANSLATE reclist-receiver TO LOWER CASE.
itab-usrid_long = reclist-receiver.
reclist-rec_type = 'U'.
APPEND reclist.
ENDIF.
Send the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = ''
commit_work = 'X'
TABLES
packing_list = objpack
contents_txt = objtxt
contents_hex = objhex
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.
IF sy-subrc NE 0.
itab-mtext = 'eMail Not Sent.'.
ELSE.
itab-mtext = 'eMail Sent.'.
ENDIF.
MODIFY itab TRANSPORTING mtext.
WAIT UP TO 5 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN. "This causes all the objects in SOST to be released.
CLEAR:itab,docdata,objpack,objpack[],objtxt,objtxt[],objhex,objhex[].
ENDLOOP. "end loop at ITAB
ENDFORM. " SEND_EMAIL
*********************************************************************
Regards,
R R Suthar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I think decoding is failed.. Check this
http://wiki.sdn.sap.com/wiki/display/Snippets/ADOBE-PrintformDownloadMailpdf
This will help u...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys,
Still i am facing problem while opening the PDF Document.
I developed the program to send Payslip as PDF format. i am getting error while opening the PDF file as
""Adobe reader could not open the PDF file because it is either not a supported file or because the file has been damaged (for example it was sent as an email attachment and was not correctly decoded"
i written code like this
CALL FUNCTION 'BAPI_GET_PAYSLIP'
EXPORTING
employeenumber = wa_pernr-pernr
sequencenumber = wa_pernr-seqnr
payslipvariant = 'ZP1Y'
IMPORTING
RETURN =
TABLES
payslip = i_payslip
.
**Get Payslip PDf
CALL FUNCTION 'BAPI_GET_PAYSLIP_PDF'
EXPORTING
employeenumber = wa_pernr-pernr
sequencenumber = wa_pernr-seqnr
payslipvariant = 'ZP1Y'
IMPORTING
return =
payslip = payslip
pdf_fsize = pdf_size.
IF sy-subrc EQ 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
i_otf[] = i_payslip[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
BIN_FILE =
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**************************************
**Convert PDF to OTF
x = pdf_size / 255.
z = pdf_size - 255.
DO x TIMES.
IF x1 > z .
EXIT.
ENDIF.
objhex1-line = payslip+x1(255).
objhex1-line = payslip+x1.
APPEND objhex1 TO objhex.
objbin1-line = v_buffer+x1(255).
objbin1-line = v_buffer + x1.
APPEND objbin1 TO objbin.
x1 = x1 + 255.
ENDDO.
y = pdf_size - x1 .
objbin1-line = v_buffer + z(y).
APPEND objbin1 TO objbin.
objhex1-line = payslip+x1(y) .
APPEND objhex1 TO objhex.
DESCRIBE TABLE objhex LINES mail_attachment_lines.
mail_attachment_lines = mail_attachment_lines * 255.
READ TABLE objhex INTO objhex1 INDEX mail_attachment_lines.
doc_chng-obj_name = 'PAYSLIP'.
CONCATENATE 'PAYSLIP FOR' mname INTO doc_chng-obj_descr SEPARATED BY space .
doc_chng-doc_size = ( mail_attachment_lines - 1 ) * 255 + 255.
objtxt1-line = 'Dear Sir / Madam,'.
CASE wa_pernr-anred.
WHEN 1.
CONCATENATE 'Dear' 'Mr.' wa_pernr-vorna wa_pernr-nachn INTO objtxt1-line SEPARATED BY ' '.
WHEN 2.
CONCATENATE 'Dear' 'Ms.' wa_pernr-vorna wa_pernr-nachn INTO objtxt1-line SEPARATED BY ' '.
WHEN 3.
CONCATENATE 'Dear' 'Dr.' wa_pernr-vorna wa_pernr-nachn INTO objtxt1-line SEPARATED BY ' '.
WHEN OTHERS.
CONCATENATE 'Dear' wa_pernr-vorna wa_pernr-nachn INTO objtxt1-line SEPARATED BY ' '.
ENDCASE.
CONCATENATE 'Dear' wa_pernr-ename INTO objtxt1-line SEPARATED BY space.
APPEND objtxt1 TO objtxt.
CLEAR objtxt1.
APPEND objtxt1 TO objtxt.
CONCATENATE 'Please find attached payslip for' mname INTO objtxt1-line SEPARATED BY space.
APPEND objtxt1 TO objtxt.
CLEAR objtxt1.
APPEND objtxt1 TO objtxt.
CONCATENATE 'SAP System generated statement (on'l_date 'At' l_time 'IST) enclosed which
does not REQUIRE SIGNATURE.' INTO objtxt1-line SEPARATED BY space.
objtxt1-line = 'Regards,'.
APPEND objtxt1 TO objtxt.
CLEAR objtxt1.
objtxt1-line = 'TEAM HR.'.
APPEND objtxt1 TO objtxt.
CLEAR objtxt1.
DESCRIBE TABLE objtxt LINES lv_tablines.
READ TABLE objtxt INTO objtxt1 INDEX lv_tablines TRANSPORTING ALL FIELDS.
doc_chng-doc_size = ( lv_tablines - 1 ) * 255 + STRLEN( objtxt1 ).
doc_chng-doc_size = ( mail_attachment_lines - 1 ) * 255 + STRLEN( objtxt1 ).
CLEAR objpack1-transf_bin.
objpack1-head_start = 1.
objpack1-head_num = 0.
objpack1-body_start = 1.
objpack1-body_num = lv_tablines.
objpack1-doc_type = 'RAW'.
APPEND objpack1 TO objpack.
CLEAR objpack1.
objpack1-transf_bin = 'X'.
objpack1-head_start = 1.
objpack1-head_num = 1.
objpack1-body_start = 1.
objpack1-body_num = mail_attachment_lines.
objpack1-doc_type = 'PDF'.
objpack1-obj_name = 'Noti'.
objpack1-doc_size = pdf_size.
objpack1-obj_descr = 'payslip.pdf'.
APPEND objpack1 TO objpack.
CLEAR objpack1.
******FM To send mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
OBJECT_HEADER =
contents_bin = objbin
contents_txt = objtxt
contents_hex = objhex
OBJECT_PARA =
OBJECT_PARB =
receivers = recev
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.
Edited by: rokandla on Nov 3, 2011 7:35 AM
User | Count |
---|---|
96 | |
7 | |
6 | |
6 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.