cancel
Showing results for 
Search instead for 
Did you mean: 

Image Missing In PDF Converted from SapScript

Former Member
0 Kudos

Hi Experts,

I was supposed to convert SapScript into PDF for sending as an attachment with mail.

When I am doing that the image (client's logo) in SapScript is not present in PDF file.

Strange scenario here is that when I am downloading that same file to my hard disk then it is absolutely fine.

I have used FM 'CONVERT_OTF_2_PDF' to get PDF table. Then I compressed the PDF table data using the follwoing code snippet:

LOOP AT lt_pdftab INTO wa_pdftab.

TRANSLATE wa_pdftab USING ' ~'.

CONCATENATE wa_buffer wa_pdftab INTO wa_buffer.

CLEAR wa_pdftab.

ENDLOOP.

TRANSLATE wa_buffer USING '~ '.

DO.

wa_record = wa_buffer.

APPEND wa_record TO lt_record.

CLEAR wa_record.

SHIFT wa_buffer LEFT BY 255 PLACES.

IF wa_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

I think in this above process only some thing is going wrong because when I am downloading PDF file using GUI_DOWNLOAD then I am passing directly internal table lt_pdftab & not lt_record. But on exporting lt_pdftab data as attachment with mail the PDF file is getting opened with error.

Any help regarding the same is highly appreciated.

Thanks,

Shaurya Jain

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Just observe this Code:

REPORT zsuresh_test.

Variable declarations

DATA:

w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',

w_fmodule TYPE rs38l_fnam,

w_cparam TYPE ssfctrlop,

w_outoptions TYPE ssfcompop,

W_bin_filesize TYPE i, " Binary File Size

w_FILE_NAME type string,

w_File_path type string,

w_FULL_PATH type string.

Internal tables declaration

Internal table to hold the OTF data

DATA:

t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

Internal table to hold OTF data recd from the SMARTFORM

t_otf_from_fm TYPE ssfcrescl,

Internal table to hold the data from the FM CONVERT_OTF

T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.

This function module call is used to retrieve the name of the Function

module generated when the SMARTFORM is activated

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = w_form_name

VARIANT = ' '

DIRECT_CALL = ' '

IMPORTING

fm_name = w_fmodule

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.

Calling the SMARTFORM using the function module retrieved above

GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF

format of the output

w_cparam-no_dialog = 'X'.

w_cparam-preview = space. " Suppressing the dialog box

" for print preview

w_cparam-getotf = 'X'.

Printer name to be used is provided in the export parameter

OUTPUT_OPTIONS

w_outoptions-tddest = 'LP01'.

CALL FUNCTION w_fmodule

EXPORTING

ARCHIVE_INDEX =

ARCHIVE_INDEX_TAB =

ARCHIVE_PARAMETERS =

control_parameters = w_cparam

MAIL_APPL_OBJ =

MAIL_RECIPIENT =

MAIL_SENDER =

output_options = w_outoptions

USER_SETTINGS = 'X'

IMPORTING

DOCUMENT_OUTPUT_INFO =

job_output_info = t_otf_from_fm

JOB_OUTPUT_OPTIONS =

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.

t_otf] = t_otf_from_fm-otfdata[.

Function Module CONVERT_OTF is used to convert the OTF format to PDF

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

ARCHIVE_INDEX = ' '

COPYNUMBER = 0

ASCII_BIDI_VIS2LOG = ' '

PDF_DELETE_OTFTAB = ' '

IMPORTING

BIN_FILESIZE = W_bin_filesize

BIN_FILE =

TABLES

otf = T_OTF

lines = T_pdf_tab

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.

To display File SAVE dialog window

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

WINDOW_TITLE =

DEFAULT_EXTENSION =

DEFAULT_FILE_NAME =

FILE_FILTER =

INITIAL_DIRECTORY =

WITH_ENCODING =

PROMPT_ON_OVERWRITE = 'X'

CHANGING

filename = w_FILE_NAME

path = w_FILE_PATH

fullpath = w_FULL_PATH

USER_ACTION =

FILE_ENCODING =

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

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

Use the FM GUI_DOWNLOAD to download the generated PDF file onto the

presentation server

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = W_bin_filesize

filename = w_FULL_PATH

FILETYPE = 'BIN'

APPEND = ' '

WRITE_FIELD_SEPARATOR = ' '

HEADER = '00'

TRUNC_TRAILING_BLANKS = ' '

WRITE_LF = 'X'

COL_SELECT = ' '

COL_SELECT_MASK = ' '

DAT_MODE = ' '

CONFIRM_OVERWRITE = ' '

NO_AUTH_CHECK = ' '

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

WRITE_BOM = ' '

TRUNC_TRAILING_BLANKS_EOL = 'X'

WK1_N_FORMAT = ' '

WK1_N_SIZE = ' '

WK1_T_FORMAT = ' '

WK1_T_SIZE = ' '

IMPORTING

FILELENGTH =

tables

data_tab = T_pdf_tab

FIELDNAMES =

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF sy-subrc 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards,

If helpful reward with points(Don't forget).

Former Member
0 Kudos

Hi Shiva,

Thanks for the reply. But I think I couldn't make my question clear enough.

The issue is not while downloading the PDF file. I am getting it absolutely fine when I am downloading it. The issue is with while sending the PDF as an attachment with mail.

Regards,

Shaurya Jain

Former Member
0 Kudos

I am still expecting to hear back from somebody regarding the solution.

Any kind of help will be highly appreciable. It is really urgent.

Thanks,

Shaurya Jain