cancel
Showing results for 
Search instead for 
Did you mean: 

PDF...

Former Member
0 Kudos

hi,

I have created a smartform, and now wanna display it in the PDF format. Could anyone please guide me with the steps to create it?

thanks.

Nayan

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

thanks

former_member196280
Active Contributor
0 Kudos

Try this

SAMPLE CODE FOR PRINTING

data: carr_id type sbook-carrid,

cparam type ssfctrlop,

outop type ssfcompop,

fm_name type rs38l_fnam.

DATA: tab_otf_data TYPE ssfcrescl,

pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,

tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,

file_size TYPE i,

bin_filesize TYPE i,

FILE_NAME type string,

File_path type string,

FULL_PATH type string.

parameter: p_custid type scustom-id default 1.

select-options: s_carrid for carr_id default 'LH' to 'LH'.

parameter: p_form type tdsfname default 'ZAMIT_SMART_FORM'.

data: customer type scustom,

bookings type ty_bookings,

connections type ty_connections.

start-of-selection.

                                  • suppressing the dialog box for print preview****************************

outop-tddest = 'LP01'.

cparam-no_dialog = 'X'.

cparam-preview = SPACE.

cparam-getotf = 'X'.

select single * from scustom into customer where id = p_custid.

check sy-subrc = 0.

select * from sbook into table bookings

where customid = p_custid

and carrid in s_carrid

order by primary key.

select * from spfli into table connections

for all entries in bookings

where carrid = bookings-carrid

and connid = bookings-connid

order by primary key.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting formname = p_form

  • 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.

exit.

endif.

  • calling the generated function module

call function fm_name

exporting

  • archive_index =

  • archive_parameters =

control_parameters = cparam

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

output_options = outop

user_settings = SPACE

bookings = bookings

customer = customer

connections = connections

importing

  • document_output_info =

job_output_info = tab_otf_data

  • job_output_options =

exceptions formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

others = 5.

if sy-subrc <> 0.

  • error handling

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

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.

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 = FILE_NAME

path = FILE_PATH

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

************downloading the converted PDF data to your local PC*******

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = bin_filesize

filename = 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'

IMPORTING

filelength = file_size

TABLES

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

ENDIF.

Rgds,

Sai

Former Member
0 Kudos

Hi

check with this material

here is the sample program to convert the smartform into pdf format

Here is the sample code.

DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

i_tline TYPE TABLE OF tline WITH HEADER LINE,

  • Work Area declarations

w_ctrlop TYPE ssfctrlop,

w_compop TYPE ssfcompop,

w_return TYPE ssfcrescl,

  • Variables declarations

v_form_name TYPE rs38l_fnam,

v_len_in LIKE sood-objlen,

v_len_out LIKE sood-objlen,

v_len_outn TYPE i.

Step 1:

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZZZ_TEST2'

importing

fm_name = v_form_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.

w_ctrlop-getotf = 'X'.

w_ctrlop-no_dialog = 'X'.

w_compop-tdnoprev = 'X'.

Step 2:

CALL FUNCTION v_form_name

EXPORTING

control_parameters = w_ctrlop

output_options = w_compop

user_settings = 'X'

IMPORTING

job_output_info = w_return

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.

Step 3:

i_otf[] = w_return-otfdata[].

Step 4:

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = v_len_in

TABLES

otf = i_otf

lines = i_tline

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.

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos

Hi

There are function module that display smartform in PDF format on screen.

There are two ways:

1) Call smartform with option -getotf is set.

Call funtion module CONVERT_OTF_2_PDF

Save this PDF file to your local PC using fm 'GUI_DOWNLOAD'.

Call function module 'WS_EXECUTE' to run your pdf file

2) Call smartform with option -getotf is set.

Call function module SSF_PDF_PREVIEW (I don't remember exactly now, i'll confirm later)

This function module will display OTF-data under pdf format.

PDF-based forms are part of the <b>SAP Interactive Forms</b> by Adobe solution. You use this solution to create and edit PDF forms for printing in SAP systems. As well as standard output on printers, and the option of archiving documents, you can also use your application to send a PDF to the Business Communication Services (BCS). Here, you have the option of faxing or e-mailing your documents.

The following gives you an overview of how a PDF-based form is structured, and also tells you how to create a PDF-based form in the development environment of ABAP Workbench. The integrated Adobe LiveCycle Designer™ software supports you when you do this. This software must be installed on your front end before you can create a layout. To see a print preview of your form, you first need to install Adobe Reader or a complete version of Adobe Acrobat.

You create and edit interactive forms in the development environment SAP NetWeaver Developer Studio. To create interactive forms here, you use the interface element InteractiveForm in Web Dynpro for Java.

This documentation does not discuss how documents are printed and controlled on printers. Instead, it discusses the whole process up to when a file is sent to output management functions, such as the spool system in SAP systems. Note that, for printing and previewing PDF-based forms, you need to use a PCL, Postscript, or ZPL printer and an appropriate device type (such as POST2, HPLJ4, HP9500, PDF1, AZPL203, or AZPL300). You cannot use a printer with the device type SAPWIN/SWIN. More information is available in the SAP Printing Guide (BC-CCM-PRN), under Printing PDF-Based Forms.

<u><b>Integration</b></u>

