a beginners guide sap smart forms

61
Page 1 of 61 Copy Rights Reserved @ SAP Document Info Introduction to SMARTFORMS

Upload: sapfico2k8

Post on 27-Dec-2015

155 views

Category:

Documents


6 download

DESCRIPTION

A Beginners Guide Sap Smart Forms

TRANSCRIPT

Page 1: A Beginners Guide Sap Smart Forms

Page 1 of 61 Copy Rights Reserved @ SAP Document Info

Introduction to

SMARTFORMS

Page 2: A Beginners Guide Sap Smart Forms

Page 2 of 61 Copy Rights Reserved @ SAP Document Info

Table of Contents

INTRODUCTION

PURPOSE OF THIS INTRODUCTION…………………………………………. 3

WHO WILL BENEFIT………………………………………………………. 3

PREREQUISITES…………………………………………………………… 3

REFRESHER ON SAPSCRIPT………………………………………………… 3

SMART FORMS: WHAT IS IT?……………………………………………… 3

SMARTFORMS VS SAP SCRIPT…………………………………………… 4

MAIN ADVANTAGES OF SMART FORMS…………………………………… 4

FEATURES INTRODUCED BY SAP IN SMART FORMS………………………… 4

ARCHITECTURE OF SAP SMARTFORM……………………………………… 5

HANDS ON SCREEN SEQUENCE

SMARTFORMS……………….……………………………………………. 7

PAGE AND WINDOWS……………………………………………………… 12

SMARTSTYLE……………………………………………………………… 28

TEMPLATE………………………………………………………………… 38

CONFIG SETTING…………………………………………………………... 54

REFRESHER ON SMARTFORMS : SUMMARY……………………………… 58

Page 3: A Beginners Guide Sap Smart Forms

Page 3 of 61 Copy Rights Reserved @ SAP Document Info

Introduction

Purpose of this Introduction

This introduction is intended to allow a quick entry into the work with the Smart Forms. SAP introduced

SmartForms in 1998 to overcome the limitations in SAP Scripts. This document would help a beginner to

start from scratch and generate his own Smart Forms. There is a self help screen sequence to guide the

beginners to create Smartforms of their own and gain confidence

Who will benefit

All SAP users. Most of the new projects would be using this technology. Clients would increasingly

demand smartforms to be used rather than sapscript.

Prerequisites

The user should know SAP Script. In this document I would briefly compare SAP script with SAP

SMART Forms, highlighting the prominent features before moving on to how to work with SMART

Forms, which is our focus.

SAP Script is SAP text management and form printing tool. By this we make a output look beautiful which

is cumbersome to do by a report program.

SAPscript consists of the following components:

An editor for entering and editing text Styles and forms for designing the print layout

A composer, which is the central module for output formatting

A programming interface for integrating SAPscript components in your own application programs

and programming the output using forms

Various database tables for storing texts, styles and forms

Smart Forms: What is it?

We use SAP Smart Forms to create and maintain forms for mass printing in SAP Systems. SmartForms are

easier to develop, maintain and transport than SAP Script.

As output medium SAP Smart Forms support a printer, a fax, e-mail, or the Internet (by using the generated

XML output).In addition to the tool, SAP delivers a selection of forms for central business processes like

forms in the applications SD,FI, HR and CRM of the R/3 Release.

Refresher on SAP Script

WE can insert picture or Logo (Company Logo) in the output, which is not possible by report

program. NOTE

Page 4: A Beginners Guide Sap Smart Forms

Page 4 of 61 Copy Rights Reserved @ SAP Document Info

SmartForms Vs SAP Script

Multiple page formats are possible in smartforms which is not the case in SAPScripts

It is possible to have a smartform without a main window .

Labels cannot be created in smartforms.

Routines can be written in smartforms tool.

Smartforms generates a function module when activated.

Main Advantages of Smart Forms:

SAP Smart Forms offer the following advantages:

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

The SAP Smart Forms has replaced the SAPscript forms. SAPscript forms will also be supported in the

future; you can use them without making any changes for years to come. You can use SAPscript texts in

the Smart Forms. Migration of SAPscript forms into Smart Forms is supported.

Features introduced by SAP in Smart Forms:

The smart forms allow the user to execute simple modifications to the form and in the form logic by

using simple graphical tools.

To print a form the user will need a program for the data retrieval and a smart form that contains the

entire form logic. As these two are separate we should adapt the smart form if changes to the form logic is

