100% found this document useful (1 vote)
113 views27 pages

SAP Smartforms Development Guide

The document discusses developing smartforms in SAP using the Smartform layout designer. It provides an overview of smartforms and their components. It then demonstrates how to create a basic smartform displaying text, use global variables and initialization, display data in tables, and use loops to iterate through internal tables. Key points covered include defining global types and data, initializing data from databases, designing table layouts, and looping through records to output multiple lines.

Uploaded by

KIRAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
113 views27 pages

SAP Smartforms Development Guide

The document discusses developing smartforms in SAP using the Smartform layout designer. It provides an overview of smartforms and their components. It then demonstrates how to create a basic smartform displaying text, use global variables and initialization, display data in tables, and use loops to iterate through internal tables. Key points covered include defining global types and data, initializing data from databases, designing table layouts, and looping through records to output multiple lines.

Uploaded by

KIRAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Introduction to Smartforms
  • Components of Smartforms
  • Simple Smartform to Display Text
  • Using Global Variables
  • Using Tables in Smartforms
  • Using Loops in Smartforms

Smartforms

Developing Smartforms using SAP Smartform layout


designer
Smartform

Smart form is a GUI Tool which is used to design the business legal documents such as
Delivery note,Purchase order,Invoice etc.
The transaction code is SMARTFORMS.
Smartforms are client independent objects.
Smartforms are advanced version of SAP Scripts.
It is a GUI tool and it is user friendly.

Smartform architecture:

Smatrtforms and SAP Scripts differences .


Smartforms

SAP Scripts

Smartforms are client independent.

SAP Scripts are client


dependent.

Smartforms

SAP Scripts

Main window is not compulsory.

Main window is compu

Smartforms generates a Function module when activated.

No Function Module w
generated.

Smartforms texts supports various colors.

Scripts allows black an


colors only.

There is no transfer of control between program and form, once the control is transfered
to Function Module, it will never come back.

Scripts has repeated t


of control.

Only single page format is possible.

Multiple page formats


available.

COMPONENTS OF SMARTFORMS.
There are two main nodes in Smartforms.
[Link] Settings

Form Attribute.

Form Interface.
Global Definition.

[Link] and Windows.

Global settings:
It is used to provide the basic settings for the smartform.

Form Attributes:
It specifies the general attributes like who created,Date,time, package,translate options, default
smartstyle, Page format (DINA4/DINA5).

Form interface:
It acts as a mediator between a driver program and a smart form.
The main functionality of form interface is, it will import the parameters which are exported by
driver program.
The parameters can be variables, work areas, internal tables..etc.

Global definition:
It will contain the variables to be used within the smart form.
We can define variables, user defined data types, field symbols, initialization code,Subroutine,
currency/quantity fields.
It is mainly used for declaring or defining the above variables.

Pages and Windows

Page.
Window.
Graphic.
Address.
Text.
Table.
o Header.
o Body.
o Footer.
Template.
Folder.
Program Lines.
Alternative.
Command.
Loop.

Pages and windows


This will contain all the pages and the windows, which are used in the smartform.
By default, a page will be created by name %page1.
By default, a window will be created by name 'Main' under the page1.
For each page, we need to specify the next page.
Eg: page = %page1
Next page = %page1 or %page2

Nodes under pages


Page : It is used to define the layout of a smartform.
We can have different pages with different layouts.
Window : it is used to display information or text at a particular place on a page.
Graphic : it is used to display logos or images on the smartforms.
Address : It is used to display the address of customer or vendor or employe, organization
address , workplace address etc.

Just provide address no, it will automatically display the address as per the country formats.

Nodes under the window


Text : it is used to display the information or text in a window.
Table : It is used to display the information in the form of table.
When ever we create table by default HEADER, MAIN AREA, FOOTER will be displayed.
The main functionality of a table is, it expands automatically depending on the internal table data.
We need to provide the name of the internal table for a table.
Template : template is also like a table which does not expand. That means it will have fixed
number of rows and columns.
Program lines : it is used to write some lines of abap code.

Window Types in Smartforms


Main window: For continuous output .
Secondary window: For output with a fixed length.
Final window: Special type of secondary window for outputting the information that is not known
until the end of form processing .
Copies window: Special type of secondary window for marking pages as copy or original.
Example Smartform GUI

Simple Smartform to Display Text


Go to SMARTFORMS T-code.

Provide form as ZSAPN_TEXT, click on create.

