Skip to Content
0
Nov 24, 2005 at 05:11 AM

Display Smartform in PDF.

528 Views

Hi All,

I have gone through the forum threads to convert a smartform into a pdf document. All of them say to use function module CONVERT_OTF. This function module converts the output of the smartform which is in OTF into the PDF format and we can download the information which opens up with Adobe Reader.

The question is whether we can display the output of the smartform in Adobe at runtime within the SAP GUI because if it is in the portal then we can set the attribute in SAP Connect, to display the output of SAP Script and Smartforms in PDF.

I tried this code

REPORT ZACOSTA_FETCH_DATA_COPY.

DATA : IT_ZACOSTA TYPE ZACOSTA_TAB_DET.

DATA : V_FORM_NAME TYPE TDSFNAME VALUE 'ZACOSTA_FORMS_COPY1',

V_FUNC_NAME TYPE RS38L_FNAM.

DATA: LS_CONTROL_PARAMETERS TYPE SSFCTRLOP,

LS_OUTPUT_OPTIONS TYPE SSFCOMPOP,

LS_JOB_OUTPUT_INFO TYPE SSFCRESCL,

LT_LINES TYPE TABLE OF TLINE,

L_DEVTYPE TYPE RSPOPTYPE,

L_SAM_HAWKINS TYPE INT4,

L_DOC TYPE DOCS OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

SELECT VBAKVBELN VBAKVKORG VBAK~VTWEG

VBAKSPART VBAKKUNNR VBAP~POSNR

VBAPMATNR VBAPARKTX VBAP~NETWR

VEDAVBEGDAT VEDAVENDDAT

INTO CORRESPONDING FIELDS OF TABLE IT_ZACOSTA

FROM VBAK INNER JOIN VBAP

ON VBAKVBELN = VBAPVBELN

INNER JOIN VEDA

ON VEDAVBELN = VBAPVBELN

WHERE VBAK~VBELN = '0040000264'. "Where Clause to be removed

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = V_FORM_NAME

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = V_FUNC_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.

  • Set language

LS_CONTROL_PARAMETERS-LANGU = SY-LANGU.

  • Set control parameters to get the output format (OTF) from Smart Forms

LS_CONTROL_PARAMETERS-NO_DIALOG = 'X'.

LS_CONTROL_PARAMETERS-GETOTF = 'X'.

LS_OUTPUT_OPTIONS-TDNOPREV = 'X'.

CALL FUNCTION V_FUNC_NAME

EXPORTING

OUTPUT_OPTIONS = LS_OUTPUT_OPTIONS

CONTROL_PARAMETERS = LS_CONTROL_PARAMETERS

USER_SETTINGS = SPACE

IT_ZACOSTA = IT_ZACOSTA

IMPORTING

JOB_OUTPUT_INFO = LS_JOB_OUTPUT_INFO.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '

  • COPYNUMBER = 0

IMPORTING

BIN_FILESIZE = L_SAM_HAWKINS

  • bin_file = p_data " binary file

TABLES

OTF = LS_JOB_OUTPUT_INFO-OTFDATA

LINES = LT_LINES

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

ERR_BAD_OTF = 4

OTHERS = 5

.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'C:\Test.pdf'

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'

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = LT_LINES

  • 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.

The reson why I had to download is because this does not show the PDF at runtime. Am I missing some parameter here or is there some kind of configuration required to display the smartform in PDF at runtime within the SAP GUI.

Any hints on this would be greatly appreciated.

Best Regards,

Sudhi