The objective of this section is to introduce Smart Forms. The topics covered include :
- Features and advantages of Smart Forms .
- 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
- 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
- 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 in a smart form consist of :
- Form Attributes
- Form Interfaces
- Global definition
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
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.
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.
General Concepts on Form Printing
They find use in :
- 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 :
- Tables or templates
- 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.
For printing a form we need two components :
- Smartform : Definition of form layout and form logic
- Application Program: ABAP Program for data retrieva
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:
- Retrieve application data
- Describe the form
- 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.
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:
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
- Complex Section
- Program Lines
Node Types -Overview
Elementary nodes (without successors)
Tools in smartforms
- Form Painter
- Table Painter
- PC Editor
- Navigation Tree
- 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
- 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
- Enter, delete, select, cut, and copy texts
- Assign paragraph and character formats
- Include, change, and delete fields
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
Field List and Error list
ListThe field list displays:
- All tables, structures and fields passed via the form interface.
- System field and fields defined in the global definition
When we check the smart forms and if any error occurs, it will be displayed at the bottom of the maintenance screen
We will be using a smart form to print the details of a Sales order with details like :
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 Table
REPORT ZSALES_PRINT NO STANDARD PAGE HEADING.
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.
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= ' '
IF SY-SUBRC <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CALL FUNCTION FM_NAME
VBELN = VBELN
KUNNR = KUNNR
ZITAB1 = ZITAB1.
The previous slides explained the features, creation and the application of Smart Forms.Download attached file:
You must be Loged in to download file