cancel
Showing results for 
Search instead for 
Did you mean: 

Smartforms emailed as PDF but can't be opened

Former Member
0 Kudos

Hello all,

Several of our SAP users will do a 'Print Preview' of a document to their screen. We are using Smartforms for this. Then they will click on the 'Send e-mail' button and send the document to their email address. It comes to their email as a PDF attachment. Some users, but not all, cannot open the PDF attachment. They get the following error:

'Can't create file: 'filename'.pdf. Right-click the folder you want to create the file in, and then click Properties on the shortcut menu to check your permissions on the folder.'

This does not happen to everyone. Also, when they can't open the PDF file, they can forward it to someone else who can open the file and that person will open it, save it with a different name and then email it back to the person who originally couldn't open it. Now they can open the PDF file.

Any ideas on where to start looking for the source of the problem, SAP, Adobe, PC settings, etc?

Thanks,

Rick

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello again,

Thank you for your replies, but we are not using custom code for any of this, it is all strictly SAP code.

Here is the scenario of what happens.

Lets say a user wants to email a quote. The user will goto SAP transaction VA23. Type in a quote number, and then click on Sales document-->Issue Output To. On the popup screen the user will then click on the Print Preview button. An image of the quote will now appear on the user's screen. The user then clicks on the Send e-mail button. Another screen comes up and the user types in the recipient's email address, selects Internet mail for the recipient type, then finally clicks on the Send button. The document then shows up in the sent to email as a PDF attachment. Here is where some users can open the PDF document and some cannot, but it seems to by a mystery so far as to why some cannot open the PDF document.

Any further thoughts would be appreciated.

Thanks,

Rick

Former Member
0 Kudos

Hi Richard,

Check my post in the following thread.

Regards,

Sravanthi

former_member451655
Active Participant
0 Kudos

hi,

Please Double check your Cording ,

REPORT zemail_gm.

*********Variable Declarations *****************************

DATA: gv_form_name TYPE rs38l_fnam, " Used to store the function module generated by Smartform

gv_bin_filesize TYPE i, " Store the file size

gv_pos TYPE i,

gv_len TYPE i,

gv_tab_lines TYPE i.

********Constants *******************************************

Data : gc_text(11) type c value 'Form Output',

gc_tst(3) type c value 'TST',

gc_testing(7) type c value 'Testing'.

*********Work Area Declarations *****************************

DATA: gs_docdata TYPE sodocchgi1, " Data of an object which can be changed

gs_ctrlop TYPE ssfctrlop, " Smart Forms: Control structure

gs_outopt TYPE ssfcompop, " SAP Smart Forms: Smart Composer (transfer) options

gs_otfdata TYPE ssfcrescl, " Smart Forms: Return value at end of form printing

gs_reclist TYPE somlreci1, " SAPoffice: Structure of the API Recipient List

gs_pdf_tab TYPE tline, " Workarea for SAP Script Text Lines

gs_objbin TYPE solisti1, " SAPoffice: Single List with Column Length 255

gs_objpack TYPE sopcklsti1. " SAPoffice: Description of Imported Object Components

*********Internal tables Declarations *****************************

DATA: gt_reclist TYPE TABLE OF somlreci1, " SAPoffice: Structure of the API Recipient List

gt_pdf_tab TYPE TABLE OF tline, " SAPscript: Text Lines

gt_otf TYPE TABLE OF itcoo, " OTF Structure

gt_objbin TYPE TABLE OF solisti1, " SAPoffice: Single List with Column Length 255

gt_objpack TYPE TABLE OF sopcklsti1. " SAPoffice: Description of Imported Object Components

CLEAR : gv_form_name,

gs_ctrlop,

gs_outopt,

gs_otfdata,

gv_bin_filesize,

gv_pos,

gv_len,

gv_tab_lines.

START-OF-SELECTION.

u2022 Generate Function Module name

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZPDF_G'

IMPORTING

fm_name = gv_form_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

u2022 Assigning values to Form Control Structure and Form Composer

gs_ctrlop-getotf = 'X'.

gs_ctrlop-no_dialog = 'X'.

gs_outopt-tdnoprev = 'X'.

u2022 Getting the OTFDATA

CALL FUNCTION gv_form_name

EXPORTING

control_parameters = gs_ctrlop

output_options = gs_outopt

user_settings = 'X'

IMPORTING

job_output_info = gs_otfdata

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

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

u2022 Assigning the OTFDATA to OTF Structure table

CLEAR gt_otf.

gt_otf] = gs_otfdata-otfdata[.

u2022 Convert the OTF DATA to SAP Script Text lines

CLEAR gt_pdf_tab.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = gv_bin_filesize

TABLES

otf = gt_otf

lines = gt_pdf_tab

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

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

ENDIF.

u2022 Assigning the Description of the object sent in the mail

CLEAR gs_docdata.

gs_docdata-obj_name = gc_tst.

gs_docdata-obj_descr = gc_testing.

u2022 Assigning the email id to Structure of the API Recipient List table

CLEAR : gt_reclist, gs_reclist.

gs_reclist-receiver = 'mail id of recipent'.

gs_reclist-rec_type = 'U'.

APPEND gs_reclist TO gt_reclist.

u2022 Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table

CLEAR : gs_objbin, gs_pdf_tab.

LOOP AT gt_pdf_tab INTO gs_pdf_tab.

gv_pos = 255 - gv_len.

IF gv_pos > 134. "length of pdf_table

gv_pos = 134.

ENDIF.

gs_objbin+gv_len = gs_pdf_tab(gv_pos).

gv_len = gv_len + gv_pos.

IF gv_len = 255. "length of out (contents_bin)

APPEND gs_objbin TO gt_objbin.

CLEAR: gs_objbin, gv_len.

IF gv_pos < 134.

gs_objbin = gs_pdf_tab+gv_pos.

gv_len = 134 - gv_pos.

ENDIF.

ENDIF.

ENDLOOP.

IF gv_len > 0.

APPEND gs_objbin TO gt_objbin.

ENDIF.

u2022 Filling the details in SAPoffice: Description of Imported Object Components table

DESCRIBE TABLE gt_objbin LINES gv_tab_lines.

CLEAR gs_objbin.

READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.

IF sy-subrc = 0.

gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).

gs_objpack-transf_bin = 'X'.

gs_objpack-head_start = 1.

gs_objpack-head_num = 0.

gs_objpack-body_start = 1.

gs_objpack-body_num = gv_tab_lines.

gs_objpack-doc_type = 'PDF'.

gs_objpack-obj_name = 'ATTACHMENT'.

gs_objpack-obj_descr = 'test'.

APPEND gs_objpack TO gt_objpack.

ENDIF.

u2022 Sending the Form Output in the PDF format to email

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gs_docdata

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = gt_objpack

contents_bin = gt_objbin

receivers = gt_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.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

WRITE 'Sent Successfully'.

ENDIF.

SUBMIT rsconn01

WITH mode EQ 'INT'

AND RETURN.

END-OF-SELECTION.