cancel
Showing results for 
Search instead for 
Did you mean: 

PrintPreview and PDF in smartforms

Former Member
0 Kudos

Hi experts,

I want to display the print preview of a smart form and from there i want to convert it to PDF.

If i set the Get OTF as 'X' then printpreview is not working ,only the pdf is creating.

I am using 'CONVERT_OTF' for conversion.

Is it possible to use PrintPreview and PDF.

I came to know through forum that we can achive this through 2 times calling the smartforms but i dont want to call smartforms 2 time.Is there any other way to achive this..

Please advice.

Thanks&Regards,

Karthik.

0 Kudos

Hi Karthi, can you tell me the solution for this........

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

HI all

im having the below problem ....

we are running a background job of transaction ME9F to generate PDF files of our purchase order and then take those generated files and email it to our vendors ... We realized that some erroneous data shows up in the PDF file but they are not there when we do a print preview....

how can this be?

Some additional into ... We created a new output type for this.

Former Member
0 Kudos

There a way : After print preview appears please type  PDF! in transaction code area and then press enter.. It generates PDF for us.

alexander_bolloni
Contributor
0 Kudos

Hi Karthi,

you do not need to call SF twice. You can force SF to directly go to print preview (without creating a spool request) by setting field

PREVIEW = 'X'

in the CONTROL_OPTIONS parameter of the SF function module

At least in NW 702 where I tried it you do not need to use the "hidden" Fcode PDF! or so in preview window but can directly go to PDF document using the menu "Goto->PDF Preview"

But one cannot download the displayed PDF file from there, this is probably prohibited by the way the Acrobat PDF viewer is integrated into the HTML Dynpro control.

I suggest you try above in combination with the OUTPUT_OPTIONS-TDGETOTF='X' flag so you get the OTF data back and then convert it to PDF yourself via CONVERT_OTF.

Best regards,

  Alex

Former Member
0 Kudos

Hi Karthi,

To convert the print preview to PDF just type PDF! in command prompt at print preview screen of smartform output , like how we type SE38 , SE11 etc. etc.

BR

Dep

0 Kudos

Dear Deepak,

is this works,simply typing the PDF! in command line.

No need to write any code for this.

if this so,then it is great.

let me know.

Regards,

MNR

sandeep_katoch
Contributor
0 Kudos

Hi nagraj,

Yes this works if you simply type PDF! as the Transaction code after displayig the smartform it will by default generate the PDF and will also give the option to save it.

Former Member
0 Kudos

How or when it will ask you to save or preview the file in PDF? i type PDF and nothing happens, i select Preview PDF option, it shows blank, anything missing?

sandeep_katoch
Contributor
0 Kudos

Dear Gabriel,

Once you see smartform output in print preview then on the transaction box where you type the transaction code type '  PDF!  ' . By default pdf will be generated, I guess you are only typing pdf instead of pdf!

BR,

Sandeep Katoch

Former Member
0 Kudos

That's what i was missing i found it 30 minutes later i posted here.

Thank you.

Former Member
0 Kudos

I have called the smartforms twice

Former Member
0 Kudos

Create spool no by using print preview.

Then use pgm RSTXPDFT4 to convert spool to pdf

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 14, 2008 9:33 AM

Former Member
0 Kudos

Hi Narendra,

How to get the spool number for printpreview.Is there any other way to do this.It is urgent please any one reply.

Karthik.

Former Member
0 Kudos

Hi,

I cant get a spool number when returning from printpreview option of smartforms.I get the spool number only when i print.How to get the spool number.

Is it possible to get spool number for printpreview.

Thanks.

Edited by: karthi keyan on Feb 15, 2008 3:51 PM

Former Member
0 Kudos
REPORT zsuresh_test.


Variable declarations 
DATA:
w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.


Internal tables declaration 


Internal table to hold the OTF data 
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,


Internal table to hold OTF data recd from the SMARTFORM 
t_otf_from_fm TYPE ssfcrescl,


Internal table to hold the data from the FM CONVERT_OTF 
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.


This function module call is used to retrieve the name of the Function 
module generated when the SMARTFORM is activated 

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name

VARIANT = ' ' 
DIRECT_CALL = ' ' 
IMPORTING
fm_name = w_fmodule
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.


Calling the SMARTFORM using the function module retrieved above 
GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF 
format of the output 
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.



Printer name to be used is provided in the export parameter 
OUTPUT_OPTIONS 
w_outoptions-tddest = 'LP01'.

CALL FUNCTION w_fmodule
EXPORTING

ARCHIVE_INDEX = 
ARCHIVE_INDEX_TAB = 
ARCHIVE_PARAMETERS = 
control_parameters = w_cparam

MAIL_APPL_OBJ = 
MAIL_RECIPIENT = 
MAIL_SENDER = 
output_options = w_outoptions

USER_SETTINGS = 'X' 
IMPORTING

DOCUMENT_OUTPUT_INFO = 
job_output_info = t_otf_from_fm

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.

t_otf] = t_otf_from_fm-otfdata[.


Function Module CONVERT_OTF is used to convert the OTF format to PDF 

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132

ARCHIVE_INDEX = ' ' 
COPYNUMBER = 0 
ASCII_BIDI_VIS2LOG = ' ' 
PDF_DELETE_OTFTAB = ' ' 
IMPORTING
BIN_FILESIZE = W_bin_filesize

BIN_FILE = 
TABLES
otf = T_OTF
lines = T_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.


To display File SAVE dialog window 
CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING 
WINDOW_TITLE = 
DEFAULT_EXTENSION = 
DEFAULT_FILE_NAME = 
FILE_FILTER = 
INITIAL_DIRECTORY = 
WITH_ENCODING = 
PROMPT_ON_OVERWRITE = 'X' 
CHANGING
filename = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_FULL_PATH

USER_ACTION = 
FILE_ENCODING = 
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 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.


Use the FM GUI_DOWNLOAD to download the generated PDF file onto the 
presentation server 

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_FULL_PATH
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' 
WK1_N_FORMAT = ' ' 
WK1_N_SIZE = ' ' 
WK1_T_FORMAT = ' ' 
WK1_T_SIZE = ' ' 
IMPORTING 
FILELENGTH = 
tables
data_tab = T_pdf_tab

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.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 14, 2008 9:32 AM

Former Member
0 Kudos

Hi Saravan,

Thanks for ur reply.I am using the same code as u provided,i am getting the PDF correctly .I am not getting the print preview of the smartform.First i want the print preview and then PDF file.

Karthik

Former Member
0 Kudos

Hello Kranthi,

M facing the same problem mgatting the pdf directly ,but my user want 2 priview first then The PDF Please suggest how to  overcone thsi issue.

Thansk

Sam