You will find screen below.

Expand page, right click on min window -> create -> Text.

Go to general attributes tab, add some text.

Click save, save it in a local object, activate and click on execute.

Whenever we activate a smartfrom, one function module will be generated, when we execute it, it
will go to function module.

Just click execute (F8).

And again press F8, execute.

Provide output device as LP01, click on print preview.

Smartform output will be displayed.

Using Global Variables and


initialization in Smartforms
Using global definitions, structures and initialization in smartforms

Using global decelerations in smartforms.


Using user defined structures.
Using initialization of data.

Go to T-code, SMARTFORMS, provide name as ZSAPN_GLOBAL_INIT and click create.

Double click on global definitions, go to types tab and add below code.
types: BEGIN OF ty_mara,
matnr type mara-matnr,
mbrsh type mara-mbrsh,
mtart type mara-mtart,
matkl type mara-matkl,
meins type mara-meins,
END OF ty_mara.

Go to global data tab, create a variable of type ty_mara.

Go to initialization tab, add output parameter as wa_mara, add below code to get material
details.
select SINGLE * FROM mara
into CORRESPONDING FIELDS OF wa_mara
WHERE matnr = '000002-000'.
**Material no must be in MARA

Expand page, double click on main window, right click on main window -> create -> text.

Go to general attributes tab.


Add a label, click on insert field, a popup will come provide variable name by adding '&' at
beginning and ending.

In the same way add other fields also.

Save, activate and execute(F8).

You will go to a function module.


Just execute.
Execute again.
Provide output device as LP01.

Smartform is displayed.

Using tables in smartforms


using tables in smartforms using tables element.
Go to T-code SMARTFORM, provide name ZSAPN_TABLE and click on create.

Click on global definitions, add a structure under types tab.

Click on global data and add parameters as below.

Go to initialization tab, add output parameter as IT_MARA and add below code get materials.

Expand page, right click on main window -> create -> table.

Whenever we create a table, header, main area, footer for the table will be created automatically.
Now we need to draw columns, we know smartforms is a GUI designer, we need to design table
columns, to create table columns go to table tab, click on pencil icon and draw five vertical lines(
no of lines = internal table fields).

Click on details to specify size of column.

Specify sizes as below.

Go main view, output options and specify width, height as below.

Right click on header -> create -> table line

Select line type from drop down.

Right click on each cell, create -> text to create column headers.

Go to general attributes tab and provide text as Material No.


Similarly create column header texts for all cells as below.
Industry Sector
Material Type
Material Group
Base Unit of measure
Double click on main area, create -> table line.

Select a table line %LTYPE1 from drop down.

Click on insert icon, a popup will come and provide variable as &wa_mara-matnr&, enter.

Similarly create text for all cells and insert respective variables as below.
&wa_mara-mbrsh&
&wa_mara-mtart&
&wa_mara-matkl&
&wa_mara-meins&
Double click on table, go to tab data and loop internal table as below.

Save, activate and execute (F8).

Using loops in SMARTFORMS


Sometimes, we may need to use loops in smart forms to display data, below is the example of
using loop s to display data.
Go to T-code SMARTFORMS, provide name as ZSAPN_LOOPS and click on create.

Double click on global definitions, go to types tab and add below code.
types: BEGIN OF ty_mara,
matnr type mara-matnr,
mtart type mara-mtart,
meins type mara-meins,
end of ty_mara.

Go to global data tab and create table and work area.

Go to initialization tab and add below code to get material details.


select * FROM mara
into CORRESPONDING FIELDS OF TABLE it_mara
UP TO 50 ROWS.

Double click on main window, right click -> create -> flow logic -> loop.

Add internal table IT_MARA and work area WA_MARA as looping parameters.

Right click on loop, create -> text.

Click on insert icon and insert work area fields.

Similarly insert all work area fields.


Save, activate and execute (F8).
It will go to function module, execute.
Again execute and provide OutputDevice as LP01, print preview.

Common questions

Powered by AI

Initialization in SAP Smartforms involves setting up initial conditions and data states before the form is executed. This step allows for early preparation of data structures, such as defining necessary types and variables, and executing initial data selection queries to populate data fields . Effective use of initialization ensures that all required data is readily available, leading to smoother execution and fewer runtime errors. This preparatory stage is critical for complex forms where data integrity and coherence are essential before the actual presentation logic is processed .

