cancel
Showing results for 
Search instead for 
Did you mean: 

hi have to covert a smart form into pdf file format when we execute report

Former Member
0 Kudos

Hi Experts,

i have a reqirement ,when i execute a report smartform need 's to be converted

into pdf file format.

please reply ur solutions for it.

Thanks in Advance.

Regards,

Hitu

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member223537
Active Contributor
0 Kudos

Hi,

Please refer this program which is as per your requirement.

Best regards,

Prashant

Former Member
0 Kudos

Step 1: To convert SmartForm output to PDF

Smart Forms does not support direct output in PDF format. Instead, the OTF output has to be converted to PDF. The function module generated by the SmartForm has to be supplied with Control Structure parameters that will export the SmartForm output to OTF format. The Output Text Format (OTF) is the established SAP output format for printing forms. It consists of a number of simple, device-independent commands, thus allowing output to be directed to different output devices such as line printers and laser printers, or as an on-screen print preview. OTF is an explicit output format, which means that once SAP Smart Forms has generated an OTF output, no modifications can be made.

OTF:

OTF is not a document; it is a format in which data becomes available after it is templated by a Script or Smartform. The SmartForm takes the data you have passed to it, formats it according to the output settings, layout, page size, styles etc. and then forwards it to it's intended destination which is normally a print device. Since SmartForm output is not necessarily targeted at print output, R/3 allows you to alternatively collect the formatted results of the SmartForm(or SAPScript) and use this data for other purposes, like creating a DOC(MS Word) file, create a PDF file, send mail etc. The standard format used after generation and formatting of SmartForm output is known as OTF.

The procedure for the form to be returned as a table in OTF format is as follows:

1. Define a structure of type SSFCTRLOP (control structure, standard parameter CONTROL_PARAMETERS) and another structure of type SSFCRESCL (to contain the output results, standard parameter JOB_OUTPUT_INFO):

DATA: my_control_pars TYPE ssfctrlop. "For CONTROL_PARAMETERS

DATA: my_output_info TYPE ssfcrescl. "For JOB_OUTPUT_INFO

2. To deactivate the dialogs and to inform SAP Smart Forms that you only want the OTF table to be returned, set the parameters NO_DIALOG and GETOTF of the control structure:

my_control_pars-no_dialog = 'X'.

my_control_pars-getotf = 'X'.

3. Pass both structures in the call of the generated function module.

Now access the OTF table in the formal parameter JOB_OUTPUT_INFO using the OTFDATA parameter of your structure.

4. Get the OTF output from table OTFDATA of the standard parameter JOB_OUTPUT_INFO.

5. To convert the OTF output to PDF, transfer the OTF table to the function module CONVERT_OTF. To do this, set the parameter FORMAT to 'PDF'. The output can be returned either as a binary string (parameter BIN_FILE) or as a character table (parameter LINES). SAP recommends the first variant.

You can then store the PDF output using the function module GUI_DOWNLOAD, for example, as a local file on your PC.

Function Module : Convert_OTF

CALL FUNCTION "CONVERT_OTF"

EXPORTING FORMAT = "PDF"

IMPORTING BIN_FILESIZE = FILE_LEN

TABLES OTF = OTFDATA

LINES = PDFDATA

EXCEPTIONS ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

OTHERS = 4.

Step 2: Sending PDF document as an attachment by mail.

You have to create variables/structure/table of the following type.

1) Data of an object which can be changed.

2) Description of Imported Object Components.

3) Single List with Column Length 255.

4) Structure of the API Recipient List.

When the data is converted into the PDF format from OTF (Function Module Convert_OTF), it is stored in an internal table, which has a similar structure as Text Lines (TLINE). Let this internal table name be LT_PDFDATA. Hence any operation that is to be performed on the data, this table is taken into consideration.

Following steps have to be followed to send the PDF as an attachment.

1) Conversion of the content in LT_PDFDATA in binary format.

The table LT_PDFDATA has two columns. Convert the entire table into a single line and replace all the space with a special character (say ~).

Then convert the entire string into lines of size 255 characters, and store it in an internal table (OBJBIN).

2) Create Receivers List.

This table will contain the receiver name and receiver type(Internet Address, Remote SAP, etc.).

3) Create Message body, Title, and Description.

4) Create Message Attachment.

Function Module Used :

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOCDATA

PUT_IN_OUTBOX = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST.

I hope it helps.

Best Regards,

Vibha

<b>*Please mark all the useful answers</b>