Академический Документы
Профессиональный Документы
Культура Документы
Applies to:
SAP R/3 4.6C – ABAP / SMARTFORMS
Summary
This program code would help those who want to combine multiple smartform outputs into a single OTF
output and then to download them as a single PDF file in your local PC.
© 2006 SAP AG 1
Table of Contents
Procedure ........................................................................................................................................................................ 2
Sample Code................................................................................................................................................................... 4
Procedure
The Function Module generated by the system when you activate the Smartform is obtained by the Function
Module SSF_FUNCTION_MODULE_NAME and the data to be passed to the smartform is sent by calling
this FM. In this FM, we’ll set the GETOTF field of the CONTROL_PARAMETERS parameter. This FM would
import the details of the Smartform into a parameter JOB_OUTPUT_INFO, which is of type SSFCRESCL.
SSFCRESCL contains a field OTFDATA, which is a table type of ITCOO containing the OTF equivalent of
the Smartform output. ITCOO has two fields TDPRINTCOM, which is the command ID and TDPRINTPAR,
which is the print parameter.
© 2006 SAP AG 2
A sample content of the OTF table is given below.
For every Smartform output in its OTF equivalent, TDPRINTCOM begins and ends with ‘//’. So the final OTF
table that should be sent as PDF output should contain only one pair of ‘//’ to mark the beginning and end of
the table. TDPRINTCOM value for end-of-page will be ‘EP’. So if you want to combine multiple Smartforms
into one OTF table, the beginning and end markers (‘//’) for subsequent smartforms should be removed and
appended after ‘EP’ command in the OTF table.
Here is the sample content of OTF table, which contains the output of two Smartforms.
© 2006 SAP AG 3
Similarly we can append multiple smartform outputs to one OTF table and then use the Function Module
CONVERT_OTF to convert the OTF data to PDF data and then you can use the Function Module
GUI_DOWNLOAD to download the PDF data to your local file.
Sample Code.
REPORT yshail_smartform1_new .
****************************DECLARATIONS********************************
TABLES: zshail_t1,sflight.
© 2006 SAP AG 4
itab LIKE TABLE OF zshail_t1 WITH HEADER LINE,
otab TYPE TABLE OF sflight WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE.
start-of-selection.
© 2006 SAP AG 5
ENDIF.
SELECT carrid connid fldate price FROM sflight INTO CORRESPONDING FIELDS
OF TABLE otab.
© 2006 SAP AG 6
***removing the initial and final markers from the OTF data**********
DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.
************ appending the modified OTF table to the final OTF table****
INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.
© 2006 SAP AG 7
* 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
.
© 2006 SAP AG 8
Screenshot of the output PDF file
First smartform output
© 2006 SAP AG 9
Second Smartform output
SAP will not be held liable for any damages caused by using or misusing the information, code or methods
suggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of
this technical article or code sample, including any liability resulting from incompatibility between the content
© 2006 SAP AG 10
within this document and the materials and services offered by SAP. You agree that you will not hold, or
seek to hold, SAP responsible or liable with respect to the content of this document.
Author Bio
© 2006 SAP AG 11