Register Login

Smartforms for Beginners

Updated May 18, 2018

Smartforms

Objective

The objective of this section is to introduce Smart Forms. The topics covered include :

  • Features and advantages of Smart Forms .
  • Architecture.
  • Tools in Smart Forms.
  • Developing a smart form, smart style and linking it to a program.
  • SAP uses Smart Forms 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 Script vs Smartforms

  • Multiple page formats possible in smartform
  • Main window may not be there in smartform
  • Labels cannot be created in smartform (disadvantage)
  • Routines can be written in smartforms
  • Smartform creates a function module when activated

Advantages

  • Creating and maintaining forms requiring half the time
  • Adapting forms without any programming knowledge due to entirely graphical user interface
  • Web Publishing using the generated XML output
  • Smart forms execute faster than Sap Script

Features

  • SAP Smart Forms allow you to execute simple modifications to the form and in the form logic by using simple graphical tools.
  • To print a form, you need a program for data retrieval and a Smart Form that contains the entire form logic. When activating the Smart Form, the system automatically generates a function module.
  • You design a form using the graphical Form Painter and the graphical Table Painter. The form logic is represented by a hierarchy structure (tree structure) that consists of individual nodes, such as nodes for global settings, nodes for texts, nodes for output tables, or nodes for graphics.
  • For Web publishing, the system provides a generated XML output of the processed form.
  • You can insert static and dynamic tables. This includes line feeds in individual table cells, triggering events for table headings and subtotals, and sorting data before output.
  • SAP Smart Forms allow you to include graphics, which you can display either as part of the form or as background graphics.

Global Settings

Global settings in a smart form consist of :

  • Form Attributes
  • Form Interfaces
  • Global definition

Form Attributes

In the form attributes we define the print settings like :

  • The page format (eg: DINA4, DINA3 etc.)
  • Characters per inch
  • Lines per inch
  • Style (Smart Style / System style)
  • Flag for XSF output

Smartforms-1

Form Interfaces

We define the form interface to pass the data to the form. In the form interface we can define import and export parameters, tables and exceptions.

Smartforms-2

Global Definition

Global definition apply for the entire form. We can use any object defined there in all nodes of the tree.

We can initialize the global data before we start processing the start page. Within the form routines we cannot access any global data unless we explicitly pass them to the form routine interface.

Smartforms-3

General Concepts on Form Printing

They find use in :

Order confirmations

Invoices

Account statements

Cheques

Salary statements

Delivery notes

Customs forms

Industry-specific forms

  • Form printing covers creating and maintaining a form for mass printing in SAP Systems
  • The layout determines the page structure, that is the number of differently structured pages and the positions of the output areas on these pages.
  • The form logic controls the dynamic formatting of the form.

Structure of the Form

A form is similar to a layout and contains the following :

  1. Pages
  2. Windows
  3. Addresses
  4. Graphics
  5. Tables or templates
  6. Data and text content

Pages of a form

  • On the pages of a form you determine the page layout and the sequence of pages with different structures.
  • The individual pages in the form may differ in their structure.
  • We specify the next page to make the page sequence clear. For recursive output call the same page repeatedly.

Types of windows

On a page there are two different types of output areas for text and data:-the Main window and the Sub window.

Main Window : In a main window you display text and data, which can cover several pages .We can define only one window in a page as a main window.

Sub Window : In a sub window you display text and data in a predetermined output area (i.e. Header, Footer etc).

 

Text and Data in a Form

We can enter text in an editor. Data can be characters,strings or numbers.

Smartforms-4

Architecture

For printing a form we need two components :

  1. Smartform : Definition of form layout and form logic
  2. Application Program: ABAP Program for data retrieva

Smartforms-5

How does a smart form work ?

When we activate the Smart Form, the system generates a function module that encapsulates all attributes of the Smart Form. As soon as the application program calls the function module, the Smart Form uses the modules interface (which corresponds to the form interface) to transfer any table data previously selected and to print the form according to the form description.

Creating Smart Forms

When creating a form we have to:

  1. Retrieve application data
  2. Describe the form
  3. Pass the application data to the form

Retrieving application data

For fetching the application data write an ABAP program to retrieve data or include a retrieval routine into your application. This code consists of statements that select data from the database according to certain selection criteria. Store the retrieved data in internal tables, structures, or variables and transfer it to the form in one step.

passed to the form, for output in the form. Formatting data in the form and not in the data retrieval program allows us to use one data retrieval program for several forms with different formatting routines.

Describing the form

Describe the interface of the form. It results from the application data previously selected.

