Application Development and Automation 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: 
Read only

print script in pdf format

Former Member
0 Likes
990

Hi all,

I have a script and i need to print it in pdf format ,right now its printing in orginal or normal .Please let me know what i should do in order to print it in pdf form, i don't want to save it somewhere and then print it,i need to print it directly rather than saving it.

Any help would be greatly appreciated

Thanks

deepthi

7 REPLIES 7
Read only

Former Member
0 Likes
956

Please go through this link , hope you will get useful stuff from this.

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f...

&----


*& Form f9100_save_to_pdf

&----


  • text

----


  • -->P_WS_FORMNAME text

----


FORM f9100_save_to_pdf using value(ws_formname).

data: i_lines TYPE tline OCCURS 0 WITH HEADER LINE.

data: ws_bin_size type i,

ws_filename type string.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = ws_bin_size

TABLES

otf = i_otf

lines = i_lines

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

IF sy-subrc <> 0.

flg_exit = 'X'.

MESSAGE i050 WITH 'Error converting to PDF format'.

EXIT.

ENDIF.

  • Get the download path

PERFORM get_download_path CHANGING ws_filename.

if flg_exit = 'X'.

EXIT.

endif.

  • Download

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = ws_bin_size

filename = ws_filename

filetype = 'BIN'

TABLES

data_tab = i_lines

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 i050 WITH 'Error while File download'.

flg_exit = 'X'.

EXIT.

ELSE.

MESSAGE i050 WITH 'File downloaded successfully '.

flg_exit = 'X'.

EXIT.

ENDIF.

Regards,

Prakash.

Read only

0 Likes
956

HI ALL,

I WANT TO PRINT IT IMMEDIATELY ,

LET ME KNOW WHAT I SHOULD I DO.i DON'T WANT TO SAVE.

THANKS

DEEPTHI

Read only

Former Member
0 Likes
956

HI,

See the below threads ...

http://searchsap.techtarget.com/tip/0,289483,sid21_gci933581,00.html

mark all the helpful answers

Regards

Sudheer

Read only

0 Likes
956

Hi when i use fm

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '

IMPORTING

BIN_FILESIZE = BINFILESIZE

TABLES

OTF = DATATAB[]

LINES = PDFTAB[]

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.

i have values in DATATAB[] and PDFTAB[]

but for some reason i don't see anything in my print preview or even i print it,it doesn't print.when i comment the above FM ,I AM ABLE TO VIEW IN PRINT PREVIEW AND ABLE TO PRINT IT.

I WANT TO KNOW WHETHER ITS POSSIBLE TO PRINT THE PDF DIRECTLY OR DO I NEED TO SAVE IT SAY DESKTOP AND THEN PRINT IT.

waiting for replies

Read only

Former Member
0 Likes
956

Hi Deepthi,

Consider the FM <b>OPEN_FORM</b>,

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

DEVICE = 'PRINTER'

DIALOG = space

FORM = 'ZSCRIPT'

  • LANGUAGE = SY-LANGU

OPTIONS = struct

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • SPONUMIV =

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

MAIL_OPTIONS = 6

ARCHIVE_ERROR = 7

INVALID_FAX_NUMBER = 8

MORE_PARAMS_NEEDED_IN_BATCH = 9

SPOOL_ERROR = 10

CODEPAGE = 11

OTHERS = 12

.

In the <b> OPTIONS </b> parameter, you can assign the component called <b>TDIMMED</b> and pass it to OPEN_FORM.

In the above example you can do like this.

struct-tdimmed = 'X'.

Now pass struct to the OPTIONS parameter of OPEN_FORM.

<b>Award points if found useful.</b>

Regards,

SP.

Read only

0 Likes
956

hi,

can anyone check the code and tell me what iam missing

I don't want to save the pdf file i want to print it or see it under print preview.

WAITING FOR REPLIES

DATA: PDFTAB TYPE TABLE OF TLINE WITH HEADER LINE,

DATATAB TYPE TABLE OF ITCOO WITH HEADER LINE.

DATA: BINFILESIZE TYPE I,

FILE_NAME TYPE STRING,

FILE_PATH TYPE STRING,

FULL_PATH TYPE STRING.

data: begin of itcpp.

include structure itcpo.

data: end of itcpp.

itcpp-tdcopies = 1.

itcpp-tdimmed = 'X'.

itcpp-tddelete = 'X'.

itcpp-tdnewid = ' '.

ITCPP-tddest = 'LP01'.

ITCPP-tdgetotf = 'X'.

itcpp-tdpreview = 'X'.

Call function 'OPEN_FORM'

exporting

device = 'PRINTER'

dialog = 'X'

  • form = 'ZZ_PICK_LIST '

form = space

language = sy-langu

options = itcpp.

call function 'START_FORM'

exporting

  • ARCHIVE_INDEX =

form = 'ZTEST'

  • LANGUAGE = ' '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

  • EXCEPTIONS

  • FORM = 1

  • FORMAT = 2

  • UNENDED = 3

  • UNOPENED = 4

  • UNUSED = 5

  • SPOOL_ERROR = 6

  • OTHERS = 7

.

LOOP AT ITAB.

call function 'WRITE_FORM'

exporting

element = 'HEAD'

function = 'SET'

window = 'MAIN'

.

ENDLOOP.

CALL FUNCTION 'CLOSE_FORM'

IMPORTING

RESULT = itcpp

  • RDI_RESULT =

TABLES

OTFDATA = DATATAB[]

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SEND_ERROR = 3

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

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '

IMPORTING

BIN_FILESIZE = BINFILESIZE

TABLES

OTF = DATATAB[]

LINES = PDFTAB[]

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.

*ENDIF.

Read only

Former Member
0 Likes
956

first u change urs layout into otf form using close function:

DATA BEGIN OF I_otfdata OCCURS 50.

include structure itcoo.

DATA END OF I_otfdata.

DATA: i_itcpp LIKE itcpp.

CALL FUNCTION 'CLOSE_FORM'

IMPORTING

result = i_itcpp

TABLES

otfdata = <b>I_otfdata</b>

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

IF i_itcpp-tdspoolid NE space.

PERFORM protocol_update_spool USING '342' i_itcpp-tdspoolid

space space space.

ENDIF.

then change otf to pdf use FM :

data: t_lines type standard table of tline

initial size 0 with header line.

data: t_doctab type standard table of docs initial size 0,

bin_filesize TYPE i,

w_filename(70) type c.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

EXPORTING

USE_OTF_MC_CMD = ' '

IMPORTING

BIN_FILESIZE = bin_filesize

TABLES

OTF = I_otfdata[]

DOCTAB_ARCHIVE = t_doctab[]

LINES = t_lines[]

EXCEPTIONS

ERR_CONV_NOT_POSSIBLE = 1

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

If u ant to save in logical file use following code:

concatenate vbdkr-vbeln '_'

vbdkr-fkdat '_'

vbdkr-kunrg '.pdf' into w_filename.

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

logical_filename = 'ZFILE'

operating_system = sy-opsys

parameter_1 = 'AR'

parameter_2 = 'SEND'

parameter_3 = w_filename

IMPORTING

file_name = w_filename

EXCEPTIONS

file_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

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

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

EXIT.

If u feel any prob after that thn reply.