necessary. The application program passes the data via a function module interface to the smart form.

When activating the smart form the system automatically generates the function module and at the runtime

process this.

The user designs the form using the graphical form painter and the graphical table painter. The form

logic is represented by the hierarchical structure that consists of individual nodes, such as nodes for global

settings, nodes for texts, nodes for output tables or nodes for graphics. To make any changes we have to use

the Drag&Drop, Cut&Paste. These actions do not include writing of coding lines or using a script language.

For web publishing, the system provides a generated XML output of the processed form.

We can insert static and dynamic tables. These include the line feeds in the individual table cells,

triggering events for table headings and subtotals and sorting data before output.

The smart forms allow the user to include graphics, which can be displayed as a part of the form or as

background graphics. During printout the user can suppress the background graphic as and when necessary.

The smart forms also supports the postage optimizing.

Page 5: A Beginners Guide Sap Smart Forms

Page 5 of 61 Copy Rights Reserved @ SAP Document Info

Form Description

Data Retrieval

Database

SMART

FORM

Activate

ABAP

FUNCTION

MODULE

APPLICATION

PROGRAM

Database Selection

Function

Module

Call

Later

Selection

OUTPUT

(Printer)

Architecture of SAP Smart Form : Schematic Flow

Page 6: A Beginners Guide Sap Smart Forms

Page 6 of 61 Copy Rights Reserved @ SAP Document Info

In a smart form we describe:

The layout of the form (element positions on a page).

Individual elements to be displayed, for ex: text, graphics, addresses, tables etc.,

The form logic, for example to read the application data from internal tables, to introduce conditions

and to control the process flows.

A form interface to transfer the application data to form definition.

When a smart form is activated , the system generates a function module that encapsulates all the attributes

of the smart form.

As soon as the application program calls the function module, the smart form uses the module interface to

transfer any table data previously selected and to print the form according to the form description.

All these will become clearer once we go through the self help screen sequence in the subsequent pages.

Page 7: A Beginners Guide Sap Smart Forms

Page 7 of 61 Copy Rights Reserved @ SAP Document Info

Hands On Guide: This is a self-help guide lucidly illustrated with tips, meant for beginners.

We first go to SAP Menu: The path is SAP Menu Tools Form Printout Smart Forms

The transaction code (T code) : Smart Forms

Lets use forms starting with ‘BC’ as SAP has created these for training purposes.

click

Page 8: A Beginners Guide Sap Smart Forms

Page 8 of 61 Copy Rights Reserved @ SAP Document Info

Let’s use BC470_FLOWS to demonstrate the various elements of Smart Forms.

We now arrive at the Display Form screen, which is divided, into 3 main sections:

Navigation window, Form painter and Maintenance window. We will discuss each of these in detail

Navigation window consist of nodes and sub nodes. They contain all the elements (text, window

etc) that belong to sap forms.

click

Page 9: A Beginners Guide Sap Smart Forms

Page 9 of 61 Copy Rights Reserved @ SAP Document Info

Maintenance window shows attributes of the elements

Form printer window shows the layout of the page.

Global setting is at the form level. You can access these from anywhere in the smart form

You can change the language by changing this field in Form Attribute: this will change the text

language (but not the layout).

Form interface tells us what are the import and export parameters, exceptions, tables etc that we

pass to the function module. These we can add but we cannot change/modify the default values

SAPscript does not allow changing the language. SAP FORMS gives the user

this option.

Also whenever we create smart forms, SAP creates/generates a function module. NOTE

Page 10: A Beginners Guide Sap Smart Forms

Page 10 of 61 Copy Rights Reserved @ SAP Document Info

Lets add a Global Database for practice. I have created NUMC_DATE through TYPES

new type created in TYPES

Page 11: A Beginners Guide Sap Smart Forms

Page 11 of 61 Copy Rights Reserved @ SAP Document Info

Global definition is what we define in smart form. We can define our own variable, constants etc. that we

can access in the code that we write. Here we would use we of the types, which we have defined earlier

(char_fifteen) to declare ‘CLERK’.

Diff between TYPE and TYPES

TYPES: What we create: char, constants etc. TYPE is used to choose from standard SAP data type

What we created in

‘Types’ is being used to

declare a variable.

Page 12: A Beginners Guide Sap Smart Forms

Page 12 of 61 Copy Rights Reserved @ SAP Document Info

Pages and Windows

In smart form, page is at the highest level: SAP processes the first page, next page and then Terms