Create one or more pages. On a page, you can position windows, addresses, and graphics. Within a window, you can create additional elements.

Create elements (text, graphics, tables, and so on) for each page, using other tools of the Form Builder:

  • Use the Form Painterto position windows, graphics, and addresses on a page (the other elements are displayed in an assigned window).
  • Use the PC Editorto write your texts.
  • Use the Table Painterto format your tables.

Form Logic

In the Form Builder you describe a Smart Form by a set of nodes. To do this, you build up a tree structure on the left side of the user interface:

Smartforms-6

Nodal Flow

Smartforms-7

The numbering of the nodes also shows the sequence in which they are processed (from top to bottom). The first node is the root node. The successorsof a node are all nodes included directly under this node in the hierarchy. For node 5 these are the nodes 6 to 9 (direct successors are only the nodes of the next hierarchy level, that is 6, 7, and 9).

Nodes in Smartforms

  • Page
  • Window
  • Text
  • Graphic
  • Template
  • Table
  • Command
  • Loop
  • Alternative
  • Folder
  • Complex Section
  • Program Lines

Node Types -Overview

Output Areas

Output-Areas

Elementary nodes (without successors)

Elementary-nodes

Table output

Table-output

Flow Control

Flow-Control

Other Nodes

Other-Nodes

Tools in smartforms

  • Form Painter
  • Table Painter
  • PC Editor
  • Navigation Tree

Form Painter

  • Used to design the layout of the smartform
  • Similar to graphical painter in Sap Scripts
  • We can create and change the size of the windows
  • We can graphical images also

Form-Painter

Table Painter

  • Drawing rows and columns
  • Inserting , cutting ,copying and deleting lines
  • Deleting cells
  • Splitting cells
  • Selecting table patterns
  • Changing cell size and moving cell separator lines

Table-Painter

PC Editor

  • Enter, delete, select, cut, and copy texts
  • Assign paragraph and character formats
  • Include, change, and delete fields

PC-Editor

Style Builder

Use Transaction Code SMARTSTYLES to maintain paragraph and character formats.

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), bar-code and font attributes
  • Colors and underlines for a paragraph or character format
  • Preview

Style-Builder

Field List and Error list

Field List

ListThe field list displays:

  • All tables, structures and fields passed via the form interface.
  • System field and fields defined in the global definition

Error List

When we check the smart forms and if any error occurs, it will be displayed at the bottom of the maintenance screen

Field-List-and-Error-list

Field-List-and-Error-list-2

Example

We will be using a smart form to print the details of a Sales order with details like :

Company address

Customer address

Material Number and description

Quantity and total price

priceSales order value.

For the sake of the example, both loop and table nodes are used for printing the item details.

The following slides show the required output and the components of the Form Builder used for getting the same.

 

Example -With Loop

Example-With-Loop

Development Sequence

Development-Sequence

Development-Sequence-2

Development-Sequence-3

Development-Sequence-4

Development-Sequence-5

Development-Sequence-6

Development-Sequence-7

Development-Sequence-8

Development-Sequence-9

Example -With Table

Example-With-Table

Example-With-Table-2

Table Painter

Table-Painter-2

Source Code

REPORT ZSALES_PRINT NO STANDARD PAGE HEADING.

DATA FLAG(1).

DATA: FORM_NAME(30) VALUE 'ZSALES_PRINT'.

DATA: FM_NAME TYPE RS38L_FNAM.

PARAMETERS: VBELN LIKE VBAK-VBELN OBLIGATORY,KUNNR LIKE VBAK-KUNNR OBLIGATORY.

DATA: BEGIN OF ZITAB OCCURS 0. INCLUDE STRUCTURE VBAP.

DATA: END OF ZITAB.

DATA ZITAB1 LIKE ZITAB OCCURS 0 WITH HEADER LINE.DATA: SVBELN TYPE DDSHRETVAL.TABLES: VBAK, VBAP.

START-OF-SELECTION.

SELECT SINGLE * FROM VBAK WHERE VBELN = VBELNAND KUNNR = KUNNR.

SELECT * FROM VBAP INTO CORRESPONDING FIELDS OF TABLE ZITABWHERE VBELN = VBAK-VBELN

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'EXPORTINGFORMNAME = FORM_NAME

*VARIANT= ' '

*DIRECT_CALL= ' '

IMPORTING

FM_NAME= FM_NAME

*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 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION FM_NAME

EXPORTING

VBELN = VBELN

KUNNR = KUNNR

FLAG= FLAG

ZITAB= ZITAB

ZITAB1 = ZITAB1.

Summary

The previous slides explained the features, creation and the application of Smart Forms.


×