Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Convert Smartform Output to PDF

Hi all,

I am trying to save Output of Smartform in PDF file format. for that purpose i am calling "CONVERT_OTF" FM from my driver program.

But it is giving me <b>Information "OTF end command // missing in OTF data"</b>

while executing FM "CONVERT_OTF". i debug it it is giving Sy-subrc = 2.

Please Help me in this context. I am also givin code of my driver program:

TABLES: vbrp.

DATA: fm_name TYPE rs38l_fnam,

it_invoice TYPE STANDARD TABLE OF vbrp,

it_invoice_wa TYPE vbrp,

it_inv TYPE STANDARD TABLE OF vbrp,

it_inv_wa TYPE vbrp,

invoice_no(25) TYPE c,

invoice_l(10) TYPE c,

invoice_h(10) TYPE c.

                  • Converting Output to PDF Declaration **********

DATA: tab_otf_data TYPE ssfcrescl,

pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,

bin_filesize LIKE sood-objlen,

outop TYPE ssfcompop, " Output Parameters

cparam TYPE ssfctrlop, " Control Parameters

tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,

my_tabix TYPE sy-tabix,

file_size TYPE i.

SELECT-OPTIONS doc_no FOR vbrp-vbeln.

SELECT vbeln posnr fkimg vrkme meins netwr matnr

FROM vbrp INTO CORRESPONDING FIELDS

OF TABLE it_invoice

WHERE vbeln IN doc_no.

  • Inserting Unique Invoice Numbers for Displaying Individual Details in

  • Smart Form

LOOP AT it_invoice INTO it_invoice_wa.

AT NEW vbeln.

MOVE it_invoice_wa-vbeln TO it_inv_wa-vbeln.

APPEND it_inv_wa TO it_inv.

ENDAT.

ENDLOOP.

invoice_no = doc_no.

invoice_l = doc_no-low.

invoice_h = doc_no-high.

                                  • suppressing the Print dialog box *********************

*outop-tddest = 'locl'.

*cparam-no_dialog = 'X'.

*cparam-preview = space.

*cparam-getotf = 'X'.

START-OF-SELECTION.

                                      • Calling Smart Form *********************************

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZSB_SMARTFORM_INVOICE'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = fm_name

.

CALL FUNCTION fm_name

EXPORTING

invoice_no_h = invoice_h

invoice_no_l = invoice_l

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • control_parameters = cparam

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • output_options = outop

  • user_settings = ''

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

JOB_OUTPUT_INFO = tab_otf_data

  • JOB_OUTPUT_OPTIONS =

TABLES

it_invoice = it_invoice

it_inv = it_inv

.

*

***removing the initial and final markers from the OTF data*********

  • DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.

                                  • searching for the end-of-page in OTF table************

  • READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.

  • my_tabix = sy-tabix + 1.

                        • appending the modified OTF table to the final OTF table****

*INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.

tab_otf_final[] = tab_otf_data-otfdata[].

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

  • ARCHIVE_INDEX = ' '

  • COPYNUMBER = 0

  • ASCII_BIDI_VIS2LOG = ' '

IMPORTING

bin_filesize = bin_filesize

  • BIN_FILE =

TABLES

otf = tab_otf_final

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

write :/ bin_filesize.

*

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = bin_filesize

filename = 'E:/Test.pdf'

FILETYPE = 'ASC'

IMPORTING

FILELENGTH = file_size

tables

data_tab = pdf_tab

  • FIELDNAMES =

.

Help will be rewarded.

Regards,

Sachin

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question