Beruflich Dokumente
Kultur Dokumente
SMARTFORMS
Page 1 of 61
Table of Contents
INTRODUCTION
PURPOSE OF THIS INTRODUCTION.
WHO WILL BENEFIT.
PREREQUISITES
REFRESHER ON SAPSCRIPT
SMART FORMS: WHAT IS IT?
SMARTFORMS VS SAP SCRIPT
MAIN ADVANTAGES OF SMART FORMS
FEATURES INTRODUCED BY SAP IN SMART FORMS
ARCHITECTURE OF SAP SMARTFORM
HANDS ON SCREEN SEQUENCE
SMARTFORMS..
PAGE AND WINDOWS
SMARTSTYLE
TEMPLATE
CONFIG SETTING...
REFRESHER ON SMARTFORMS : SUMMARY
Page 2 of 61
3
3
3
3
3
4
4
4
5
7
12
28
38
54
58
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.
Refresher on SAP Script
SAP Script is SAP text management and form printing tool. By this we make an output look beautiful
which is cumbersome to do by a report program.
SAPscript consists of the following components:
An editor for entering and editing text Styles and forms for designing the print layout
A composer, which is the central module for output formatting
A programming interface for integrating SAPscript components in your own application programs
and programming the output using forms
Various database tables for storing texts, styles and forms
NOTE
WE
WE can
can insert
insert picture
picture or
or Logo
Logo (Company
(Company Logo)
Logo) in
in the
the output,
output, which
which is
is not
not possible
possible by
by report
report
program.
program.
Page 4 of 61
SMART
SMART
FORM
FORM
APPLICATION
PROGRAM
Activat
e
Database
Selection
Function
Module
Call
ABAP
FUNCTION
MODULE
Later
Selection
Database
Form Description
OUTPUT
OUTPUT
(Printer)
(Printer)
Page 5 of 61
Page 6 of 61
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 61
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
Navigation window consist of nodes and sub nodes. They contain all the elements (text, window
etc) that belong to sap forms.
Page 8 of 61
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).
NOTE
SAPscript
SAPscript does
does not
not allow
allow changing
changing the
the language.
language. SAP
SAP FORMS
FORMS gives
gives the
the user
user
this
this option.
option.
Also
Also whenever
whenever we
we create
create smart
smart forms,
forms, SAP
SAP creates/generates
creates/generates aa function
function module.
module.
Form interface tells us what are the import and export parameters, exceptions, tables etc that we
pass to the function module. These we can add but we cannot change/modify the default values
Page 9 of 61
Lets add a Global Database for practice. I have created NUMC_DATE through TYPES
Page 10 of 61
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.
1 OF 10 ETC
Conditional breaknext 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 61
Now lets create our own smart form Lets 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 61
I have changed the sequence by dragging and drop. Now Test1 appears before the First Page.
NOTE
Printing
Printing will
will take
take place
place on
on the
the basis
basis of
of next
next page
pagefield.
field.
Page
15the
of sequence
61
But
processing
will
happen
as
per
in
navigation
But processing will happen as per the sequence in navigation window!
window!
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 61
Here there are 3 options : Black and white, color and dynamic bitmap pictures. We name the background
picture and choose the determine dynamically option.
Now after the Page, we create a new Window. There will be output options, attributes and conditions in
each window.
Page 18 of 61
Cannot use main in this field because SAP creates Main by default and doesnt allow main as name.
NOTE
We
We cannot
cannot have
have more
more than
than 11 main
main window
window in
in aa page.
page. We
We can
can have
have multiple
multiple
secondary
windows
secondary windows
Whatever
Whatever uu print
print in
in secondary
secondary windowit
windowit has
has to
to be
be static.
static. (If
(If uu have
have 20
20 lines
lines in
in
aa PO
PO and
and there
there is
is page
page constraint
constraint the
the lines
lines get
get carried
carried forward
forward to
to next
next page
page in
in the
the
main
main window.
window. i.e.
i.e. In
In aa predecessor
predecessor and
and successor
successor type
type of
of content,
content, they
they will
will be
be
printed
printed in
in sequence
sequence in
in main
main window.
window. This
This is
is not
not allowed
allowed in
in Secondary
Secondary windows.
windows.
Page 19 of 61
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 20 of 61
In the output, we have the option of sizing and positioning the main window along with different
shading and color choices.
We can have conditions.to be executed at run time We take an example to illustrate this.
Page 21 of 61
Page 22 of 61
NOTE
Some
Some practical
practical examples
examples of
of conditions
conditions in
in aa window
window in
in Form
Form could
could be
be that,
that, on
on the
the
first
page,
we
want
the
Company
Logo
and
address
of
customer
but
on
first page, we want the Company Logo and address of customer but on
subsequent
subsequent pages
pages we
we dont
dont want
want customer
customer address.
address. Similarly
Similarly we
we may
may wish
wish to
to
have
have signature
signature only
only at
at the
the last
last page.
page. Appropriate
Appropriate conditions/flow
conditions/flow logic
logic can
can be
be
inserted
inserted here
here to
to take
take care
care of
of these
these situations.
situations. We
We can
can give
give flow
flow logic
logic for
for both
both
main
main and
and secondary
secondary windows.
windows.
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 23 of 61
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 24 of 61
Page 25 of 61
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 26 of 61
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.
SAP provides different paragraph formats for standard, header and footer, centered and totals.
Page 27 of 61
Page 28 of 61
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 29 of 61
NOTE
The
The newly
newly created
created paragraph
paragraph font
font (e.g.
(e.g. AV)
AV) wont
wont be
be part
part of
of global
global settings.
settings. If
If
we
change
the
form
attribute
-
output
options--
and
style
to
some
other
we change the form attribute - output options-- and style to some other
style
style (like
(like from
from BC470
BC470 to
to BC
BC 470_STYLS)
470_STYLS) this
this option
option would
would no
no longer
longer be
be
there.
there.
Lets create a new style (ZBC470_avi) with 2 paragraph formats and we character format
Page 30 of 61
Page 31 of 61
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
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.
Page 32 of 61
Click
Page 33 of 61
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 34 of 61
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 35 of 61
Here we put the text element as per paragraph and character format. We may have a text which is
determined during run time (dynamic).
Now lets create our own table. Here we can put logic as per client requirement.
Page 36 of 61
NOTE
TEMPLATE:
TEMPLATE: Template
Template is
is used
used when
when we
we know
know the
the exact
exact size
size of
of the
the output
output or
or
the
the output
output is
is in
in aa fixed
fixed format.
format. E.g.
E.g. Tax
Tax form/
form/ cheques
cheques /airline
/airline form/railway
form/railway
ticket:
ticket: all
all these
these use
use templates.
templates.
Diff
Diff between
between table
table and
and template:
template: In
In Table
Table the
the height
height changes
changes dynamically.
dynamically.
We
call
a
row
a
line
in
template.
We call a row a line in template.
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 37 of 61
This is to terminate the current page and start processing the new page.
Page 38 of 61
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 39 of 61
Page 40 of 61
If what we type here is True then it will get processed under the True button.
We next explore another feature of Smartform: Folder
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.
Page 41 of 61
Page 42 of 61
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
In the
the print
print program
program mentiwed
mentiwed below,
below, populating
populating certain
certain fields
fields from
from database
database tables
tables into
into itit creates
creates an
an
output
internal
table.
Once
the
output
internal
table
is
ready,
then
the
function
module
output internal table. Once the output internal table is ready, then the function module
SSF_FUNCTION_MODULE_NAME
SSF_FUNCTION_MODULE_NAME is
is called.
called. Here,
Here, in
in the
the import
import parameters,
parameters, the
the name
name of
of the
the smart
smart
form
is
given.
The
output
of
this
function
module
is
the
name
of
another
function
module.
form is given. The output of this function module is the name of another function module.
This
This function
function module
module is
is again
again called,
called, in
in this
this example,
example, the
the name
name of
of the
the function
function module
module is
is
"/1BCDWB/SF00000007.
"/1BCDWB/SF00000007.
So,
So, in
in case
case of
of smart
smart forms,
forms, we
we use
use 22 function
function modules
modules for
for the
the processing
processing of
of the
the smart
smart form.
form. Once
Once this
this
internal
internal table
table is
is thrown
thrown from
from the
the smart
smart form,
form, then
then in
in the
the layout,
layout, the
the required
required fields
fields can
can be
be displayed.
displayed.
CALL
CALL FUNCTION
FUNCTION 'SSF_FUNCTION_MODULE_NAME'
'SSF_FUNCTION_MODULE_NAME'
CALL
CALL FUNCTION
FUNCTION '/1BCDWB/SF00000007'
'/1BCDWB/SF00000007'
Page 43 of 61
Page 44 of 61
we have to mention this name (of function module) in the print program.
Page 45 of 61
This calls the SAP Smart form. We are checking the output in Monocolour.
Page 46 of 61
Page 47 of 61
SE37: We use the just created function module. /1BCDWB/SF00000007. We execute this.
Page 48 of 61
CHECK PRINT
PREVIEW
Page 49 of 61
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 50 of 61
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 51 of 61
We can create our own message type. We can define various options like transmission medium here like
Print, Fax, EDI etc.
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
Page 52 of 61
Click
Page 53 of 61
Page 54 of 61
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
=
* OUTPUT_OPTIONS
=
* USER_SETTINGS
= 'X'
Page 56 of 61
* 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.
Additional Fonts for your SMARTFORMS
You can create additional fonts and style with transaction SMARTSTYLES
This can then be define in the paragraph and character formats, which you can then be assign to texts and
fields in the Smart Form.
The character formats includes effects such as superscript, subscript, barcode and font attributes.
Various Utilities and their functions in Smartforms
Creating Forms Using SAP Smart Forms
When creating a form we must:
Retrieve the application data
Describe the form
Pass the application data to the form
Retrieving the application data:
Write an ABAP program to retrieve data or include a retrieval routine into the application. This code
consists of statements that select data from databases according to certain selection criteria. Store the
retrieved data in internal tables, structures or variables and transfer it to the form in we step
.
Describing the Form:
The user defines the form using a smart form. Use the tools of the form builder as listed below:
Use the form painter to position the windows, graphics and addresses on a page.
Use the PC editor to write the texts.
Use the table painter to format the tables.
The flow control is used to print the pages and elements.
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.
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.
Page 57 of 61
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.
Graphical User Interface
The basic ABAP programming skills are required only in special cases like calling a function module or for
complex and extensive conditions.
The SAP form builder of the smart form consists of:
Form painter for creating the layout of the form
PC Editor for entering texts and fields into output areas
Navigation free for maintaining the form logic
Table painter for creating templates and tables
Form check
To define the text formats, we can use the Smart Styles.
The Form Painter:
The form painter offers the following functions:
Design area with ruler, cursor with help lines, and he grid and main grid.
Display of the cursor position in the ruler, which can be suppressed and set.
Two level grid with engage function which can be customized.
When creating, changing and moving a window, the window size appears in the ruler.
Detachable toolbar containing the most important functions.
Autoscrolling when moving windows, placing windows in the background.
Zoom factors that can be set to any value and autozooming of the design area to the window
size.
Sensitive context menu.
Placing a scanned graphic into the background of the design area.
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.
The Table Painter:
The table painter offers the following functions:
Drawing lines and columns
Inserting , cutting , copying and deleting lines
Deleting cells
Changing cell size and moving cell separator lines
Splitting cells
Selecting table patterns
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).
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.
Field list and Error list:
The field list displays the following data in the form a tree structure:
Page 58 of 61
All tables, fields and structures passed via the form interface.
System fields and the fields that are defined in the global definitions.
This allows we to check whether a correct field name has been entered or not and that the form knows the
field or not. To display the field list, in the form builder choose field list On/Off.
The error list contains the list of errors and warnings displayed at the bottom of the maintenance screen.
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.
Basic elements of a form
Creating pages:
Each form consists of we or more pages. The first page in the tree structure is the start page and the
processing of the form starts with this page itself.
Open the context menu for existing page node and choose createpage
Enter a unique name for the node and a description
Determine the format and the mode of the page counter on the general attributes tab
Determine the print attributes of the page on the output options
Determine a background graphic for the entire page on the background tab
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 choosewindow
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
Positioning texts on the form
The texts are displayed in the form using text nodes. The only exceptions are addresses. This uses its own
node.
The predecessor node of the text node determines its use:
Predecessor node
Used to
Sub window
[Position text on we or more pages]
Main window
[Display text in relation to other nodes in the main window, it may cover
several pages]
Template
[Displays texts for table cells of a static table]
Table
[Display table contents]
Header and footer
[Display column headings and grand totals in tables]
Event node
[Display subtotals in a table]
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
Page 59 of 61
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
Define the table layout:
The table layout is used to determine the following,
The number of lines and cells
The height of each cell
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.
Displaying contents in cells:
The template node defines the table layout. The successor nodes of the template determine the data to
be displayed 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.
Displaying contents in cells:
The template node defines the table layout. The successor nodes of the template determine the data to be
displayed 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.
Page 61 of 61