Introduction to
SMARTFORMS
Page 1 of 65
Bok Material on SmartForms Avidypta Guha
Table of Contents
INTRODUCTION
PURPOSE OF THIS INTRODUCTION............................................................................................................................................................3
WHO WILL BENEFIT..............................................................................................................................................................................3
PREREQUISITES....................................................................................................................................................................................3
SMART FORMS: WHAT IS IT?................................................................................................................................................................3
SmartForms Vs SAP Script.........................................................................................................................................................4
MAIN ADVANTAGES OF SMART FORMS:..................................................................................................................................................4
PAGES AND WINDOWS..............................................................................................................................................................12
Page 2 of 65
Bok Material on SmartForms Avidypta Guha
Introduction
Purpose of this Introduction
This introduction is intended to allow a quick entry into the work with the Smart Forms. SAP introduced
SmartForms in 1998 to overcome the limitations in SAP Scripts. This document would help a beginner to
start from scratch and generate his own Smart Forms. There is a self help screen sequence to guide the
beginners to create Smartforms of their own and gain confidence
Who will benefit
All SAP users. Most of the new projects would be using this technology. Clients would increasingly
demand smartforms to be used rather than sapscript.
Prerequisites
The user should know SAP Script. In this document I would briefly compare SAP script with SAP
SMART Forms, highlighting the prominent features before moving on to how to work with SMART
Forms, which is our focus.
SAP Script is SAP text management and form printing tool. By this we make a output look beautiful which
is cumbersome to do by a report program.
An editor for entering and editing text Styles and forms for designing the print layout
A programming interface for integrating SAPscript components in your own application programs
and programming the output using forms
NOTE WE can insert picture or Logo (Company Logo) in the output, which is not possible by report
program.
We use SAP Smart Forms to create and maintain forms for mass printing in SAP Systems. SmartForms are
easier to develop, maintain and transport than SAP Script.
Page 3 of 65
Bok Material on SmartForms Avidypta Guha
As output medium SAP Smart Forms support a printer, a fax, e-mail, or the Internet (by using the generated
XML output).In addition to the tool, SAP delivers a selection of forms for central business processes like
forms in the applications SD,FI, HR and CRM of the R/3 Release.
Multiple page formats are possible in smartforms which is not the case in SAPScripts
It is possible to have a smartform without a main window .
Labels cannot be created in smartforms.
Routines can be written in smartforms tool.
Smartforms generates a function module when activated.
The SAP Smart Forms has replaced the SAPscript forms. SAPscript forms will also be supported in the
future; you can use them without making any changes for years to come. You can use SAPscript texts in
the Smart Forms. Migration of SAPscript forms into Smart Forms is supported.
The smart forms allow the user to execute simple modifications to the form and in the form logic by
using simple graphical tools.
To print a form the user will need a program for the data retrieval and a smart form that contains the
entire form logic. As these two are separate we should adapt the smart form if changes to the form logic is
necessary. The application program passes the data via a function module interface to the smart form.
When activating the smart form the system automatically generates the function module and at the runtime
process this.
The user designs the form using the graphical form painter and the graphical table painter. The form
logic is represented by the hierarchical structure that consists of individual nodes, such as nodes for global
settings, nodes for texts, nodes for output tables or nodes for graphics. To make any changes we have to use
the Drag&Drop, Cut&Paste. These actions do not include writing of coding lines or using a script language.
For web publishing, the system provides a generated XML output of the processed form.
We can insert static and dynamic tables. These include the line feeds in the individual table cells,
triggering events for table headings and subtotals and sorting data before output.
The smart forms allow the user to include graphics, which can be displayed as a part of the form or as
background graphics. During printout the user can suppress the background graphic as and when necessary.
The smart forms also supports the postage optimizing.
Page 4 of 65
Bok Material on SmartForms Avidypta Guha
SMART
FORM
APPLICATION
PROGRAM
Activat
e
Data Retrieval
Function
Module
Database Call
Selection ABAP
FUNCTION
MODULE
Later
Selection
Database
Form Description
OUTPUT
(Printer)
Page 5 of 65
Bok Material on SmartForms Avidypta Guha
When a smart form is activated , the system generates a function module that encapsulates all the attributes
of the smart form.
As soon as the application program calls the function module, the smart form uses the module interface to
transfer any table data previously selected and to print the form according to the form description.
All these will become clearer once we go through the self help screen sequence in the subsequent pages.
Page 6 of 65
Bok Material on SmartForms Avidypta Guha
Hands On Guide: This is a self-help guide lucidly illustrated with tips, meant for beginners.
We first go to SAP Menu: The path is SAP Menu Tools Form Printout Smart Forms
The transaction code (T code) : Smart Forms
click
Lets use forms starting with ‘BC’ as SAP has created these for training purposes.
Page 7 of 65
Bok Material on SmartForms Avidypta Guha
click
We now arrive at the Display Form screen, which is divided, into 3 main sections:
Navigation window, Form painter and Maintenance window. We will discuss each of these in detail
Page 8 of 65
Bok Material on SmartForms Avidypta Guha
• Navigation window consist of nodes and sub nodes. They contain all the elements (text, window
etc) that belong to sap forms.
• Maintenance window shows attributes of the elements
• Form printer window shows the layout of the page.
Global setting is at the form level. You can access these from anywhere in the smart form
You can change the language by changing this field in Form Attribute: this will change the text
language (but not the layout).
SAPscript does not allow changing the language. SAP FORMS gives the user
NOTE this option.
Also whenever we create smart forms, SAP creates/generates a function module.
Form interface tells us what are the import and export parameters, exceptions, tables etc that we
Page 9 of 65
Bok Material on SmartForms Avidypta Guha
pass to the function module. These we can add but we cannot change/modify the default values
Lets add a Global Database for practice. I have created NUMC_DATE through TYPES
Page 10 of 65
Bok Material on SmartForms Avidypta Guha
Global definition is what we define in smart form. We can define our own variable, constants etc. that we
can access in the code that we write. Here we would use we of the types, which we have defined earlier
(char_fifteen) to declare ‘CLERK’.
What we created in
‘Types’ is being used to
declare a variable.
Page 11 of 65
Bok Material on SmartForms Avidypta Guha
Pages and Windows
In smart form, page is at the highest level: SAP processes the first page, next page and then Terms
General Terms and Conditions…if u wish to change the order, just drag and drop the sequence.
Conditional break…next page of next page become ‘term’ page (SAP stops processing /
execution of this page)
U can define print mode globally for all the pages instead of declaring this at each page
Page 13 of 65
Bok Material on SmartForms Avidypta Guha
Now lets create our own smart form Let’s copy a standard smart form [BC470_FLOWS]of SAP
and create ZBC470_FLOWS_AVID. Then we would play around with its different elements.
Page 14 of 65
Bok Material on SmartForms Avidypta Guha
Page 15 of 65
Bok Material on SmartForms Avidypta Guha
I have changed the sequence by dragging and drop. Now Test1 appears before the First Page.
For background picture and graphics you can pick up either black and white or color bitmap images and are
stored in the form of standard texts. We take a detour from the smartform screen and open Form Graphics
screen. Transaction code: Se78
Page 16 of 65
Bok Material on SmartForms Avidypta Guha
Here there are 3 options : Black and white, color and dynamic bitmap pictures. We name the background
picture and choose the determine dynamically option.
Page 17 of 65
Bok Material on SmartForms Avidypta Guha
Page 18 of 65
Bok Material on SmartForms Avidypta Guha
Now after the Page, we create a new Window. There will be output options, attributes and conditions in
each window.
Page 19 of 65
Bok Material on SmartForms Avidypta Guha
Cannot use main in this field because SAP creates Main by default and doesn’t allow main as name.
We cannot have more than 1 main window in a page. We can have multiple
secondary windows
Whatever u print in secondary window…it has to be static. (If u have 20 lines in
a PO and there is page constraint the lines get carried forward to next page in the
NOTE main window. i.e. In a predecessor and successor type of content, they will be
printed in sequence in main window. This is not allowed in Secondary windows.
Page 20 of 65
Bok Material on SmartForms Avidypta Guha
You can have only we main page which u can stretch to multiple pages (you can copy and stretch it) but
you can have multiple secondary windows.
Inside the main window we can add text as introduction to customize the form output. In Smart Form
what you see is what you get.
Page 21 of 65
Bok Material on SmartForms Avidypta Guha
In the output, we have the option of sizing and positioning the main window along with different
shading and color choices.
Page 22 of 65
Bok Material on SmartForms Avidypta Guha
We can have conditions….to be executed at run time We take an example to illustrate this.
Page 23 of 65
Bok Material on SmartForms Avidypta Guha
Now we come to the last part of the Pages and Window Section i.e. the Address element.
Note: CAM = Central Address Management
e.g. Based on the country, we may take country specific format (e.g. in US the ZIP code is must, while
in India it is not a mandatory field.)
Page 24 of 65
Bok Material on SmartForms Avidypta Guha
Lets create a new address. It can be of 4 types: Personal, Official, Organization address or it may be
determined during runtime based on the selection parameter (Dynamically determined).
U need to find address number only and everything else will be populated
The attributes could be of 3 types: Text element, Include Text and Text module
We would then fill up text name: static or dynamic, text object (e.g. TEXT) and text id (e.g. ADRS)
Page 25 of 65
Bok Material on SmartForms Avidypta Guha
Page 26 of 65
Bok Material on SmartForms Avidypta Guha
we can use the System Fields in Data Dictionary table SFSY compwents while writing
the logic for Smartform
Lets add a new text element ‘TXT1’ choosing appropiate paragraph and character formats.
Page 27 of 65
Bok Material on SmartForms Avidypta Guha
We can have our own smart style : paragraph as well as character formats. Lets check out a standard
style before creating our own!
The header data in each smart style allows us to configure font size, line and character spacing.
Page 28 of 65
Bok Material on SmartForms Avidypta Guha
SAP provides different paragraph formats for standard, header and footer, centered and totals.
Page 29 of 65
Bok Material on SmartForms Avidypta Guha
Now it comes in the form as the menu of Paragraph Formats in the SAP Smart Form.
Note : AV has come in the menu. Alignment is as per the paragraph format AV.
Page 30 of 65
Bok Material on SmartForms Avidypta Guha
The newly created paragraph font (e.g. AV) won’t be part of global settings. If
we change the form attribute - output options-- and style to some other
NOTE style (like from BC470 to BC 470_STYLS) this option would no longer be
there.
Lets create a new style (ZBC470_avi) with 2 paragraph formats and we character format
Page 31 of 65
Bok Material on SmartForms Avidypta Guha
Now I mention in form attribute my own style
Page 32 of 65
Bok Material on SmartForms Avidypta Guha
When you create a table, SAP automatically creates 3 areas: Header, Main and Footer. In Main Area,
there are many cells, which are processed record by record.
Click
Page 33 of 65
Bok Material on SmartForms Avidypta Guha
In Main Area, we create different cells. In Table painter, we draw the format as per client requirement (e.g.
Heading, Sub Heading, Item, Sub Total, Grand Total etc.)
We use the table layout to determine:
• The number of lines and cells
• The height of each line
• The width of each cell
• The alignment of the table in the window
• Whether and where to display separator lines or frames
We can either draw the table by visual aid or we can click on details button and set the area allotted to each
cell by filling in the measurements.
Click
Page 34 of 65
Bok Material on SmartForms Avidypta Guha
In Data Painter, we can process the data before displaying it in SMARTFORM. SAP provides us with
the option of putting some basic logic. E.g. Loop, Where condition, Option of Row-by-Row selection,
Sort Condition, At the end of table processing: Events (provided by SAP).
Page 35 of 65
Bok Material on SmartForms Avidypta Guha
For easy navigation and access, SMARTFORM provides Field List option. We can activate that by
Utilities- Field List on/off.
We can put conditions/logic by putting ABAP code inside ‘bookings’ main area, Program Lines. Here
we first declare the input and output parameters.
Page 36 of 65
Bok Material on SmartForms Avidypta Guha
Here we put the text element as per paragraph and character format. We may have a text which is
determined during run time (dynamic).
Page 37 of 65
Bok Material on SmartForms Avidypta Guha
Now lets create our own table. Here we can put logic as per client requirement.
TEMPLATE: Template is used when we know the exact size of the output or
the output is in a fixed format. E.g. Tax form/ cheques /airline form/railway
ticket: all these use templates.
NOTE Diff between table and template: In Table the height changes dynamically.
We call a row a ‘line’ in template.
Page 38 of 65
Bok Material on SmartForms Avidypta Guha
Whenever you wish to write your code in SAP Smartform, you have to create the proper flow logic. We use
‘command’ to code any conditions for going to the next page
Page 39 of 65
Bok Material on SmartForms Avidypta Guha
This is to terminate the current page and start processing the new page.
Page 40 of 65
Bok Material on SmartForms Avidypta Guha
In Smartform, We can process our own logic. We can call some table, select some data do standard data
manipulations through this. In navigation wndow, First Page-- Main Window -- Create -- Flow
Logic -- Program line. But it is advisable not to write programs here as it slows down the process. It is
advisable to write the code in print program.
This is very similar to table. If you wish to dynamically determine the output, we can loop at internal table
Page 41 of 65
Bok Material on SmartForms Avidypta Guha
Flow Logic: Alternative: In this we can embed ‘If - else’ kind of logic.
Page 42 of 65
Bok Material on SmartForms Avidypta Guha
If what we type here is True then it will get processed under the True button.
We next explore another feature of Smartform: Folder
Page 43 of 65
Bok Material on SmartForms Avidypta Guha
Folder is used to modularize the navigation; it has nothing to do with technical thing. The order you
mention in the folder is the order that SAP will process.
There is an option given in Smartforms. We can migrate old SAPscripts to smartforms.
Note: We should check the text elements and make sure the flow logic works in the new format.
Page 45 of 65
Bok Material on SmartForms Avidypta Guha
In Function Module screen, (se37)
To get the function module name, after saving and activating the form, go to Environment – function
module name. This function module name has to be given in the main program to call the form.
Else go to function module SSF_FUNCTION_MODULE_NAME and give the name of the program.
In the print program mentiwed below, populating certain fields from database tables into it creates an
output internal table. Once the output internal table is ready, then the function module
SSF_FUNCTION_MODULE_NAME is called. Here, in the import parameters, the name of the smart
form is given. The output of this function module is the name of another function module.
This function module is again called, in this example, the name of the function module is
"/1BCDWB/SF00000007”.
So, in case of smart forms, we use 2 function modules for the processing of the smart form. Once this
internal table is thrown from the smart form, then in the layout, the required fields can be displayed.
Page 46 of 65
Bok Material on SmartForms Avidypta Guha
Page 47 of 65
Bok Material on SmartForms Avidypta Guha
we have to mention this name (of function module) in the print program.
Page 48 of 65
Bok Material on SmartForms Avidypta Guha
This calls the SAP Smart form. We are checking the output in Monocolour.
Page 49 of 65
Bok Material on SmartForms Avidypta Guha
Page 50 of 65
Bok Material on SmartForms Avidypta Guha
SE37: We use the just created function module. /1BCDWB/SF00000007. We execute this.
Page 51 of 65
Bok Material on SmartForms Avidypta Guha
CHECK PRINT
PREVIEW
Page 52 of 65
Bok Material on SmartForms Avidypta Guha
We can set the background of the output as any file stored in our hard disk. We can call a graphics from
desktop or any other pic stored in the hard disk. Transaction code: SE78
Page 53 of 65
Bok Material on SmartForms Avidypta Guha
Now let us delve in to configuration settings to modify our smartform as per requirement.
Creating output type and assigning smart form name in spro
Spro –> materials mgt –> purchasing —> messages —> output control –> message types –> define
message types for Purchase order.
Page 54 of 65
Bok Material on SmartForms Avidypta Guha
We can create our own message type. We can define various options like transmission medium here like
Print, Fax, EDI etc.
Page 55 of 65
Bok Material on SmartForms Avidypta Guha
Select we output type and double click on processing routine to get the following screen. It will execute the
print program as soon as we call ‘neu’ message type. In the above screen, we can mention the name of the
smart form for that output type. Once this is dwe we can mention the output type in the purchase order
me22n: Lets take an existing P.O.
Click
Page 56 of 65
Bok Material on SmartForms Avidypta Guha
Page 57 of 65
Bok Material on SmartForms Avidypta Guha
Smart forms is very similar to SAP scripts. This is also a tool, which is extensively used to create
layouts, and then a separate print program is created. This print program is used to create the output internal
table, which in turn is thrown to the smart form where the field values are displayed.
SAP Smartforms can be used for creating and maintaining forms for mass printing in SAP Systems. The
output medium for Smartforms support printer, fax, e-mail, or the Internet (by using the generated XML
output).
These are the steps to create your own smartform:
Global definitions
Variable name Type assignment Reference type
ITAB2 TYPE Table Structure
Page 58 of 65
Bok Material on SmartForms Avidypta Guha
5. Calling SMARTFORMS from your ABAP program
REPORT ZSMARTFORM.
* Calling SMARTFORMS from your ABAP program.
* Collecting all the table data in your program, and pass once to SMARTFORMS
* SMARTFORMS
* Declare your table type in :-
* Global Settings -> Form Interface
* Global Definintions -> Global Data
* Main Window -> Table -> DATA
*
* Written by : SAP Hints and Tips on Configuration and ABAP/4 Programming
* http://sapr3.tripod.com
*
TABLES: MKPF.
DATA: FM_NAME TYPE RS38L_FNAM.
DATA: BEGIN OF INT_MKPF OCCURS 0.
INCLUDE STRUCTURE MKPF.
DATA: END OF INT_MKPF.
SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.
SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.
MOVE-CORRESPONDING MKPF TO INT_MKPF.
APPEND INT_MKPF.
ENDSELECT.
* At the end of your program.
* Passing data to SMARTFORMS
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZSMARTFORM'
* VARIANT =''
* DIRECT_CALL =''
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM =1
NO_FUNCTION_MODULE =2
OTHERS = 3.
if sy-subrc <> 0.
WRITE: / 'ERROR 1'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function FM_NAME
* EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
* CONTROL_PARAMETERS =
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
Page 59 of 65
Bok Material on SmartForms Avidypta Guha
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
TABLES
GS_MKPF = INT_MKPF
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.
Form Logic
In the form builder we can describe a smart form by a set of nodes. To do this, we can build up a tree
structure on the left side of the user interface.
The node global settings and its three successors form attributes, form interface and global definitions
always exists for any newly created forms.
Page 60 of 65
Bok Material on SmartForms Avidypta Guha
To describe the form logic, create the hierarchy under the node pages and windows.
The following rules apply to control the flow of the form output.
The nodes in the tree structure are processed from top to bottom.
For each node there is a tab, this can be used to link the node to a condition. If the condition is
true, the system processes the node. If not, it skips the node and all its successors.
We should define a next page for each page.
The PC Editor:
The pc editor offers the following functions:
Enter, delete, select, cut and copy texts.
Assign paragraph and character formats.
Include, change and delete fields.
Style builder:
On the left of the style builder screen consists of the predetermined nodes (header data, folder for
paragraph formats, folder for character formats).
Page 61 of 65
Bok Material on SmartForms Avidypta Guha
On the right we can see the maintenance screen with its tab pages. At the bottom the preview of the
selected font can be viewed.
Node types:
When a form is created, the tree structure of the form painter contains two root nodes.
The successors of the global settings node are used to maintain form attributes, the form
interface and global definitions.
The successors of the pages and windows node to create the pages of the form, position elements
on these pages, and determine the sequence on how to process these created elements.
Creating windows:
We can set the size and position of the window graphically in the form painter. There are main windows
and subwindows. The difference between these two is that the output in a main window can cover several
pages.
Open the context menu for an existing page node and choose→window
Enter a name for the node and a description
On the general attributes indicate whether the window is a main window. If sub window wants to
be created then leave the checkbox empty
Page 62 of 65
Bok Material on SmartForms Avidypta Guha
There are three text types:
Text element : to enter new text in the PC editor
Text module : to include a text module
Include text : to include an existing SAPscript text
Inserting addresses:
We can use the address node to insert an address into the form. This guarantees that the address is
formatted according to the postal rules of the sender country.
To create an address node , call the context menu for that node in the tree structure that we
wants to contain the text and choose create->text
Enter a name for the node and a description
Determine the address type on the general attributes tab
For organizational addresses we have to specify the address number, for any other we have to
specify the person number and the address number
In the box additional addresses we can maintain other attributes to specify how to display the
address
Printing graphics:
Goto tcode se78 to import graphics into the SAP system. The transaction imports the graphics and
stores it in the BDS (business transaction server) and then it can be displayed in the form.
Page 63 of 65
Bok Material on SmartForms Avidypta Guha
To create the graphic node , call the context menu for that node in the tree structure and
choose create->graphic
Enter a name for the node and the description
On the general attributes determine whether a colored or a black and white
Use the fields object , id and name to identify the graphic
Displaying a static table
Use node type template to display a table whose layout and size is determined before the runtime of the
print program.
To create a template define a table layout to determine the cell structure for each line. The cells are
used to display the cell structure for each line. The cells are used to display the contents of the
successor nodes of the template node. This allows us to position text and a graphic side by side.
The template node is also used for label printing. To use a template we must do the following:
Define the table layout
Display the contents in the table cells
Combining nodes:
The more extensive the form becomes, the lesser clear becomes the node hierarchy in the tree structure.
To avoid this we can combine the related nodes by appending them under a folder node.
llet" style="margin-left:1.75in;text-indent:-.25in;mso-list:l8 level1 lfo23; tab-stops:list 1.75in">
The width of each cell
The alignment of the table in the window
Whether and where to display separator lines or frames
Create a template node and maintain the attributes width, horizontal alignment and vertical alignment.
Use the table control on the template tab to define the layout of the lines. Each line of the template must
have a definition.
Use the pattern box to select the desired table pattern.
Combining nodes:
The more extensive the form becomes, the lesser clear becomes the node hierarchy in the tree structure. To
avoid this we can combine the related nodes by appending them under a folder node.
Page 64 of 65
Bok Material on SmartForms Avidypta Guha
Acknowledgements
Satish Suri
Mohan Motiani
Rajneesh Chauhan
Tathagata Sengupta
SAP Help Documents
All team members of Syngenta
I need your feedback and suggestions for further enriching this document for all of us to benefit. Thanks!
Page 65 of 65