Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting error message while opening PDF file.

Former Member
0 Kudos

Hello Experts....

I'm getting error message while opening the attached PDF file in mail.

I'm Sending the payslip to mail which is converted into .PDF format.

Where exactly the problem i m not getting.

Please help....

8 REPLIES 8

anjaneya_bhardwaj2
Contributor
0 Kudos

Hey , what is the error you are getting ? what are you trying to send ? and did you investigate why the error is coming ? If you have searched enough and could'nt get it then us know? also go through below links ..

[;

[http://wiki.sdn.sap.com/wiki/display/sandbox/SendMailwithPDFAttachment]

Anjaneya .

0 Kudos

Error is: There was an error while opeing this document.The file is damaged and could not be repaired....

I'm sending the PE51-PAYSLIP

converting by using this FM "CONVERT_ABAPSPOOLJOB_2_PDF"

after geting result in OUT_TAB.

again the conversion FM "QCE1_CONVERT" is using...and getting result in othe Internal table.

in this FM source is OUT_TAB

and Target is i_record.

out_tab is of type tline

and i_record is of type solisti1.

0 Kudos

Hi prajyot Go through this example ,

BCS_EXAMPLE_8 in SE38 and compare the steps . If all of your steps are matching and still you are getting error .

Then go through the links below .

[;

[;

if still not resloved paste your code here ...

0 Kudos

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = rqident

no_dialog = ' '

DST_DEVICE = out_parms-pdest

  • PDF_DESTINATION =

  • get_size_from_format = out_parms-pdest

IMPORTING

pdf_bytecount = bytecount

  • pdf_spoolid = pdfspoolid

  • LIST_PAGECOUNT =

  • btc_jobname = jobname

  • btc_jobcount = jobcount

TABLES

pdf = out_tab

EXCEPTIONS

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11.

IF sy-subrc NE 0.

ENDIF.

*CALL FUNCTION 'BAPI_GET_PAYSLIP_PDF'

  • EXPORTING

  • employeenumber = PERNR-PERNR

  • sequencenumber = '00001'

  • payslipvariant = 'PAYSLIP-PM'

  • IMPORTING

    • RETURN =

  • PAYSLIP = PAYSLIP

    • PDF_FSIZE =

  • .

*

******************CONVERTING PAYSLIP(XSTRING) TO BINARY FORMAT******

*

  • call function 'SCMS_XSTRING_TO_BINARY'

  • exporting

  • buffer = payslip

    • APPEND_TO_TABLE = ' '

    • IMPORTING

    • OUTPUT_LENGTH =

  • tables

  • binary_tab = OUT_TAB.

*----


*----


check not ( out_tab[] is initial ).

refresh i_record.

clear : i_record.

*

call function 'QCE1_CONVERT'

tables

t_source_tab = out_tab

t_target_tab = i_record

exceptions

convert_not_possible = 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.

  • do.

  • i_record = it_attachment_long.

  • append i_record.

  • shift it_attachment_long left by 255 places.

  • if it_attachment_long is initial.

  • exit.

  • endif.

  • enddo.

*

select single ltx into subject from t247

where mnr eq pn-begda+4(2)

and spras eq 'EN'.

condense subject.

concatenate 'Payslip for the month of' subject pn-begda+0(4)

into subject separated by space.

describe table lt_objbin lines l_att_lines.

read table lt_objbin index l_att_lines.

lv_document_data-doc_size = tab_lines * 255 .

lv_document_data-obj_name = 'Payslip'.

lv_document_data-obj_descr = subject.

  • e-mail body

clear lt_objpack-transf_bin.

lt_objpack-head_start = 1.

lt_objpack-head_num = 0.

lt_objpack-body_start = 1.

lt_objpack-body_num = tab_lines.

lt_objpack-doc_type = 'RAW'.

  • LT_OBJPACK-doc_size = STRLEN( LT_OBJTXT ).

append lt_objpack.

  • For e-mail attachment

lt_objhead = 'payslip.pdf'.

append lt_objhead.

lt_objbin[] = out_tab[]."i_record[].

"describe table i_record lines l_att_lines.

describe table out_tab lines l_att_lines.

  • CLEAR LT_OBJPACK.

lt_objpack-transf_bin = 'X'.

lt_objpack-head_start = 1.

lt_objpack-head_num = 0.

lt_objpack-body_start = 1.

lt_objpack-body_num = l_att_lines.

lt_objpack-doc_type = 'PDF'.

lt_objpack-obj_name = 'attachment'.

lt_objpack-obj_descr = 'payslip'.

lt_objpack-doc_size = ( l_att_lines - 1 ) * 255 + strlen( lt_objbin ).

append lt_objpack.

  • make recipient list

" check user_mail_id is not initial.

lt_reclist-receiver = user_mail_id.

lt_reclist-rec_type = 'U'.

append lt_reclist.

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

exporting

document_data = lv_document_data

put_in_outbox = 'X'

commit_work = 'X'

tables

packing_list = lt_objpack

object_header = lt_objhead

contents_bin = lt_objbin

  • contents_txt = lt_objtxt

receivers = lt_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 = 0.

write:/ 'Mail sent to', 30 user_mail_id.

write : sy-uline.

else.

write:/ 'Error encountered'.

endif.

clear : lt_objpack, lt_objhead, lt_objbin, lt_reclist.

refresh : lt_objpack, lt_objhead, lt_objbin, lt_reclist.

  • clear : filepath+3(17), pdffile, encryptpdf, batch_file.

clear : out_tab, i_record, filetable.

clear : user_mail_id, password.

else.

write : 'payslip not generated'.

endif.

end-of-selection.

Please Check....

0 Kudos

Hi please refer the below Link for the similar requirement .

[; I do not think you need to yuse ABAPPtospool FM as this is not required ...

Thanks,

Anjaneya .

0 Kudos

Thanks Anjeneya....

But there is one problem....I wanted tha PDF file in landscape view....

Will u please help...

0 Kudos

Hello Anjaneya...

The code in the link u have send to me is working fine but i dont want the payslip in that format(means dotted lines an all)...

I want the payslip which will u get after running "pc00_m40_cedt".

please help...

madhu_vadlamani
Active Contributor
0 Kudos

Hi,

What is the error you are getting.

Regards,

Madhu.