HR280_Col73SAP Interactive Forms and SAP Smart Forms Sappress_creating_forms_in_sap
Smart Forms Demo
Click here to load reader
Transcript of Smart Forms Demo
•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).
Smart Forms
Multiple page formats possible in smartform Main window may not be there in smartform Routines can be written in smartforms Smartform creates a function module when activated
Sap Script Vs Smartforms
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
Advantages
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.
Features
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.
Features
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.
They find use in :
Order confirmations Invoices
Account statements Checks
Salary statements Delivery notes
Customs forms Industry-specific forms
General Concepts on Form Printing
For printing a form we need two components :
1. Smartform : Definition of form layout and form logic
2. Application Program: ABAP Program for data retrieval
Architecture
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.
How does the Smartform work
When creating a form we have to:
1. Retrieve application data
2. Describe the form
3. Pass the application data to the form
Creation of Smartform
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.
While we initialize the form, we can format the data, which we 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.
Retrieving Application Data
Global settings in a smart form consist of :
Form Attributes
Form Interfaces
Global definition
Describing the form
Global settings
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
Form Attributes
Form Attributes
Form interface is like the import / export parameters of any function module. Activation of Smartform will create a new function module. This form interface will have the import / export parameters.
Form interface contains:
Import tab
Export tab
Tables tab
Exceptions tab
Form Interfaces
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.
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.
Global Definition
Global Definition
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 contents
Structure of 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
Pages of a form
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).
Types of Windows
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 Painter to position windows, graphics, and addresses on a page (the other elements are displayed in an assigned window).
Use the PC Editor to write your texts.
Use the Table Painter to format your tables.
Describing the Form
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:
Nodes
Form Logic
Page Window Text Graphic Template Table Command Loop Alternative Folder Complex Section Program Lines
Nodes in Smartforms
The following are the nodes in Smartforms
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 successors of 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).
Nodal Flow
Window Output area on a page. There are main windows and subwindows.
All except window and page nodes
Node type Description Possible direct successors
Page A page of the form. Direct successors of this node can be placed directly on the page.
Window, graphic, address
Output Areas
Node type Description
Text You use this node to print any texts (and table contents), except addresses.
Graphic You use this node to position graphics in the form. To include background graphics, use node type Page .
Address You use this node to include an address. The system reads the address data directly from the database tables and formats them for print output.
Elementary nodes (without successors)
Nodes - Overview
Table Output of a table containing application data
As with template node
Node type Description Possible direct successors
Template Output of a table containing static data
All except window, page, table, and template nodes
Table output
Nodes - Overview
Flow ControlNode type Description Possible direct successors
Command Executes special commands (next page, paragraph numbering, printer control)
(no successor)
Loop Processes successor node repeatedly. All except window and page nodes
Alternative Branches depending on condition. Direct successors are automatically the nodes TRUE and FALSE. The direct successors of these are all nodes except window and page nodes.
Other NodesNode type Description Possible direct successors
Folder Combines successor nodes to logical groups
All except window and page nodes
Complex section Combines all attributes of the node types template, table, loop, folder
All except window and page nodes
Program lines Executes ABAP program code (for example, conversion routines).
(no successors)
Nodes - Overview
Form Painter Table Painter PC Editor Navigation Tree
Tools in Smartforms
The following are the tools available in Smartforms
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
Overview about Form Painter
Design area with ruler, cursor with help lines, and he grid and main grid.
Display of the cursor position in the ruler, which can be suppressed and set.
Two level grid with engage function which can be customized.
When creating, changing and moving a window, the window size appears in the ruler.
Detachable toolbar containing the most important functions.
Form Painter
The form painter offers the following functions:
Autoscrolling when moving windows, placing windows in the background.
Zoom factors that can be set to any value and autozooming of the design area to the window size.
Sensitive context menu. Placing a scanned graphic into the background of the
design area.
Form Painter
The form painter offers the following functions: …Cont.
Form 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
Table Painter
Enter, delete, select, cut, and copy texts
Assign paragraph and character formats
Include, change, and delete fields
PC Editor
We can enter text in an editor. Data can be characters,strings or numbers.
Text and Data in Form (PC - Editor)
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
Transaction code - SMARTSTYLES or SMARTFORMS by selecting smart style option
Style Builder
Style Builder
FIELD LIST :The field list displays the following data in the form a tree structure:
All tables, fields and structures passed via the form interface. System fields and the fields that are defined in the global definitions.
This allows one to check whether a correct field name has been entered or not and that the form knows the field or not. To display the field list, in the form builder choose field list On/Off.
ERROR LIST:The error list contains the list of errors and warnings displayed at the bottom of the maintenance screen. That is when we check the smart forms and if any error occurs, it will be displayed at the bottom of the maintenance screen.
Field List & Error List
Field List & Error List
Migration of SAP Scripts to Smart Forms
There are two tools to migrate the SAP scripts to Smart forms
Individual Migration.Mass Migration
Individual Migration
Form Migration
Go to SAP Smartforms initial screen and enter the smart form name you want to create in the Form field.
Choose Utilities Migrate SAP script form and
Enter the name and the language of the Source form (SAP script).
Choose Enter.
Now change the design of the form and of the form logic. To activate the Smart form choose Activate
Style Migration
Style Migration
Go to initial screen of Smart stylesIn the Style name field enter the name of the style you want to create.
Choose Smart styles Convert SAP Script style.
Enter the name of the name of the SAP script style you want to convert.Choose Enter.
Choose Back . Now change the style as you wanted and activate the style you have created
Mass Migration
Execute the Report SF_Migrate.
Select the names and the language of the SAP script forms and choose Execute.
The system creates the Smart forms under the names of the SAP script forms plus the extension _SF.
To change and adapt the form , go to transaction SMARTFORMS. Then activate the changed smart form.
EXAMPLE
Test Scenario
Need to print the invoice details. The expected format is like:
Test Scenario
Develop a small program for data selection and to call the Smart form
Report YINVOICE is developed for this. Based on the selection screen invoice number, this program will select invoice / Partner / Material details from VBRK / VBRP / VBPA / MAKT and pass the details in the form of variables / internal table to the Smart form
Test Scenario
Program… Continued
Test Scenario
SMARTFORM - YINVOICE is created
Form Interface - IMPORT tab & TABLES tab
Test Scenario
SMARTFORM - YINVOICE
Global Definitions
PASTE THE SCREEN SHOT AT THE END
Test Scenario
New “Window” can be created by right clicking on the “Page”
All “Create/insert” options are available on right click. For example if we need to insert Graphic in a window, mouse right click by keeping the cursor position on the window!!
Test Scenario
Window name / description can be changed after creating it
Inserting the “Graphic” in the created “LOGO” window
Test Scenario
In the Graphic node, the name and description are changed + a new image is selected by pressing F4 (Value request)
Test Scenario
Aligning the Graphic (LOGO) window using “Form Painter”
Test Scenario
Window for displaying the header “Invoice Details”:
Window created with name HEADING:
Text node is inserted (by right click option) and the text “INVOICE DETAILS” is entered
Test Scenario
Window for displaying the header “Invoice Details”:
As per our required format, the text should get displayed with under line. For that purpose a smartstyle YINVOICE is created. Different paragraphs are created in that (for plain text, bold text, bold and under line, small letters, etc)
For displaying Invoice Details with under line, the paragraph format P3 can be used.
Test Scenario
Window for displaying the header “Invoice Details”:
In the output options tab of text node, the smartstyle is entered:
Once the style is mentioned, the “General attributes” tab will get the styles described in YINVOICE smartstyle. Selecting the P3 format for displaying this text
After this, the HEADING window is aligned using “Form Painter”:
Test Scenario
Window for displaying the Bill to Address
An Alternate has been created to fetch the Bill to Address
Test Scenario
An Alternate to fetch the Bill to Address
The alternate evaluates the condition whether the variable v_adrnr_bp is not equal to space and if true, the code logic under the true node will be executed, otherwise the code logic under the false node will be executed
A code logic has been created for Bill to Address
Test Scenario
Code Logic for getting Bill To Address
The variables needed for getting the information to be declared in Global Definitions and also to be passed as Input Parameters and Output Parameters in the code logic as marked above
The select statement fetches the address details from ADRC using the variable v_adrnr_bp. The text elements Name, Street and City are created to print the Bill to address
Test Scenario
Window for displaying the Ship to Address
Similarly for Ship to Address also, a window is created. An alternate like bill to address is created which evaluates the variable v_adrnr_sh and if true the code logic under true node is executed, otherwise false node is executed. The text elements Name1, Street1 and City1 are used to display the Ship to address
Test Scenario
Creating a table for printing Line Items
Test Scenario
A Table for printing the Line Items in the Invoice
A table has been created with columns for and the line type is %LTYPE1.Table consists of a header,Main area and footer portion
Test Scenario
A Table for printing the Line Items in the Invoice
In the Data tab, in the loop section, the internal table to be specified. The looping action takes place in the internal table and the line items are printed in the main area.
Test Scenario
Table for Printing Line Items
A row has to be created in the header portion of the table so as to print the headings of the columns in the table. The line type to be specified when creating a row
The Line type we have created for this table is %LTYPE1
Test Scenario
Table for Printing Line Items - Header
When a row is created with the line type %LTYPE1 then four cells or columns are automatically created in the row. Under the Cell1 the Material text element is created for printing the heading Material. Similarly for Description, Quantity and Price text elements are created under the Cell2, Cell3 and Cell4 for printing those headings.
Test Scenario
Table for Printing Line Items – Main Area
A row has been created in the main area with line type %LTYPE1. Under the Cell1 the text element for printing material number is created. Similarly for Description, Quantity and Price text elements are also created for printing those data under Cell2, Cell3 and Cell4. The looping action takes place in the main area. All line items in the internal table is printed. The field name specified in the text element as &i_inv-matnr& which is the field name in the internal table
Test Scenario
Table for Printing Line Items – Footer
In the footer portion of the table any texts or any footer data can be printed. A row can be created with the line type %LTYPE1 and text elements can be created in each cell.
Test Scenario
Template for printing Footer Details
A window is created with the name reference and a template is created under the window
Test Scenario
Template for printing Footer Details
Rows and columns are created in the template using the pencil pointer of the template.The template has 2 lines and 2 columns
Test Scenario
Template for printing Footer Details
A text element named ReferenceDoc is created under the template node
In the output options tab, in output structure section, the line and column of template is specified. This reference doc # output appears in the line 1and column 1 of the template.
Test Scenario
Template for printing Footer Details
The text element Dated is printed in Line 1 and column 2 of the template. Similarly the corresponding data of the reference and date is configured to print in line 2, column 1 and column 2 of the template.
Test Scenario
Address for printing Footer Address
A window named Footeraddress is created and under the window an address node is created.
Test Scenario
Address for printing Footer Address
Test Scenario
Address for printing Footer Address
In the General Attributes tab, the type is chosen as organization address and the address number is given as 12879.
The default paragraph for theoutput is given as P1. The numberof lines to be printed is given as 5
By default, the address of the specified address number is picked and printed in the output.
Test Scenario
Command for branching to a New Page
The command node isused to branch to a newpage provided the page we wish to branch exists.You can branch to a newpage as long as you are still displaying the contentsof the main window.
Test Scenario
Command for branching to a New Page
In the General Attributes tab, tick Go to New Page and determine the new page using the list box next to the check box. The output of main window will continue in new page