You are on page 1of 20

Introduction to SAP Scripts

SAP script is the SAP System's own text-processing system.It looks and feels a lot
like other leading text-processing systems.
It is used to print preformatted text in pre-formatted forms.

Components of SAP Script


SAP Scripts comprises of five main components:

1.
2.

An editor for entering and editing the lines of a text


Styles and layout sets for print layout. These are created independent of the
individual texts using the corresponding maintenance transactions and are allocated
to the texts later
3.
The composer is a central output module. The SAP script composer is invisible
to the outside
4.
A programming interface that allows you to include SAP script components
into your own application programs and to control the output of layout sets from
within the programs
5.
Several database tables for storing texts, styles and layout sets

Layout Set
To output documents using the programming interface, R/3 application programs need
so-called layout sets (a kind of form).In SAP script a layout set describes the layout of
the individual print pages and uses text elements to supply definable output blocks,
which a print program can call.A layout set can be defined as a page design for a
document

Layout set on its own doesn't contain any data. The selection of data for the document
is done through the print program. The print program selects the data from database
table and feeds it to the layout set. When the print program is executed the document
is printed on the screen, printer.
Usually a SAPScript Layout consists of following components
1.

2.

3.

4.

5.

Header Data: Header data is used for information and control of SAP printing.
The header data comprises of 2 parts - Device Independent - Stores information
like Start page , Default paragraph ,Language Attributes etc. And Device
Dependent stores information like Page format ,Orientation Lines per inch etc
Paragraph and Character Formats: Paragraphs are formatted using various
attributes. For instance Standard paragraph attributes specify Left or Right margin,
Alignment ,Line spacing etc. Font attributes specify Font family ,Font size etc.
Character formats allow to format entire blocks of text within a paragraph
Windows and Text Elements: Windows are individual text areas (header
address, date, footer) in a page . It helps combine the information contained in a
document into certain groups and make each group appear on the printed page in an
individual area.You can define text elements (window texts) for each window. The
print program accesses text elements by name, formats them and prints them in the
respective window. The paragraph and the character formats used must be defined
in the form.
Pages: They are individual pages of a document and must have a unique name.
You will often find different layouts for individual pages: The first page of an
invoice differs from the subsequent pages, on which you need not repeat general
information, such as address or customer data.
Page Windows: While defining windows and pages, you do not yet determine
the position and spacing of the texts to be output.A page window defines the
rectangular output area in the output medium by specifying the left upper edge of
the output area and its width and height

Control Commands
The purpose of "control commands" is to allow control of the output formatting.These
commands are not interpreted by the SAP script editor, but are passed through to the
SAP script Composer for processing. This includes, for example, line and page
formatting, the formatting of text according to the paragraph and character formats
specified.

Syntax
1

Enter /: in the paragraph format

Examples

NEW-PAGE - Explicit page break


PROTECT .........ENDPROTECT - To print complete paragraph in one page.
INCLUDE - To include the content of another text into current text
PERFORM - To call a subroutine of any ABAP program

Print Program
The execution of script is done through an ABAP program, which is referred as Print
Program. Each print program should have an ENTRY form , which will be called
from customization.
For a standard configuration we can see the form name (script name), print program
name and output type in the table TNAPR.The print program uses the Form control
functions to call the script.
The print program call either all or some of the form control functions to execute the
script

OPEN_FORM (Mandatory) Opens the layout set output


CLOSE_FORM (Mandatory) Ends the layout set output
START_FORM (Optional) Starts a new layout set
WRITE_FORM (Mandatory) Calls a layout set element
END_FORM (Optional) Ends the current layout set

Output Types
The output type can specify, a printed form that you need for internal use or a form
that you want to send to a customer or vendor . The output type can also be an internal
electronic mail message that you want to send to staff in another department.
For example "Print out" can be classified as one output type of a billing document, i.e.
when this output type is executed the billing document is printed. Similarly "Fax" can
be an output type, i.e. when this output type is executed a fax of the billing document
is sent

All the output types for any document (e.g. billing document) will be stored in the
table NAST.Output types are executed through the program RSNAST00 .
Example : Output type in a billing document1.
2.
3.
4.

Go to VF03
Enter billing document number and press enter again
Chose Output under the menu Goto -> Header
Here Z101 is an output type of a print output

Standard Texts and Graphics