General Terms and Conditions…if u wish to change the order, just drag and drop the sequence.

1 OF 10 ETC initialize or increase counter

Page 13: A Beginners Guide Sap Smart Forms

Page 13 of 61 Copy Rights Reserved @ SAP Document Info

Conditional break…next page of next page become ‘term’ page (SAP stops processing /

execution of this page)

U can define print mode globally for all the pages instead of declaring this at each page

Page 14: A Beginners Guide Sap Smart Forms

Page 14 of 61 Copy Rights Reserved @ SAP Document Info

Now lets create our own smart form Let’s copy a standard smart form [BC470_FLOWS]of SAP

and create ZBC470_FLOWS_AVID. Then we would play around with its different elements.

Lets create a new page in our object.

Page 15: A Beginners Guide Sap Smart Forms

Page 15 of 61 Copy Rights Reserved @ SAP Document Info

This is the page we created. Lets name it as ‘Test1’.

I have changed the sequence by dragging and drop. Now Test1 appears before the First Page.

Printing will take place on the basis of ‘next page’ field.

But processing will happen as per the sequence in navigation window!

NOTE

Page 16: A Beginners Guide Sap Smart Forms

Page 16 of 61 Copy Rights Reserved @ SAP Document Info

For background picture and graphics you can pick up either black and white or color bitmap images and are

stored in the form of standard texts. We take a detour from the smartform screen and open Form Graphics

screen. Transaction code: Se78

Now lets go back to the main screen ……Background Pic

Page 17: A Beginners Guide Sap Smart Forms

Page 17 of 61 Copy Rights Reserved @ SAP Document Info

Here there are 3 options : Black and white, color and dynamic bitmap pictures. We name the background

picture and choose the determine dynamically option.

Note: Runtime color …….use the field with ampersand.

Page 18: A Beginners Guide Sap Smart Forms

Page 18 of 61 Copy Rights Reserved @ SAP Document Info

Now after the Page, we create a new Window. There will be output options, attributes and conditions in

each window.

Page 19: A Beginners Guide Sap Smart Forms

Page 19 of 61 Copy Rights Reserved @ SAP Document Info

Cannot use main in this field because SAP creates Main by default and doesn’t allow main as name.

We cannot have more than 1 main window in a page. We can have multiple

secondary windows

