Smart Forms have been introduced in SAP Basis Release 4.6C as the tool for creating and maintaining forms. This tool allows developers to execute simple modifications to a form and the form logic by using simple graphical tools; in 90% of all cases, without any programming effort. Thus developers can get away from the robotic approach in sap script development, and produce good quality layouts at much reduced estimates.
Let us look at the steps involved in creating smartforms within the SAP system.
Start smartforms transaction, give the name of the smartform that you want to develop and click the Create button. This transaction is also called the smartform-builder.
1. The next screen has 3 sections –
Column 1 Global settings, pages and windows, window elements
Column 2 Details of each object selected in column 1
Column 3 Form painter for the developer to “visualize” each form object
2. Under the page node in the first column, click on Create => Page. Give the page name and description. Give the appropriate Next page in the General Attributes of the page. The Output Options tab is for defining the print attributes for the page.
3. Under the existing page node in the first column, click on Create => Window. Give the window name and description. Give the appropriate Next page in the General Attributes of the page. The Output Options tab is for defining the position and size of the window. The main point is to define the window type as Main or secondary depending on the need. Every page can have only ONE MAIN WINDOW and the width of the main window should be same on all the pages – height can differ.
4. Before creating the various elements in the windows, the programmer should define a smart style – this contains the various paragraphs and character sets that need to be used for the text elements, and is synonymous with the sap script style. Let us see how this is done.
a. Invoke transaction SMARTSTYLES. Enter the style name, and choose Create to create it. Activate the style after creating it and ensuring it that it is error-free.
b. The default paragraph, default tap stops, characters/inch and lines/inch, font family and font sizes should be defined in the header data of the smartstyle.
c. A paragraph format consists of defining indents, spacing, font settings, text color, tabs, numbering and outline.
d. The text flow can be defined for a paragraph, in the form of the below two attributes
i. Page protection – Enabling this prevents the paragraph from being split across pages due to a page break. If there is not enough space left on the current page to accommodate the paragraph, the entire paragraph gets pushed on to the next page
ii. Next paragraph – Enabling this links the current paragraph to the subsequent paragraph, and prevents them from splitting across pages due to a page break.
e. Character formats can be defined using the attributes Superscripting, Subscripting, Barcode, font attributes like family/size, bold/italic, underlined and color.
Lets now look at all the elements that can be created within a window on a page.
a. Text Node
i. This is used to position all the texts except addresses. To create this node, select the respective node that should have this text, and then choose Create => Text. Enter the name and description (both unique).
ii. Give the text type on the General Attributes tab, as Text element. Enter the text on the tab itself using the in-place Pc editor, or using the Text editor. Choose whether the text should start with a new paragraph, or new line, or append it directly to the end of the current paragraph. Give the proper output options to specify the style or box and shading for the text.
iii. Use the text type Include text, to point to a sapscript text that is already created in the SAP system. Point to note is that any control statements in the include text, are ignored during smartform processing.
iv. Use the text type text module to include a text module already defined in the SAP system. Use the program lines preceding the text module node to dynamically determine the text name that needs to be associated with the text module.
v. A special type of node called Address node is used to display addresses from the SAP system, in proper format. The important point is to enter the correct address type on the General attributes tab of the address node. The additional addresses box is used to specify the way in which the address needs to be displayed.
b. Printing graphics: (LOGO): Use the transaction code SE78 to import graphics into the SAP system. The transaction imports the graphics and stores it in the BDS (business transaction server). This can then be easily displayed in the form.
i. To create the graphic node, call the context menu for that node in the tree structure and choose Create=>graphic.
ii. Enter a name (LOGO) for the node and the description (Logo Graphic).
iii. On the general attributes determine whether the graphics background should be colored or a black and white.
iv. On General Attributes use the fields object - GRPAHIC, id – BMAP and name - &G_LOGO& to identify the graphic. &G_LOGO& is variable and therefore we can print company code specific logo.
c. The node type Template is used to display a table whose layout and size (number of lines and columns) is known before the runtime of the print program. A table layout needs to be be defined to determine the cell structure for each line. The cells are used to display the contents of the successor nodes of the template node. This allows the positioning of text and a graphic side by side.
i. Create a template node and maintain the attributes Width, Horizontal alignment, and Vertical alignment. Each line of the template must have a definition. To define the layout of each line, use the table control on the Template tab.
ii. To specify the lines of your template, for which the definition applies, use the columns From and To. The numbering should start with 1. The intervals in the line definition should neither overlap nor leave gaps.
iii. The Height to specify applies for all cells of this line. Specify a Width for each cell that needs to be displayed. The sum of the width values must amount to the specified Width of the template.
iv. The Name of the template line can be reused for other lines of the same template. Enter it in the Reference column of the desired lines. The system then copies the values you specified for the line height and the individual cell widths.
v. Use the Pattern box to select the desired ta
vi. The data to be displayed in the table cells should be specified in the successor nodes of the template node. Create the successor nodes under the template node.
a. It is best to create one folder node for each line, for clarity purposes. The folder node is actually used to combine related nodes.
b. For folder nodes, the input fields should be specified in the Output structure box, with the fields Line and Column. Assign each node to the cell in which the output needs to appear. Several nodes can be assigned to one cell.
c. The output sequence within the cell is determined by the sequence of the nodes in the tree
Now we have reached the step of merging data into a form during run time, since the form design is over. This data primarily comprises of
a. Data selected from database tables of the SAP system.
b. Data provided by the SAP Standard or by Smart Forms (for example, the date or the current page number).
c. Data that has been calculated or introduced in the form, for example table totals. This data is displayed using fields as placeholders in the form to determine how and where to display this data. Smart Forms provide the following possibilities to merge data into the form.
i. A form interface in which you define parameters for application data.
ii. Global definitions to define fields like internal tables, work areas.
iii. System fields whose contents are predetermined.
7. To define the form interface, use the node Global settings => Form Interface. Here the parameter names for the data to be passed should be entered. These names will be valid throughout the form; and they need not correspond to the variables names in the data retrieval program.
a. The export and import parameters can be of any data types.
b. Tables with a flat structure only can be passed on the Tables tab. While defining the fields, take care to enter the appropriate reference type. A type can be assigned using the keywords LIKE or TYPE. Double-click on the reference type to display its definition.
c. Use the local check on each tab page to check your entries for the form interface.
8. Within a form you can use the field string SFSY with its system fields. During form processing the system replaces these fields with the corresponding values. The field values come from the SAP System or are results of the processing. The various system fields that can be used in smartform development are listed below.
a. &SFSY-DATE&
Displays the date. You determine the display format in the user master record.
b. &SFSY-TIME&
Displays the time of day in the form HH:MM: SS.
c. &SFSY-PAGE&
Inserts the number of the current print page into the text. You determine the format of the page number (for example, Arabic, numeric) in the page node.
d. &SFSY-FORMPAGES&
Displays the total number of pages for the currently processed form. This allows you to include texts such as 'Page x of y' into your output.
e. &SFSY-JOBPAGES&
Contains the total page number of all forms in the currently processed print request.
f. &SFSY-WINDOWNAME&
Contains the name of the current window (string in the Window field)
g. &SFSY-PAGENAME&
Contains the name of the current page (string in the Page field)
h. &SFSY-PAGEBREAK&
Is set to 'X' after a page break (either automatic or command-controlled)
i. &SFSY-MAINEND&
Is set as soon as processing of the main window on the current page ends
j. &SFSY-EXCEPTION&
Contains the name of the raised exception. You must trigger your own exceptions, which you defined in the form interface, using the user_exception macro (syntax: user_exception <exception name >).
No comments:
Post a Comment