Professional Documents
Culture Documents
Smartforms
Smartforms
Smart form is a GUI Tool (Graphical User Interface) which is used to design the business
legal documents such as Delivery note, Purchase order, Invoice etc.
The transaction code is SMARTFORMS.
Smart forms are client independent objects.
Smart forms are advanced version of SAP Scripts.
It is a GUI tool and it is user friendly.
COMPONENTS OF SMARTFORMS.
There are two main nodes in Smart forms.
1. Global Settings
Form Attribute.
Form Interface.
Global Definition.
Global settings:
It is used to provide the basic settings for the smart form.
Form Attributes:
It specifies the general attributes like who created, Date, time, package, translate options, default
smart style, 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.
(In this example, we will print a simple text using our form. To create a text, expand “Pages and
Windows” New Page. Select Main Window and Right click on that. Select Create Text )
Whenever we activate a smartfrom, one function module will be generated, when we execute it, it
will go to function module.
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.
Expand page, double click on main window, right click on main window -> create -> text.
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 smart forms 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).
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).
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.
Add internal table IT_MARA and work area WA_MARA as looping parameters.
Click create
Create LOGO window and Add Graphic
Save and Activate, then Execute
Go to global definition to define variables for actual price calculation and for changing date format.
Below variables for actual price calculation
These variables to change Date format
Repeat same procedure for Customer window, Sales order window, Barcode window and Telno
window.
Adjust 7 windows properly in page1 (drag and drop)
Maintain Description
Select paragraph format --> right click then select create Node
Provide paragraph format : P1 , maintain description
Select Font option, provide font family COURIER , font size 12, font style BOLD
Select character format right click Create Node
Provide character format: C1, maintain description
Select Standard settings, in that provide BARCODE name : BC_EAN8 (sap provided)
Select font maintain font family COURIER , font size 12, font style BOLD
Select Header Data double click
In Standard Paragraph field provide Paragraph format : P1
SAVE and ACTIVATE Style
In smartforms Paragraph format and Character formats are reusable. Bcoz those are
maintain separately in Style. Where as in scripts this is not possible bcoz in scripts
Paragraph format and Character formats are maintain with in form itself.
Select Customer window Right click, Create -> Flow logic -> Loop
Provide Internal Table : ITAB INTO ITAB ( equal to: Loop at ITAB .. Endloop.)
Select customer window, from that select %loop customized, Right click->Create->Text
to maintain variables with in loop.. endloop for customer window
from General Attributes, select Text editor, GOTO -> Change editor
BACK (F3)
Select Sales window, Right click -> Create -> Flow logic -> Loop
Select sales window then %loop customize, Right click -> create-> Text
to maintain variables with in loop.. endloop for sales window
from General Attributes, select Text editor, GOTO -> Change editor
BACK (F3)
Select MAIN window ,Right click-> create -> Table
Select Table , put cursor on %LTYPE1, Right click -> Split -> Line , %LTYPE2 will be added
automatically.
select LTYPE1 -> Right click -> Split -> Cell
select LTYPE1 -> Right click -> Split -> Cell
select LTYPE1 -> Right click -> Split -> Cell
select LTYPE1 -> Right click -> Split -> Cell
it will create 5 columns.
Repeat same procedure for LTYPE2 ( 5 columns)
Select Details provide Description for LTYPE1 and LTYPE2 as LABELS and DATA
Select Table Painter , Select Pattern, choose one of pattern from this list to Main window
From table select Header Right click -> create -> Table line
click on cell1 Right click ->Create -> Text, from General Attributes,
Text editor, GoTo -> Change editor
BACK (F3)
click on cell2, cell3, cell4, cell5 repeate same procedure and keep labels MATERIAL, QUANTITY, PRICE
and DISCOUNT
From Tables select MAIN Area, to keep variables for Data, Right click -> Create-> Flow logic-> Loop
select %loop customized in Main Area, Right click -> create -> Table Line
BACK(F3)
select cell7, Right click-> create->Text. from General Attributes, Text editor, GoTo -> Change editor
* &ktab-MATNR& BACK(F3)
select cell8, Right click-> create->Text. from General Attributes, Text editor, GoTo -> Change editor
* &ktab-kwmeng& BACK(F3)
select Text customize of cell8, Right click-> create->Flow Logic->Program Lines.
BACK(F3)
Select Tele No window , Right click -> Text. from General Attributes, Text editor, GoTo -> Change
editor
BACK(F3)
From Main window, click on Table, select DATA tab
Tables: kna1, vbak,vbap.
* selection screen logic to enter sales order number
parameters: sorder type vbak-vbeln OBLIGATORY.
*Declare internal tables for customer window, sales order window and Line It
em window
data: it_itab type STANDARD TABLE OF kna1,
it_jtab type STANDARD TABLE OF vbak,
it_ktab type STANDARD TABLE OF vbap.
data: fm_name type rs38l_fnam. "rs38l_fnam is predefined data element for na
me of Function module
data: v_spool type ssfcrescl. "ssfcrescl is a predefined database structure
to print parameters in smartforms
data: v_spoolno type rspoid. "rspoid is predefined data element to generates
spool request number
* SQL statement to check and extract sales order number entered in selecctio
n screen
select * from vbak into table it_Jtab where vbeln = sorder.
*SQL statement to extract customer data and line item data based on sorder
no having in IT_JTAB
If not it_jtab is initial.
select * from kna1 into table it_itab FOR ALL ENTRIES IN it_Jtab
where kunnr = it_Jtab-kunnr.
select * from vbap into table it_ktab FOR ALL ENTRIES IN it_Jtab
where vbeln = it_Jtab-vbeln.
Endif.
*select pattern select call function : SSF_FUNCTION_MODULE_NAME click ent
er
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSALES_ORDER_FORM'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME " system generated function module
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION FM_NAME "is used to pass data into the form based on inp
ut value entered by user
IMPORTING
sorder = sorder
job_out_info = v_spool
TABLES
itab = it_itab
jtab = it_jtab
ktab = it_ktab.
* logic to generate spool request number (it is used to send from FORM to P
rint program)
loop at v_spool-spoolids into v_spoolno.
endloop.
* logic to support FORM in PDF
submit rstxpdft4 with spoolno = v_spoolno.
OR
How to Debugg the SMARTFORM?
In Program Lines maintain Break-Point before code to switch on debugging.
NACE Transaction:
NACE is the Tcode used to link the Application type, Output Types and its processing Routines like (
Driver programs and attached Script forms or Smart forms).
You should know the Application of a document first Like:
for PO it is EF, for sales Doc's it is V1, for Delivery docs it is V2, for billing Doc's it is V3 etc
NACE is used for Output Type Configuration.
Goto Transaction NACE --> Select Application V1(Sales) --> Click on Output Types --> Select the
output type as BA00 (as generally BA00 is the output type associated with Sales Order ) --> Double
click on the Processing Routines folder on the left and it will display the Form name and the
corresponding driver programs name.