Вы находитесь на странице: 1из 57

SAP (Smart Form)

Hi how are you I came back with


another thinks in SAP which is how
create the smart Form?
First what is the Smart Form and for
what use?
Use Smart Forms to create and maintain forms
for mass printing in SAP systems. Besides
using the printer for standard output you can
also select the Internet (by using a generated
HTML output), a fax, or e-mail as the output
medium.
In addition to the tool, SAP delivers a selection
of forms for central business processes. This
includes forms in Customer Relationship
Management (CRM) as well as in the
applications SD, FI, and HR.
Smart Forms offers the following advantages:
Creating and maintaining forms
requiring half the time
Adapting forms without any
programming knowledge due to entirely
graphical user interface
Integrating input elements into the
HTML output, which enables you to use a
form in Internet applications as well

Will enter direct to the case, here in this


case will create the smart form from
table name ZTOOLSREP which I
created by self and from this will make
print page like below and will use
internal table in the smart form itself:
this is the table:
And this is the records
contained:

And this is the print page will


create:
Now let start with the
case:

1- To create new Smart Form you


have to enter TCODE: smartforms:
Then the below screen will appear, in
this screen you can create Style which
you can use in the smart form such as
color style and font style or size:
2-Now create now name for smart form
and should start with Z or Y and click
create:
3- Under Global Setting click Form
Interface and in the right side select
Tables:
4- Under Parameter Name enter the
internal table (ITAB), Type
Assignment (LIKE), and Associated
Type the table (ZTOOLSREP): table
which I mentioned before. This mean
will define the internal table.

5- After that will create window folder


so go under the Pages and Windows on
%PAGE1 New Page right click >
create > window:
New window will appear above the
MAIN Main Window (this window will
be as Title):
6-In the right side will note that now
window as below:
So window1 will be title:

Expand the window1 screen to the right


as showing down, and right click to the
window1 >Create >Text:
Double click in the %TEXT NEW Text
1 and select in the right side General
Attributes and type the title
(EMPLOYEES TOOLS AND
TACKLES), also you can select
Paragraph Formats and Character
Formats:
7- Create again new window (window2)
which will be for single record.
As same in previous step right click on
window2 and create text, under General
Attributes type TOOLS NUMBER:
Then click in the Insert Fields (which
circled in red color) and type (&ITAB-
TOOLSNUMBER&), should start and
end with (&).
For more information: TOOLS
NUMBER: this will be on print page,
and (&ITAB-TOOLSNUMBER&) from
Internal Table field (ITAB) which will
be from database or table
(ZTOOLSREP).
As below screen you can know now
which the text and which will come from
database:
Note: This step only will show one
field or record which you select and in
coming step I will explain you how use
the internal table and fetching the data
from will database.

So, do same what you did in previous


step: such as:
Type: EMPLOYEE NO: Insert Fields:
&ITAB-EMPLOYEENUMBER&
Type: EMPLOYEE NAME: Insert
Fields: & &ITAB-
EMPLOYEENAME&
Type: DATE: Insert Fields: &ITAB-
BORROWDATE&
Now you will note that there are three
windows in the right side:
Window1 for Page Title,
Window2 for single records,
And the Main window we will use for
many records (Internal Table).
8- Right click on MAIN Window >
Create >Table as showing below:

If you click on table in right side you


will see the internal table mentioned as
%LTYPE1 and in the left side will
appear under Main Window %TABLE1
NEW Table 1and under it Header, Main
Area, and Footer.
Header: means header for the internal
table.
Main Area: the records inside the
internal table.
Footer: foot for the internal table.
9- In % TABLE1 New Table 1 click
Data as below and under LOOP Loop
type ITAB .
10-Rghit click on Header > Create >
Table Line.
11- Under Header click on % ROW1
New Line 1, in right side Output Options
select % LTYPE1 in the Line Type.
Now we are creating only header for
each fields in the internal table.
12-By using Pen make partition as
below four partitions:
13-On %CELL1 New Column1 right
click > Create > Text:
Type the (DOCUMENT NO).
14-Do same create text for %CELL2
New Column 2 and type (MATERIAL
NO).
15-Do same create text for %CELL3
New Column 3 and type (MATERIAL
DESCRIPTION).
16-Do same create text for %CELL4
New Column 4 and type (QUANTITY).
17-Now we are going to create for main
records or fields. So, right click on Main
Area > Create > Table Line.
18- On the %ROW2 New Line 2 Select
for Line Type (%LTYPE1). So,
automatically will appear CELLS as
below:
And we will insert fields in each cell.
So, right click on each cell and create
TEXT as in coming steps:
19- Create Text for cell5 and only Insert
Fields (&ITAB-GIVOURCHERNO&).

20- Create Text for cell6 and only Insert


Fields (&ITAB-MATERIALNO&).
21- Create Text for cell7and only Insert
Fields (&ITAB-
ITEMDESCRIPTION&).
22- Create Text for cell8 and only Insert
Fields (&ITAB-QUANTITY&).
Now you will note that there are 2
ROWs with cells one for header and one
for main area.
23- Now again create new window to
write some text, WINDOW3 and type
(CREATED/ISSUED BY: ----------------
----- TOOLS RECEIVED BY: -----------
---------------).

In the right screen you will see 3


windows and one main as below.
Reminder: WINDOW1 for Page
Title.
WINDOW2 will use
for single record.
MAIN will use for
many records from internal table.
WINDOW3 will use
for signature text.
24- Now click on MAIN Main Window
and in the right side click Output Option
and select frames and color as below.

25- Save and Active, it is good if you


use to save for each step or after some
steps.
After this we finish creating smart forms.
So, we have to create program to test
and run it.
26-Now go and create program named
ZPRTOOLTEST:
And type or copy these codes, you
should declare the ZTOOLSREP and
other parameters.

REPORT ZPRTOOLTEST.

**DATA T_SPFLI TYPE TABLE OF ZTOOLSREP


DATA FUNC_NAME TYPE RS38L_FNAM.
DATA ITAB LIKE STANDARD TABLE OF ZTOO

selection-
screen: begin of block B1 with frame title TEXT
001.
parameters: TOOLN TYPE ZTOOLSREP-
TOOLSNUMBER.

selection-screen: end of block B1.

START-OF-SELECTION.

SELECT * INTO TABLE ITAB FROM ZTOOLSR

read table ITAB INDEX 1.


if SY-SUBRC = 0.

ENDIF.

CALL FUNCTION 'SSF_FUNCTION_MODULE


EXPORTING
formname = 'ZTESTM'
* VARIANT =''
* DIRECT_CALL =''
IMPORTING
FM_NAME = FUNC_NAME
* EXCEPTIONS
* NO_FORM =1
* NO_FUNCTION_MODULE =2
* OTHERS =3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-
MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-
MSGV3 SY-MSGV4.
ENDIF.

***/1BCDWB/SF00000211

CALL FUNCTION FUNC_NAME


* EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
* CONTROL_PARAMETERS =
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'

* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
TABLES
itab = ITAB
* 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.
27-Save, Active and Test the program.
28- Will appear this screen so enter tool
number as below:

29-Then print screen will appear so


click on Print Preview.
This is the final.
1-The Window1 is used for page title.
2-The Window2 is used for single
record.
3-The Main Window (header) is used
header.
4-The Main Window (main) is used for
internal table many records.
5-The Window3 is used for Created text.