What is SAP Smart Forms?
SAP Smart Forms is form creation tool, with better GUI for form development as compared to SAP Script. In simple words, SAP smart form is a tool for form processing.
Many business applications in SAP need to display their data in form format, also known as business documents, and SAP Smart Form serves as an ideal tool to create these forms. These business documents can then be printed, faxed or sent via email.
With help of SAP Smart Forms business can achieve a consistent design for all their business documents. Smart Forms when integrated with business applications serve as a medium for their data output. SAP solutions come with a number of pre-created forms for most of their central business processes.
Tcode for SAP Smart Form
SAP Smart Forms tcode is SMARTFORMS. This tool facilitates designing of form as well as defining form interface.
SAP Smart Forms Tutorial
SAP Smart Form Architecture
Smart Forms are meant to output application data in a form format. The architecture of Smart Forms keeps separate application data retrieval from form definition.
When smart forms are activated, it generates a function module, similar to a regular function module, that can be called from an application program, also known as a driver program.
The interface of this generated function module passes the data to be output from the application program to the form. When defining smart form, we define form interface to transfer application data to form definition. The interface of the generated function module is a replication of the form interface.
SAP SmartForms Form Builder
The tool to design and edit SmartForms is known as the Form Builder, accessed using tcode SMARTFORMS. The Form Builder has three main areas, Navigation tree in the left hand side, maintenance screen in the middle and form painter in the right hand side.
Smart Forms Navigation area: The Sap Smart form navigation tree comes handy in navigating across the Smart form. It consists of various nodes in a hierarchy format. The pages, windows, text elements or any other form element are know as nodes, and navigation tree helps in quick navigation across these nodes.
Smart Forms Maintenance area: The mid area, also know as maintenance screen displays the attributes of the node selected.
Smart Forms Form Painter: The RHS form painter helps in quickly aligning the layout of the Smart form. In Form Painter, you design the page layout by positioning the output area ( window ). This section can be hidden by Utilities -> Form Painter On/Off to bring more working space.
Under the form node you have the Global settings node and the Pages and Windows node.
SAP Smartform global settings
Global settings node consists of three sub nodes: Form attributes, Form Interface and Global definitions.
Form Attributes
You can check the basic formatting settings and admin information in this node.
In Form attributes, General Properties tab, you can control the translation of smartform to other languages.
Change the page format of the smartform in Form attributes, Output options tab. Also, you can check the smartstyle attached to a form in Form attributes, output options tab.
Form Interface
The SAP Smartform form interface is used to define the interface of the form which includes importing and exporting parameters, tables and exceptions. The driver program of smartform uses Form Interface to pass data to the form, as well as return data back from the smartform .
Remember, that when the smartform is activated, it generates a function module that has the interface based on the parameters defined in the form interface. Data is exchanged to and from the smartform using this function module.
Global definitions
The smartform global definitions node is used to declare Global data, Types, Field Symbols, Initialization, Form Routines and to define Currency/Quantity Fields. The variables and fields declared here are global and available through out the smartform.
SAP Smart Form Pages and Windows
The major node after Global settings is the Pages and Windows node. This node will hold pages, and every smartform will at-least have one page. Needless to say, you can have multiple pages in a smartform with different layout. The above images shows a page, with a Main Window inside it.
Pages has three tabs, in General Attributes tab we state the Next page to be followed after execution of the current page, it can call itself also as Next page. In Output options we can define page format, Portrait or Landscape, and in Background Picture tab we get option to place a background image.
Inside a page, we can have window, graphic or address node.
We can create multiple window inside a page. The windows are placed on page to create a layout for the form. It also serves the purpose of placing nodes together that needs to be displayed on the form.
We can have the following nodes inside a window: graphic, address, text, table, template, flow logic and folder. These are also known as form elements. The text node will be used to display text or variable data.
SAP Smart Forms step by step
This step is to help beginners jump start with creating Smart Forms. Here we will see how to create SAP Smart Forms step by step from scratch.
Go to Tcode SMRTFORMS and provide form name. Click Create.
double click on form attributes. Give a description to form.
Double click on Form Interface. In Import tab, enter as highlighted in image. Later after activating the form, a function module will be generated which will have interface as defined in the form interface. We will call the generated function module from the driver program.
Next, expand pages and windows. Expand page. Right click on main and select Text. We are inserting a Text node.
Double click on created text node. Give a description. Also, provide some meaningful text in the box.
Click on + icon. This is used to insert variables. The data of these variables will displayed on the text node. The variables must be prefixed and suffixed with &. Once done click on continue.
We are done with the defnition of the smart form. Click Save, Check and Activate to save and activate the smart form.
You can see the generated function module by clicking Environment – Function Module from the menu.
In a notepad, note down the generated function module. Your function module will be different, so don’t worry. Every smart form generates a unique function module.
This completes the definition of the form. Next, we develop a driver program to pass data to form and display the form.
Driver program for Smart Forms
We create a driver program to call the smart form as well as to pass the application data to the smart form.
Go to tcode SE38. Give a program name and click Create to create an application program.
Code your program as shown below. Use pattern to call your function module that you noted in the earlier step.
As you can see, we are retrieving data in work area is_scustom and passing it to the function module. This makes is_custom data available to the form, and finally displayed as output.
Once done, save and activate driver program. Fill the parameter and execute the program.
Click on print preview to display the output.
Form output. The value from the work area is displayed on the form. If you have added any text, then it will also display in the output.
This article teaches what is sap smart form, how to create a sap smart form and how to write a driver program for the smart form.
Advantages of SAP Smart Forms over SAP Scripts
- Better GUI for form maintenance and development reduces development effort.
- SAP Smart Forms has functionalities like Table Painter and Template that makes customizing Smart Forms easy
- Unlike SAPScript, SAP Smart Forms do not require special scripting language commands
- SAP Smart Forms allow easy insertion of normal ABAP Code
- SAP Script does not have syntax check whereas Smart forms have syntax checker.
SAP Smart Forms standard examples
SAP IDES has a number of SAP smart forms examples for your reference and you can refer them to learn more about smart forms. These are SF_EXAMPLE_01, SF_EXAMPLE_02, SF_EXAMPLE_03 and so on.