Whatever u print in secondary window…it has to be static. (If u have 20 lines

in a PO and there is page constraint the lines get carried forward to next page

in the main window. i.e. In a predecessor and successor type of content, they

will be printed in sequence in main window. This is not allowed in Secondary

windows.

NOTE

Difference in Main and Secondary Windows in a Form

Page 20: A Beginners Guide Sap Smart Forms

Page 20 of 61 Copy Rights Reserved @ SAP Document Info

You can have only we main page which u can stretch to multiple pages (you can copy and stretch it) but

you can have multiple secondary windows.

Inside the main window we can add text as introduction to customize the form output. In Smart Form

what you see is what you get.

Page 21: A Beginners Guide Sap Smart Forms

Page 21 of 61 Copy Rights Reserved @ SAP Document Info

In the output, we have the option of sizing and positioning the main window along with different

shading and color choices.

We can have conditions….to be executed at run time We take an example to illustrate this.

Page 22: A Beginners Guide Sap Smart Forms

Page 22 of 61 Copy Rights Reserved @ SAP Document Info

By default this will be AND.

Page 23: A Beginners Guide Sap Smart Forms

Page 23 of 61 Copy Rights Reserved @ SAP Document Info

Now we come to the last part of the Pages and Window Section i.e. the Address element.

Note: CAM = Central Address Management

e.g. Based on the country, we may take country specific format (e.g. in US the ZIP code is must, while

in India it is not a mandatory field.)

Some practical examples of conditions in a window in Form could be that, on the

first page, we want the Company Logo and address of customer but on

subsequent pages we don’t want customer address. Similarly we may wish to

have signature only at the last page. Appropriate conditions/flow logic can be

inserted here to take care of these situations. We can give flow logic for both

main and secondary windows.

NOTE

Page 24: A Beginners Guide Sap Smart Forms

Page 24 of 61 Copy Rights Reserved @ SAP Document Info

Lets create a new address. It can be of 4 types: Personal, Official, Organization address or it may be

determined during runtime based on the selection parameter (Dynamically determined).

U need to find address number only and everything else will be populated

The attributes could be of 3 types: Text element, Include Text and Text module

We would then fill up text name: static or dynamic, text object (e.g. TEXT) and text id (e.g. ADRS)

Page 25: A Beginners Guide Sap Smart Forms

Page 25 of 61 Copy Rights Reserved @ SAP Document Info

We then number the pages in the footer space provided

and write our code as text element.

Page 26: A Beginners Guide Sap Smart Forms

Page 26 of 61 Copy Rights Reserved @ SAP Document Info

we can use the System Fields in Data Dictionary table SFSY compwents while writing

the logic for Smartform

Lets add a new text element ‘TXT1’ choosing appropiate paragraph and character formats.

Page 27: A Beginners Guide Sap Smart Forms

Page 27 of 61 Copy Rights Reserved @ SAP Document Info

We can have our own smart style : paragraph as well as character formats. Lets check out a standard

style before creating our own!

The header data in each smart style allows us to configure font size, line and character spacing.

SAP provides different paragraph formats for standard, header and footer, centered and totals.

Page 28: A Beginners Guide Sap Smart Forms

Page 28 of 61 Copy Rights Reserved @ SAP Document Info

Lets create a paragraph AV (which is deleted after the exercise).

Page 29: A Beginners Guide Sap Smart Forms

Page 29 of 61 Copy Rights Reserved @ SAP Document Info

Now it comes in the form as the menu of Paragraph Formats in the SAP Smart Form.

Note : AV has come in the menu. Alignment is as per the paragraph format AV.

Page 30: A Beginners Guide Sap Smart Forms

Page 30 of 61 Copy Rights Reserved @ SAP Document Info

Lets create a new style (ZBC470_avi) with 2 paragraph formats and we character format

The newly created paragraph font (e.g. AV) won’t be part of global settings. If

we change the form attribute - output options-- and style to some other

style (like from BC470 to BC 470_STYLS) this option would no longer be

there.

NOTE

Page 31: A Beginners Guide Sap Smart Forms

Page 31 of 61 Copy Rights Reserved @ SAP Document Info

Now I mention in form attribute my own style

I check out my output in the next page form.

Page 32: A Beginners Guide Sap Smart Forms

Page 32 of 61 Copy Rights Reserved @ SAP Document Info

When you create a table, SAP automatically creates 3 areas: Header, Main and Footer. In Main Area,

there are many cells, which are processed record by record.

In Main Area, we create different cells. In Table painter, we draw the format as per client requirement (e.g.

Heading, Sub Heading, Item, Sub Total, Grand Total etc.)

We use the table layout to determine:

The number of lines and cells

The height of each line

The width of each cell

The alignment of the table in the window

Whether and where to display separator lines or frames

We can either draw the table by visual aid or we can click on details button and set the area allotted to each

cell by filling in the measurements.

Click

Page 33: A Beginners Guide Sap Smart Forms

Page 33 of 61 Copy Rights Reserved @ SAP Document Info

Click

Page 34: A Beginners Guide Sap Smart Forms

Page 34 of 61 Copy Rights Reserved @ SAP Document Info

In Data Painter, we can process the data before displaying it in SMARTFORM. SAP provides us with

the option of putting some basic logic. E.g. Loop, Where condition, Option of Row-by-Row selection,

Sort Condition, At the end of table processing: Events (provided by SAP).

Page 35: A Beginners Guide Sap Smart Forms

Page 35 of 61 Copy Rights Reserved @ SAP Document Info

For easy navigation and access, SMARTFORM provides Field List option. We can activate that by

Utilities- Field List on/off.

We can put conditions/logic by putting ABAP code inside ‘bookings’ main area, Program Lines. Here

we first declare the input and output parameters.

Page 36: A Beginners Guide Sap Smart Forms

Page 36 of 61 Copy Rights Reserved @ SAP Document Info

Here we put the text element as per paragraph and character format. We may have a text which is

determined during run time (dynamic).

Now lets create our own table. Here we can put logic as per client requirement.

Page 37: A Beginners Guide Sap Smart Forms

Page 37 of 61 Copy Rights Reserved @ SAP Document Info

Whenever you wish to write your code in SAP Smartform, you have to create the proper flow logic. We use

‘command’ to code any conditions for going to the next page

TEMPLATE: Template is used when we know the exact size of the output or

the output is in a fixed format. E.g. Tax form/ cheques /airline form/railway

ticket: all these use templates.

Diff between table and template: In Table the height changes dynamically.

We call a row a ‘line’ in template.

NOTE

Page 38: A Beginners Guide Sap Smart Forms

Page 38 of 61 Copy Rights Reserved @ SAP Document Info

This is to terminate the current page and start processing the new page.

Page 39: A Beginners Guide Sap Smart Forms

Page 39 of 61 Copy Rights Reserved @ SAP Document Info

In Smartform, We can process our own logic. We can call some table, select some data do standard data

manipulations through this. In navigation wndow, First Page-- Main Window -- Create -- Flow

Logic -- Program line. But it is advisable not to write programs here as it slows down the process. It is

advisable to write the code in print program.

This is very similar to table. If you wish to dynamically determine the output, we can loop at internal table

Page 40: A Beginners Guide Sap Smart Forms

Page 40 of 61 Copy Rights Reserved @ SAP Document Info

Flow Logic: Alternative: In this we can embed ‘If - else’ kind of logic.

Page 41: A Beginners Guide Sap Smart Forms

Page 41 of 61 Copy Rights Reserved @ SAP Document Info

If what we type here is True then it will get processed under the True button.

We next explore another feature of Smartform: Folder

Folder is used to modularize the navigation; it has nothing to do with technical thing. The order you

mention in the folder is the order that SAP will process.

Page 42: A Beginners Guide Sap Smart Forms

Page 42 of 61 Copy Rights Reserved @ SAP Document Info

There is an option given in Smartforms. We can migrate old SAPscripts to smartforms.

Note: We should check the text elements and make sure the flow logic works in the new format.

Here I am migrating a previously created SAP script to Smartform.

Page 43: A Beginners Guide Sap Smart Forms

Page 43 of 61 Copy Rights Reserved @ SAP Document Info

In Function Module screen, (se37)

To get the function module name, after saving and activating the form, go to Environment – function

module name. This function module name has to be given in the main program to call the form.

Else go to function module SSF_FUNCTION_MODULE_NAME and give the name of the program.

In the print program mentiwed below, populating certain fields from database tables into it creates an

output internal table. Once the output internal table is ready, then the function module

SSF_FUNCTION_MODULE_NAME is called. Here, in the import parameters, the name of the smart

form is given. The output of this function module is the name of another function module.

This function module is again called, in this example, the name of the function module is

"/1BCDWB/SF00000007”.

So, in case of smart forms, we use 2 function modules for the processing of the smart form. Once this

internal table is thrown from the smart form, then in the layout, the required fields can be displayed.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

CALL FUNCTION '/1BCDWB/SF00000007'

Page 44: A Beginners Guide Sap Smart Forms

Page 44 of 61 Copy Rights Reserved @ SAP Document Info

Page 45: A Beginners Guide Sap Smart Forms

Page 45 of 61 Copy Rights Reserved @ SAP Document Info

we have to mention this name (of function module) in the print program.

Supposing we want to print a Purchase Order:

We need to have a print program and a smart form name to be given in the customizing settings. Also in the

print program, we call the function name we got from above.

Let’s check out the print program SAPBC470_PROGS.

Page 46: A Beginners Guide Sap Smart Forms

Page 46 of 61 Copy Rights Reserved @ SAP Document Info

In this program we have the SSF_FUNCTION_MODULE_NAME. We execute the program.

This calls the SAP Smart form. We are checking the output in Monocolour.

Page 47: A Beginners Guide Sap Smart Forms

Page 47 of 61 Copy Rights Reserved @ SAP Document Info

This is the way our smart form looks.

Page 48: A Beginners Guide Sap Smart Forms

Page 48 of 61 Copy Rights Reserved @ SAP Document Info

SE37: We use the just created function module. /1BCDWB/SF00000007. We execute this.

Page 49: A Beginners Guide Sap Smart Forms

Page 49 of 61 Copy Rights Reserved @ SAP Document Info

CHECK PRINT

PREVIEW

Page 50: A Beginners Guide Sap Smart Forms

Page 50 of 61 Copy Rights Reserved @ SAP Document Info

We can set the background of the output as any file stored in our hard disk. We can call a graphics from

desktop or any other pic stored in the hard disk. Transaction code: SE78

Page 51: A Beginners Guide Sap Smart Forms

Page 51 of 61 Copy Rights Reserved @ SAP Document Info

Now let us delve in to configuration settings to modify our smartform as per requirement.

Creating output type and assigning smart form name in spro Spro –> materials mgt –> purchasing —> messages —> output control –> message types –> define

message types for Purchase order.

Page 52: A Beginners Guide Sap Smart Forms

Page 52 of 61 Copy Rights Reserved @ SAP Document Info

We can create our own message type. We can define various options like transmission medium here like

Print, Fax, EDI etc.

Select we output type and double click on processing routine to get the following screen. It will execute the

print program as soon as we call ‘neu’ message type. In the above screen, we can mention the name of the

smart form for that output type. Once this is dwe we can mention the output type in the purchase order

Page 53: A Beginners Guide Sap Smart Forms

Page 53 of 61 Copy Rights Reserved @ SAP Document Info

me22n: Lets take an existing P.O.

The Output is defined here in P.O.

Click

Page 54: A Beginners Guide Sap Smart Forms

Page 54 of 61 Copy Rights Reserved @ SAP Document Info

Page 55: A Beginners Guide Sap Smart Forms

Page 55 of 61 Copy Rights Reserved @ SAP Document Info

What we have discussed thus far, I will try to sum up:

Smart forms is very similar to SAP scripts. This is also a tool, which is extensively used to create

layouts, and then a separate print program is created. This print program is used to create the output internal

table, which in turn is thrown to the smart form where the field values are displayed.

SAP Smartforms can be used for creating and maintaining forms for mass printing in SAP Systems. The

output medium for Smartforms support printer, fax, e-mail, or the Internet (by using the generated XML

output).

These are the steps to create your own smartform:

1. Create a new smartforms

Transaction code SMARTFORMS

Create new smartforms call ZSMART

2. Define looping process for internal table

Pages and windows

First Page -> Header Window (Cursor at First Page then click Edit -> Node -> Create)

Here, you can specify your title and page numbering

&SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total Page)

