cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform output to pdf in ECC 6.0 for Purchase Order

Former Member
0 Kudos

Hi Experts,

I am developing the Smartform to print Purchase Order. For this I have copied the standard Smartform of PO and modifying according to Client requirement. But I did not do any modifications on Print Program. Our client wants to save the PO into PDF format as local file after seeing the print preview . How to achieve this.I have already searched some threads, for this I need to modify the print program also. Is there any way to save PO as PDF file format with out modifying the Print Program?. Further I have another doubt, is there any possible way to save the PO as PDF after seeing the print preview?

For this the standard Print Program Is YBAA_FM06P.

Thanks and Regards,

Jagadeesh.

Edited by: Jagadeesh on Jan 22, 2009 5:33 PM

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Jagdeesh,

I hope the given code will solve your problem 100%

You just change the Parameters and your Smartform Name.

*variable declaration

DATA : fm_name TYPE rs38l_fnam. " Name of the Function Module

DATA: it_otf TYPE STANDARD TABLE OF itcoo,

it_docs TYPE STANDARD TABLE OF docs,

it_lines TYPE STANDARD TABLE OF tline,

st_job_output_info TYPE ssfcrescl,

st_document_output_info TYPE ssfcrespd,

st_job_output_options TYPE ssfcresop,

st_output_options TYPE ssfcompop,

st_control_parameters TYPE ssfctrlop,

v_len_in TYPE so_obj_len,

v_language TYPE sflangu VALUE 'E',

v_e_devtype TYPE rspoptype,

v_bin_filesize TYPE i,

v_name TYPE string,

v_path TYPE string,

v_fullpath TYPE string,

v_filter TYPE string,

v_uact TYPE i,

v_guiobj TYPE REF TO cl_gui_frontend_services,

v_filename TYPE string,

v_fm_name TYPE rs38l_fnam.

************************************************************************

CALL FUNCTION 'SSF_GET_DEVICE_TYPE'

EXPORTING

i_language = v_language

i_application = 'SAPDEFAULT'

IMPORTING

e_devtype = v_e_devtype.

st_output_options-tdprinter = v_e_devtype.

st_output_options-tdprinter = 'locl'.

st_control_parameters-no_dialog = 'X'.

st_control_parameters-getotf = 'X'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZDTK_MM_57FC'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

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

CALL FUNCTION fm_name

*CALL FUNCTION '/1BCDWB/SF00000044'

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

CONTROL_PARAMETERS = st_control_parameters

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

OUTPUT_OPTIONS = st_output_options

  • USER_SETTINGS = 'X'

SFP_BUKRS = P_BUKRS

SFP_WERKS = P_WERKS

SFP_EXNUM = P_EXNUM

IMPORTING

DOCUMENT_OUTPUT_INFO = st_document_output_info

JOB_OUTPUT_INFO = st_job_output_info

JOB_OUTPUT_OPTIONS = st_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.

ELSE.

************************************************************************

.........................CONVERT TO OTF TO PDF........................

************************************************************************

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = v_bin_filesize

TABLES

otf = st_job_output_info-otfdata

doctab_archive = it_docs

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

************************************************************************

.....................GET THE FILE NAME TO STORE.......................

************************************************************************

CONCATENATE P_EXNUM '.pdf' INTO v_name.

CREATE OBJECT v_guiobj.

CALL METHOD v_guiobj->file_save_dialog

EXPORTING

default_extension = 'pdf'

*default_extension = 'doc'

default_file_name = v_name

file_filter = v_filter

CHANGING

filename = v_name

path = v_path

fullpath = v_fullpath

user_action = v_uact.

IF v_uact = v_guiobj->action_cancel.

EXIT.

ENDIF.

************************************************************************

....................DOWNLOAD AS FILE..................................

************************************************************************

MOVE v_fullpath TO v_filename.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = v_bin_filesize

filename = v_filename

filetype = 'BIN'

*filetype = 'DAT'

TABLES

data_tab = it_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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

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

ENDIF.

ENDIF.

Regards,

Devalla T Kumar

Former Member
0 Kudos

>

> For this the standard Print Program Is YBAA_FM06P.

Its starting with Y i dnt think thts a standard print program so better do changes to the print program itself, its much better to implement it thru print program.

Former Member
0 Kudos

well what u can do is write a report tht will retrive ur spool and use this spool to convert into pdf . this way u can get pdf without modifying the print program but u hv to be careful tht u get the correct spool

Former Member
0 Kudos