You are on page 1of 16

Smart forms

Written by Jasmeet Singh Malhotra Jasmeet.malhotra@wipro.com Reviewed by Charitha Kolla Charitha.kolla@wipro.com

Wipro Technologies

Smart Form technology allows to design print forms. ABAP programs have to "call" them so that spools are generated, ready to be printed. SMARTFORMS is the transaction to design the smart form layout.

It is possible to embed texts, images, tables, barcodes. Importing parameters have to be defined so that an ABAP program can send the data to be printed. When the smart form is activated, a function module is generated that an ABAP program has to call. You should never assume the name of this function module as it may change in each system after import. See below how to do.

SMARTSTYLES transaction allows to define paragraph and character formats (fonts, barcodes, etc.) Though ABAP code can be entered in the Smart Form, it is best to not do it, and make the calling ABAP program pass all data via parameters. This will ease the conversion into Interactive Forms By Adobe. The only ABAP code that needs to remain in the Smart Form is the part which handles page break processing (sub-totals and so on). Smart Form technology has replaced SAPscript technology since release 4.6C, and has been superseded by Interactive Forms by Adobe since release 6.40.

Smart Form layout


Parameters and variables can be printed using the SAP script principle (ampersands around the variable name in the text nodes: &VARNAME&)

Calling the Smart Form from the ABAP program


ABAP program has to perform the following general steps:

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' o It is used to get the generated function module corresponding to the smart form (when the smart form is activated) CALL FUNCTION 'SSF_OPEN' (*): opens the spool CALL FUNCTION l_generatedfunctionmodule o There are 2 parameters CONTROL_PARAMETERS-NO_OPEN and CONTROL_PARAMETERS-NO_CLOSE that you must set to 'X'

Wipro Technologies

You may call it several times (and even call different Smart Forms) so that several forms are stored in the same spool. It may also be used to share the same page counter. o Note: unlike SAPscripts, Smart Form has to be called once to be entirely printed. CALL FUNCTION 'SSF_CLOSE' (*): closes the spool
o

(*) It is also possible to not call SSF_OPEN and SSF_CLOSE: by default, a call to the generated function module will open and close the spool.

Smart forms global settings


Goto transaction SMARTFORMS.Give a name to your form ,with naming convension Y or Z.Press CREATE button. This will take you to SAP form builder screen.In the right hand side you can see a tree structure which contains 1) Global settings 2) Pages and windows which are automaticaly created. 1) Global settings node consists of a) Form Attributes b) Form Interface c) Global Definitions 2) Pages and windows node consists of a) First page b) Main window which are automaticaly created. * In FORM ATTRIBUTES you have two tab pages 1) General Attributes 2) Output options

Wipro Technologies

1) General Attributes will display the Created by and Changed by Created date and Changed date Created time and Changed time and the package to which the form is assigned

Wipro Technologies

In the language attributes of the form ,it shows the current language,in this case EN. * In the TRANSLATE selection block there are three radio buttons for the translation of the form. a) First radio-button will allow you to translate the form to all languages. b) Second radio-button will give you an option to select languages .The arrow button on the right hand side of this radio-button will give you a wide range of languages to select, which are supported by SAP. c) The third radio-button will cancel the option of translation. 2) In the tabpage OUTPUT OPTIONS you can specify the Page format, Characters per inch, Lines per inch,Style and output format. * In FORM INTERFACE you have four tabpages .

Wipro Technologies

IMPORT Parameters that has to be imported to the form function module. EXPORT Parameters that are to be exported from the form function module. TABLES Parameters that is used to pass internal tables form the driver program. EXCEPTIONS Exceptions that are created in the function module.

Wipro Technologies

All the parameters that are defined in the form interface will be displayed as parameters in the form function module. * In GLOBAL DEFINITIONS you can define global variables, types, field symbols, etc. That are global to the form .

Wipro Technologies

How to get the function module name automatically in the driver program? WITH EXAMPLE.
1 ) Create a parameter for the form name of type TDSFNAM. In the example - p_form is the parameter. In this parameter you can give the name of the form for which you need to call the function module. TDSFNAM is a data element ,whose domain contains the value table STXFADM. STXFADM is a table for SMART FORM administration.

Wipro Technologies

Wipro Technologies

Wipro Technologies

10

2 ) Create a data element(In example w_fm) of type rs38l_fnam to get the function module name. RS38L is a structure that contains Screen fields of the Transaction UNIT. 3 ) t_itab is the internal table that you can use to pass data to the FORM. (In the example it has to be of type SFLIGHT.)

Wipro Technologies

11

By the function module SSF_FUNCTION_MODULE_NAME you can export the formname using EXPORTING parameter FORMNAME and you can import the function module name using IMPORTING parameter FM_NAME. This importing parameter will pass the name of the function module to dataelement w_fm. Now using w_fm you can call the FORM function module.
&--------------------------------------------------------------------*& Report ZSMART1 *& &--------------------------------------------------------------------REPORT zsmart1. PARAMETERS: p_form TYPE tdsfname. DATA: t_itab LIKE TABLE OF sflight. DATA: w_fm TYPE rs38l_fnam. * Get data SELECT * FROM sflight INTO TABLE t_itab. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = p_form IMPORTING fm_name = w_fm 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 symsgv2 sy-msgv3 sy-msgv4. ENDIF. * now call the generated function module CALL FUNCTION w_fm EXPORTING user_settings = 'X' TABLES itab = t_itab 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 symsgv2 sy-msgv3 sy-msgv4. ENDIF.

Wipro Technologies

12

How to add graphics dynamically in SMART FORMS ?


Your requirment is to determine the graphic of the form dynamically through driver program. It doesn't mean that you can dynamically define a LOGO, in fact you can only define whether the logo is Black and White or a Colored. Step 1. In the form painter's FORM INTERFACE declare a variable of type character.You will receive this variable as export parameter of the function module created by the form in your driver program .

Wipro Technologies

13

Step 2. In the window where you have to display the graphic ,create a graphic node. In the general attributes of this node specify the name of the graphic you need to display. Select the radio-button DETERMINE DYNAMICALLY (BMON, BCOL) and specify the variable you have created in the FORM INTERFACE ,with in '&' sign.

Wipro Technologies

14

Note:Not all the logos will be in the COLORED format .So you have to select the logo accordingly. Otherwise when you execute your driver program you will get an ERROR message (GRAPHIC CANNOT BE DISPLAYED).

Step 3. In the driver program call the FORM function module and pass the parameters

Wipro Technologies

15

accordingly.
REPORT zsmart1. PARAMETERS: p_form TYPE tdsfname. DATA: t_itab LIKE TABLE OF sflight. DATA: w_fm TYPE rs38l_fnam. SELECT * FROM sflight INTO TABLE t_itab. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = p_form IMPORTING fm_name = w_fm 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 symsgv2 sy-msgv3 sy-msgv4. ENDIF. CALL FUNCTION w_fm EXPORTING user_settings = 'X' symbol = 'BCOL' "<=== PARAMETER ADDED TABLES itab = t_itab 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 symsgv2 sy-msgv3 sy-msgv4. ENDIF.

Wipro Technologies

16

You might also like