Main windows -> TABLE -> DATA

In the Loop section, tick Internal table and fill in

ITAB1 (table in ABAP SMARTFORM calling function) INTO ITAB2

3. Define table in smartforms

Global settings :

Form interface

Variable name Type assignment Reference type

ITAB1 TYPE Table Structure

Global definitions

Variable name Type assignment Reference type

ITAB2 TYPE Table Structure

4. To display the data in the form

Make used of the Table Painter and declare the Line Type in Tabstrips Table

e.g. HD_GEN for printing header details,

IT_GEN for printing data details.

You have to specify the Line Type in your Text elements in the Tabstrips Output options.

Tick the New Line and specify the Line Type for outputting the data.

Declare your output fields in Text elements

Tabstrips - Output Options

For different fonts use this Style : IDWTCERTSTYLE

For Quantity or Amout you can used this variable &GS_ITAB-AMOUNT(12.2)&

5. Calling SMARTFORMS from your ABAP program

Refresher on SMART FORMS

Page 56: A Beginners Guide Sap Smart Forms

Page 56 of 61 Copy Rights Reserved @ SAP Document Info

REPORT ZSMARTFORM.

* Calling SMARTFORMS from your ABAP program.

* Collecting all the table data in your program, and pass once to SMARTFORMS

* SMARTFORMS