Standard Texts for your report can be created using transaction SO10
Graphics and printer macros are uploaded with report RSTXLDMC into individual
standard text documents or through transaction SE78. Graphics are uploaded in
"Baseline TIFF 6.0" format (.tif files on PC)
SAP Script & Standard text elements can exported or imported between two systems
using RSTXSCRP program
Copying Scripts Across clients:
SAP Script is a client dependent object.Unlike programs, changes done to SAP script
in one client will not be reflected in other clients. For copying script from one client to
another, go to SE71 and use "Copy from Client" option available under
Utilities menu or import the transport request, in which the script is saved, from the

original client using the transaction SCC1 .


Important Points to Note
1.

SAP script does not maintain any versions. So when modifying the SAP script ,
ensure that the changes are well documented in script. This applies to the standard
texts too.
2.
The output of the form will differ when viewed on the screen and on the
printer. So always test the output of the script on the printer.

Smart Forms
SAP Smart Forms is used to create and maintain forms for mass printing in SAP
Systems.As output medium SAP Smart Forms support a printer, a fax, e-mail, or
the Internet (by using the generated XML output).
SAP introduced SmartForms in 1998 to overcome the limitations in SAP Scripts.
SmartForms are easier to develop, maintain and transport than SAP Script.

Smart Forms and SapScripts Comparison

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.
Routines can be written in SmartForms tool.
SmartForms generates a function module when activated.
Labels cannot be created in SmartForms.

Advanatges of Smart Forms

They help adapting forms without any programming knowledge due to entirely
graphical user interface
When activating the smart form the system automatically generates the
function module and at the runtime .
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.
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.
Web Publishing is possible using the generated XML output

Architecture of SAP Smart Form

Smartforms Guide
Lets go through it in SAP system1.
2.

Enter transaction SMARTFORMS in the transaction code box.


In the next screen , enter a from name and click create

The next screen is divided into three sections-

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


Whenever we create smart forms, SAP creates/generates a function module.Unlike
SAPscripts , SAP FORMS allow you to change language.
In the navigation window you will find
Global Data Declarations : The Data defined here can be used throughout the
smartform for coding purposes.
Form Interface : Here all the data which will be passed to the smartform from the
Print program is defined.

Right-Clicking on the Pages will allow creation of New Page, Window, Graphic or
Address.

Printing will take place on the basis of 'next page' field.


But processing will happen as per the sequence in navigation 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. You may take a detour
from the smartform screen and open Form Graphics screen. Transaction code: Se78

Setting in the Graphics in Smart Form Window-

Windows in Smart Forms

There are two types of Windows


1.
2.

Main
Secondary

Important Points to Note

You cannot have more than 1 main window in a page. You can have multiple
secondary windows
Whatever you 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
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.

Inside the main window we can add text as introduction to customize the form output.

The Output options on each window determine the Line size, Width, Colors and
background to be put.

Smartforms gives the option of giving the address number which is maintained in the
central address management. The address will be directly taken from ADRC table and
will be populated in the form.

The two different editors are available in Smartforms viz. Normal Editor

and the Graphics Editor.

This setting can be changed using the Configure editor in Utilities.


In Table painter, you can draw the format as per client requirement (e.g. Heading, Sub
Heading, Item, Sub Total, Grand Total etc.)
You can 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

The Table shows the different line types which will be used in the table. The Line
types define the size of each cell and the number of cells in each line.

Smart Forms Programming Flow


When an SAP Smart Form template is created, a user creates the form layout, defines
the required fields, conditions, and special programming instructions in the Smart

Form template using the Smart Form Builder.


After the form design is complete, the form needs to be activated before it can be
tested or accessed by the print programs.Activating the form initiates the generation of
a function module that handles all of the form's processing.
This function module interacts with the application program/print program to create
the output in the user-defined output media for the specified device.
In case of smart forms, we use 2 function modules for the processing of the smart
form. To the first function module , we pass the name of the smart form as the import
parameter. This then returns the name of the dynamically generated function module
which will actually call the smartform.
The smartform name can be passed on to the function Module 'SSF_FUNCTION_MODULE_NAME'

This will return the Function module name of the smartform which is referenced.

The Print program will be calling the FM 'SSF_FUNCTION_MODULE_NAME' to


get the Function module name at Runtime. Therafter it will call the Function module
thus obtained to execute the smartform.

Templates
Template can be used when you 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.
The big between table and template is that in a Table the height changes
dynamically.We call a row a 'line' in template.

SMART Styles
A Smart Style contains:

Header data containing the default values of a Smart Style

Paragraph formats including indents and spacing, font attributes, tabs, and
outline and numbering

Character formats including effects (superscript, subscript), barcode and font


attributes

Colors and underlines for a paragraph or character format


You can use the transaction 'smartforms' / 'smartstyles' to create a smart style.

You might also like