An activated PDF-based form corresponds to a callable function module in the SAP system. The complete logic of the form is represented by this function module. When a form is printed, it is called by an application program, which collects the relevant application data. The application program uses the function module interface to send the data. Therefore, the data collection process is split from the logic of the form. This means that you only need to adjust the form when you modify the logic or layout.

<u><b>Features</b></u>

To develop a PDF-based form, you use the Form Builder tool that is integrated with ABAP Workbench. This tool enables you to create a complete form description, even if you do not have extensive programming skills. The tool supports you in the following tasks:

&#9679; Creating layouts

Here, you use the Adobe LiveCycle Designer to design pages or create the layout.

&#9679; Specifying the data used in the form

In the form context, you specify which data, tables, texts, and graphics are sent to the form.

&#9679; Migration of Smart Forms

By migrating Smart Forms, you can reuse them as PDF-based forms. You can find the Smart Form migration tool in transaction SMARTFORMS.

Smart Forms are still supported; you can continue to forms created in Smart Forms without making any changes.

&#9679; Importing existing PDF files or forms

This tool is integrated into Adobe LiveCycle Designer and enables you to use your own templates for your form.

&#9679; Scripting

Adobe LiveCycle Designer uses the script languages JavaScript and FormCalc. FormCalc is a simple Adobe script language for typical form calculations, including mathematical and logical functions, and date and character string functions. For more information about FormCalc, and a FormCalc language reference, see the online help of LiveCycle Designer.

To achieve the best level of performance when processing forms, use as little scripting as possible in the form. If possible, perform all calculations and data analysis in the application program, before the form is called.

&#9679; Printing and archiving the PDF form:

You can use output parameters to specify print and archive settings, and so adapt the output to your requirements. These parameters are not viewed in Form Builder. Instead, you control them with function modules that you integrate in your application program.

<u><b>

Restrictions</b></u>

Note that local print versions may differ from print versions produced using spool requests in the SAP system. You can print out parts of PDF forms (such as selected pages) as local print versions only, using Adobe Acrobat or Adobe Reader. Information about further restrictions is available in SAP Note 1009567.

you can save your smartform as a pdf.

1. Use FM

CONVERT_OTF_2_PDF

to convert smartform output (otf) to pdf. It will store converted data into an internal table.

2. Use FM

GUI_DOWNLOAD

to download that internal table on the presentation server as a pdf file.

<b>Check this sample code</b>

data: carr_id type sbook-carrid,
cparam type ssfctrlop,
outop type ssfcompop,
fm_name type rs38l_fnam.

DATA: tab_otf_data TYPE ssfcrescl,
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
file_size TYPE i,
bin_filesize TYPE i,
FILE_NAME type string,
File_path type string,
FULL_PATH type string.

parameter: p_custid type scustom-id default 1.
select-options: s_carrid for carr_id default 'LH' to 'LH'.
parameter: p_form type tdsfname default 'ZPAVANSMART_FORM'.

data: customer type scustom,
bookings type ty_bookings,
connections type ty_connections.

start-of-selection.

***************** suppressing the dialog box for print preview****************************
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = SPACE.
cparam-getotf = 'X'.

select single * from scustom into customer where id = p_custid.
check sy-subrc = 0.


select * from sbook into table bookings
where customid = p_custid
and carrid in s_carrid
order by primary key.

select * from spfli into table connections
for all entries in bookings
where carrid = bookings-carrid
and connid = bookings-connid
order by primary key.

call function 'SSF_FUNCTION_MODULE_NAME'
exporting formname = p_form
* 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.
exit.
endif.

* calling the generated function module
call function fm_name
exporting
* archive_index =
* archive_parameters =
control_parameters = cparam
* mail_appl_obj =
* mail_recipient =
* mail_sender =
output_options = outop
user_settings = SPACE
bookings = bookings
customer = customer
connections = connections
importing
* document_output_info =
job_output_info = tab_otf_data
* job_output_options =
exceptions formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.

if sy-subrc <> 0.
* error handling
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.


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.


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 = FILE_NAME
path = FILE_PATH
fullpath = 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.

*************downloading the converted PDF data to your local PC********

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = 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'
IMPORTING
filelength = file_size
TABLES
data_tab = 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.

ENDIF.

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos

HI ANJI..

your code is working..

now i am getting pdf file without print form..(its not possible take printout)..

suppose i want 3 cases like.

1. i want to see the output form

2. i want to take printout

3. i need a pdf file after executing

i am waiting for your replay...

thanks in advance

Former Member
0 Kudos

HI ANJI..

your code is working..

now i am getting pdf file without print form..(its not possible take printout)..

suppose i want 3 cases like.

1. i want to see the output form

2. i want to take printout

3. i need a pdf file after executing

I NEED A CODE FOR BOTH SAPSCRIPT AND SMARTFORM..

CAN YOU PLZ.............

i am waiting for your replay...

thanks in advance

Former Member
0 Kudos

Hi Nayan,

Yes you can save your smartform as a pdf.

1. Use FM CONVERT_OTF_2_PDF to convert smartform output (otf) to pdf. It will store converted data into an internal table.

2. Use FM GUI_DOWNLOAD to download that internal table on the presentation server as a pdf file.

Reward points if the answer is helpful.

Cheers,

Govind.