* Declare your table type in :-

* Global Settings -> Form Interface

* Global Definintions -> Global Data

* Main Window -> Table -> DATA

*

* Written by : SAP Hints and Tips on Configuration and ABAP/4 Programming

* http://sapr3.tripod.com

*

TABLES: MKPF.

DATA: FM_NAME TYPE RS38L_FNAM.

DATA: BEGIN OF INT_MKPF OCCURS 0.

INCLUDE STRUCTURE MKPF.

DATA: END OF INT_MKPF.

SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.

SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.

MOVE-CORRESPONDING MKPF TO INT_MKPF.

APPEND INT_MKPF.

ENDSELECT.

* At the end of your program.

* Passing data to SMARTFORMS

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZSMARTFORM'

* VARIANT = ' '

* DIRECT_CALL = ' '

IMPORTING

FM_NAME = FM_NAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

if sy-subrc <> 0.

WRITE: / 'ERROR 1'.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

call function FM_NAME

* EXPORTING

* ARCHIVE_INDEX =

* ARCHIVE_INDEX_TAB =

* ARCHIVE_PARAMETERS =

* CONTROL_PARAMETERS =

* MAIL_APPL_OBJ =

* MAIL_RECIPIENT =

* MAIL_SENDER =

* OUTPUT_OPTIONS =

* USER_SETTINGS = 'X'

Page 57: A Beginners Guide Sap Smart Forms