In SAP Smartforms, tables and templates serve distinct functions. Tables are designed to expand automatically based on input data from internal tables, accommodating varying amounts of information without manually adjusting layouts . In contrast, templates do not expand automatically, maintaining a fixed number of rows and columns, making them suitable for static data presentations . This fundamental difference makes tables more flexible for dynamic data, whereas templates are used where consistency in layout is required.

The 'Main Window' in SAP Smartforms is significant as it supports continuous data output across multiple pages, seamlessly flowing through the form's entire length without constraints . This is essential for documents like invoices or reports where data spreads over several pages. In contrast, 'Secondary Windows' have fixed lengths, suitable for consistent data presentation such as headers or footers, and 'Final Windows', also a type of secondary window, are used for content determined after the form's main processing is complete, such as summaries or concluding notes .

'Program Lines' in SAP Smartforms are used to incorporate custom ABAP code directly within the form, allowing developers to perform operations that go beyond the capabilities of the standard layout components . They are particularly useful for complex calculations, data manipulations, or conditional content display. By embedding code, Smartforms can dynamically tailor content to meet specific business requirements, improve data presentation, and integrate additional logic, thereby enhancing the functionality and flexibility of the document creation process .

Key differences between SAP Smartforms and SAP Scripts include client dependency and control flow. Smartforms are client-independent, meaning they do not rely on a specific client setup, whereas SAP Scripts are client-dependent . In terms of control flow, Smartforms generate a function module when activated, providing a one-time transfer of control to the function module, which does not return, while SAP Scripts support repeated control transfer . Additionally, Smartforms support multicolored text, contrasting with the black and white restrictions in SAP Scripts .

Smartforms ensure compliance with international address standards through the 'Address' node, which interprets and formats addresses based on country-specific templates by simply providing an address number . This feature is critically important for global businesses as it simplifies the management of diverse address formats and ensures documents are professional and aligned with local norms, reducing errors in address handling and enhancing communication efficiency across international boundaries .

The 'Form Interface' in SAP Smartforms acts as a mediator between a driver program and a smartform. Its primary function is to import parameters that are exported by the driver program, which can include variables, work areas, and internal tables . This interface is crucial for passing data required for the form's output without embedding logic directly within the form itself, ensuring a separation between logic and presentation layers .

'Global Definitions' in Smartforms play a crucial role in unifying variables, user-defined data types, and initialization code required throughout the form. These definitions are used to declare global variables, which ensures that necessary data is prepared and available during form processing . By centralizing the declaration and initialization in 'Global Definitions', Smartforms ensures consistency and reduces redundancy, thereby optimizing the form's processing logic and facilitating the integration with driver programs .

SAP Smartforms manages dynamic address data by utilizing the 'Address' node, which can automatically display addresses based on country-specific formats. By providing an address number, the 'Address' node adapts the format of the address output according to predefined settings appropriate for the target country, ensuring compliance with international standards without manual intervention in the layout .

Using loops in SAP Smartforms involves defining looping structures within the form to iterate over internal table data, displaying each row according to the layout specified in the 'Main Window' . This method is beneficial for printing lists or tables where the amount of data is not fixed, ensuring that all entries in a dataset are represented in the output. By using loops, forms are capable of adapting to large or small data sets dynamically, providing the versatility needed for comprehensive reporting and documentation tasks where data volume can vary significantly .

Smartforms 
Developing Smartforms using SAP Smartform layout 
designer 
Smartform 
 
Smart form is a GUI Tool which is used
Smartforms 
SAP Scripts 
Main window is not compulsory. 
Main window is compu
Smartforms generates a Function module when act
Global definition: 
It will contain the variables to be used within the smart form. 
We can define variables, user defined da
Just provide address no, it will automatically display the address as per the country formats. 
Nodes under the window 
Text
Simple Smartform to Display Text 
Go to SMARTFORMS T-code. 
 
Provide form as ZSAPN_TEXT, click on create. 
 
You will find s
Expand page, right click on min window -> create -> Text. 
 
Go to general attributes tab, add some text.
Click save, save it in a local object, activate and click on execute. 
 
Whenever we activate a smartfrom, one function m
 
Just click execute (F8). 
 
And again press F8, execute.
 
Provide output device as LP01, click on print preview. 
 
 
Smartform output will be displayed.
Using Global Variables and 
initialization in Smartforms 
Using global definitions, structures and initialization in smartfor

You might also like