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: 

CONVERT_OTFSPOOLJOB_2_PDF ?

Former Member
0 Kudos

Hi all,

When I developed smartform I kept particular printer in mind. Now since the client wants to print it on diffrenet printers, the allignment is going to change.

I came to know about a function called, CONVERT_OTFSPOOLJOB_2_PDF which will convert the spool jobs in pdf file. Now my question is how do I implement this function in smartforms so that whenever it goes for print through spool it will get conveterted in pdf format so that allignmnet willot change whatever may be the printer ?

10 REPLIES 10

Former Member
0 Kudos

Hi,

in the smartforom interface

I_SSFCTRLOP-getotf = 'X'.

FORM SAVE_TO_PDF TABLES ZOFTDATA STRUCTURE ITCOO.

data:

ZPDF LIKE TLINE OCCURS 100 WITH HEADER LINE,

NUMBYTES TYPE I.

call function 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

IMPORTING

BIN_FILESIZE = NUMBYTES

TABLES

OTF = ZOFTDATA

LINES = ZPDF

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

BIN_FILESIZE = NUMBYTES

FILENAME = FILEPDF

FILETYPE = 'BIN'

IMPORTING

  • ACT_FILENAME = FILEPDF

FILESIZE = NUMBYTES

TABLES

DATA_TAB = ZPDF

EXCEPTIONS

OTHERS = 9.

endform.

0 Kudos

HI Svetlin Rusev,

Myself also want to convert form to PDF file. based on your coding, i defined the subroutine save_to_pdf in form routine area in gobal definition. my question is where should i call the subroutine and how to pass the parameter zotfdata. pls explain in detail . very urgent.

with thanks,

senthil.

0 Kudos

Hi,

When calling FM CALL FUNCTION sfm_name (smartform call), there is an export parameter(importing) JOB_OUTPUT_INFO of type ssfcrescl.

zotfdata = ssfcrescl-OTFDATA

The subroutine is called after closing the smartform.

But additinally need to pass to FM CALL FUNCTION sfm_name an import parameter(exporting) CONTROL_PARAMETERS type SSFCTRLOP.

SSFCTRLOP-getotf = 'X'. - to get ssfcrescl-OTFDATA

SSFCTRLOP-no_dialog = 'X'. - if you don't need a dialog

Svetlin

0 Kudos

thanks Svetlin Rusev.

0 Kudos

Could u just explain briefly how to do this.

0 Kudos

Here is a sample code.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap code samples/smartforms/tutorial with code sample on smart forms.pdf

0 Kudos

i had used this code in my code. but its not working. again i had created a new form for testing the given code. it is also not working. when i debug the code i found that the table is been passing but the filesize is not retrieved there in the conver_otf func. may be because of this the func. is not getting the data in pdf file. do u any idea where the error may have occured.

0 Kudos

Hi,

I use this code

FORM SAVE_TO_PDF TABLES ZOFTDATA STRUCTURE ITCOO.

data:

ZPDF LIKE TLINE OCCURS 100 WITH HEADER LINE,

NUMBYTES TYPE I.

call function 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

IMPORTING

BIN_FILESIZE = NUMBYTES

TABLES

OTF = ZOFTDATA

LINES = ZPDF

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

BIN_FILESIZE = NUMBYTES

FILENAME = FILEPDF

FILETYPE = 'BIN'

IMPORTING

  • ACT_FILENAME = FILEPDF

FILESIZE = NUMBYTES

TABLES

DATA_TAB = ZPDF

EXCEPTIONS

OTHERS = 9.

endform.

Be sure that table ZOFTDATA is not empty.

0 Kudos

hi

but whr u had used the perform stmt. in the print prg.

0 Kudos

Usually it should be atfer "CALL FUNCTION fm_name" stmt.

CALL FUNCTION fm_name

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMETERS =

CONTROL_PARAMETERS = I_SSFCTRLOP

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

OUTPUT_OPTIONS = I_ssfcompop

  • USER_SETTINGS = 'X'

S_BKPF = S_BKPF

S_FWBAS = S_FWBAS

S_FWSTE = S_FWSTE

S_FWTOT = S_FWTOT

S_WORDS = S_WORDS

S_PAYM = S_PAYM

V_BSEG = S_BSEG

P_TYPE = copy

I_USER = PUNAME

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

<b>JOB_OUTPUT_INFO = E_ssfcrescl</b>

  • JOB_OUTPUT_OPTIONS =

TABLES

T_BSEG = T_BSEG

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.