Page 57 of 61 Copy Rights Reserved @ SAP Document Info

* IMPORTING

* DOCUMENT_OUTPUT_INFO =

* JOB_OUTPUT_INFO =

* JOB_OUTPUT_OPTIONS =

TABLES

GS_MKPF = INT_MKPF

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

if sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

Additional Fonts for your SMARTFORMS

You can create additional fonts and style with transaction SMARTSTYLES

This can then be define in the paragraph and character formats, which you can then be assign to texts and

fields in the Smart Form.

The character formats includes effects such as superscript, subscript, barcode and font attributes.

Various Utilities and their functions in Smartforms

Creating Forms Using SAP Smart Forms

When creating a form we must:

Retrieve the application data

Describe the form

Pass the application data to the form

Retrieving the application data:

Write an ABAP program to retrieve data or include a retrieval routine into the application. This code

consists of statements that select data from databases according to certain selection criteria. Store the

retrieved data in internal tables, structures or variables and transfer it to the form in we step

.

Describing the Form:

The user defines the form using a smart form. Use the tools of the form builder as listed below:

Use the form painter to position the windows, graphics and addresses on a page.

Use the PC editor to write the texts.

Use the table painter to format the tables.

The flow control is used to print the pages and elements.

Form Logic

In the form builder we can describe a smart form by a set of nodes. To do this, we can build up a tree

structure on the left side of the user interface.

The node global settings and its three successors form attributes, form interface and global definitions

always exists for any newly created forms.

To describe the form logic, create the hierarchy under the node pages and windows.

The following rules apply to control the flow of the form output.

The nodes in the tree structure are processed from top to bottom.

Page 58: A Beginners Guide Sap Smart Forms

Page 58 of 61 Copy Rights Reserved @ SAP Document Info

For each node there is a tab, this can be used to link the node to a condition. If the condition is

true, the system processes the node. If not, it skips the node and all its successors.

We should define a next page for each page.

Graphical User Interface

The basic ABAP programming skills are required only in special cases like calling a function module or for

complex and extensive conditions.

The SAP form builder of the smart form consists of:

Form painter for creating the layout of the form

PC Editor for entering texts and fields into output areas

Navigation free for maintaining the form logic

Table painter for creating templates and tables

Form check

To define the text formats, we can use the Smart Styles.

The Form Painter:

The form painter offers the following functions:

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.

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.

The PC Editor:

The pc editor offers the following functions:

Enter, delete, select, cut and copy texts.

Assign paragraph and character formats.

Include, change and delete fields.

The Table Painter:

The table painter offers the following functions:

Drawing lines and columns

Inserting , cutting , copying and deleting lines

Deleting cells

Changing cell size and moving cell separator lines

Splitting cells

Selecting table patterns

Style builder:

On the left of the style builder screen consists of the predetermined nodes (header data, folder for

paragraph formats, folder for character formats).

On the right we can see the maintenance screen with its tab pages. At the bottom the preview of the

selected font can be viewed.

Field list and Error list:

The field list displays the following data in the form a tree structure:

Page 59: A Beginners Guide Sap Smart Forms

Page 59 of 61 Copy Rights Reserved @ SAP Document Info

All tables, fields and structures passed via the form interface.

System fields and the fields that are defined in the global definitions.

This allows we 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.

The error list contains the list of errors and warnings displayed at the bottom of the maintenance screen.

Node types:

When a form is created, the tree structure of the form painter contains two root nodes.

The successors of the global settings node are used to maintain form attributes, the form

interface and global definitions.

The successors of the pages and windows node to create the pages of the form, position elements

on these pages, and determine the sequence on how to process these created elements.

Basic elements of a form

Creating pages:

Each form consists of we or more pages. The first page in the tree structure is the start page and the

processing of the form starts with this page itself.

Open the context menu for existing page node and choose createpage

Enter a unique name for the node and a description

Determine the format and the mode of the page counter on the general attributes tab

Determine the print attributes of the page on the output options

Determine a background graphic for the entire page on the background tab

Creating windows:

We can set the size and position of the window graphically in the form painter. There are main windows

and subwindows. The difference between these two is that the output in a main window can cover several

pages.

Open the context menu for an existing page node and choosewindow

Enter a name for the node and a description

On the general attributes indicate whether the window is a main window. If sub window wants to

be created then leave the checkbox empty

Positioning texts on the form

The texts are displayed in the form using text nodes. The only exceptions are addresses. This uses its own

node.

The predecessor node of the text node determines its use:

Predecessor node Used to

Sub window [Position text on we or more pages]

Main window [Display text in relation to other nodes in the main window, it may cover

several pages]

Template [Displays texts for table cells of a static table]

Table [Display table contents]

Header and footer [Display column headings and grand totals in tables]

Event node [Display subtotals in a table]

There are three text types:

Text element : to enter new text in the PC editor

Text module : to include a text module

Include text : to include an existing SAPscript text

Page 60: A Beginners Guide Sap Smart Forms

Page 60 of 61 Copy Rights Reserved @ SAP Document Info

Entering texts in PC editor:

To create a text node call the context menu for that node in the tree structure that should receive the

text, then choose->text

Enter a unique name for the node and the node description

On the general attributes tab choose text element as text type

Enter the text in the PC editor

In the text node box choose whether the text should be started with a new paragraph or only

in a new line

Including text modules:

Text module of the text node is used to refer to an existing text module in the system. The text modules

can be used in two ways:

Refer to the text module. The text then appears read-only in the PC editor and is included

when the form is printed.

Copy the text module. The system then copies the text of the module and automatically

converts the text node into an editable text element.

To create a text node , call the context menu for that node in the tree structure that shall

contain the text and choose create->text

Enter a unique name for the node and a description

On the general attributes tab select the text type text module

Enter the name of the text module in the text name field

Including SAPscript texts:

We can use the text type include text node to refer to a SAPscript text that already exists in the system.

To identify the text the text name, object, id and the language is needed.

To create the text node call the context menu for that node in the tree structure that shall

receive the text and choose create -> text

Enter a unique name for the node and the node description

On the general attributes tab choose include text as text type

Inserting addresses:

We can use the address node to insert an address into the form. This guarantees that the address is

formatted according to the postal rules of the sender country.

To create an address node , call the context menu for that node in the tree structure that we

wants to contain the text and choose create->text

Enter a name for the node and a description

Determine the address type on the general attributes tab

For organizational addresses we have to specify the address number, for any other we have to

specify the person number and the address number

In the box additional addresses we can maintain other attributes to specify how to display the

address

Printing graphics:

Goto tcode se78 to import graphics into the SAP system. The transaction imports the graphics and

stores it in the BDS (business transaction server) and then it can be displayed in the form.

To create the graphic node , call the context menu for that node in the tree structure and

choose create->graphic

Enter a name for the node and the description

On the general attributes determine whether a colored or a black and white

Use the fields object , id and name to identify the graphic

Displaying a static table

Page 61: A Beginners Guide Sap Smart Forms

Page 61 of 61 Copy Rights Reserved @ SAP Document Info

Use node type template to display a table whose layout and size is determined before the runtime of the

print program.

To create a template define a table layout to determine the cell structure for each line. The cells are

used to display the cell structure for each line. The cells are used to display the contents of the

successor nodes of the template node. This allows us to position text and a graphic side by side.

The template node is also used for label printing. To use a template we must do the following:

Define the table layout

Display the contents in the table cells

Define the table layout:

The table layout is used to determine the following,

The number of lines and cells

The height of each cell

The width of each cell

The alignment of the table in the window

Whether and where to display separator lines or frames

Create a template node and maintain the attributes width, horizontal alignment and vertical alignment.

Use the table control on the template tab to define the layout of the lines. Each line of the template

must have a definition.

Use the pattern box to select the desired table pattern.

Displaying contents in cells:

The template node defines the table layout. The successor nodes of the template determine the data to

be displayed in the table cells.

Combining nodes:

The more extensive the form becomes, the lesser clear becomes the node hierarchy in the tree structure.

To avoid this we can combine the related nodes by appending them under a folder node.

llet" style="margin-left:1.75in;text-indent:-.25in;mso-list:l8 level1 lfo23; tab-stops:list 1.75in">

The width of each cell

The alignment of the table in the window

Whether and where to display separator lines or frames

Create a template node and maintain the attributes width, horizontal alignment and vertical alignment.

Use the table control on the template tab to define the layout of the lines. Each line of the template must

have a definition.

Use the pattern box to select the desired table pattern.

Displaying contents in cells:

The template node defines the table layout. The successor nodes of the template determine the data to be

displayed in the table cells.

Combining nodes:

The more extensive the form becomes, the lesser clear becomes the node hierarchy in the tree structure. To

avoid this we can combine the related nodes by appending them under a folder node.