Template, Table, Loop, Command
in Smartform
Applies To:
SAP 4.6C - Smartforms
Summary
This document explains how to use Table, Template, Loop to display the set of records in Smartform. It also
explains how to Command in Smartform. This document first selects the required data from database table.
After that it uses TEMPLATE in Loop to display the data. After that it makes use of COMMAND to display the
remaining data from next page. Then it uses LOOP to display the same data. After that again it makes use of
COMMAND for page break. Then it uses TABLE to display the data.
Table of Contents
Applies To: ................................................................................................................ .....................1
Template, Table, Loop, Command .......................................................................... .......................1
in Smartform................................................................................................................ ...................1
Summary................................................................................................................ ........................1
Table of Contents.................................................................................................................. ..........1
Procedure..................................................................................................................... ..................1
Template....................................................................................................................... ..................3
Command..................................................................................................................... ..................4
Loop........................................................................................................................................... .....4
Table.............................................................................................................................. .................5
Code Sample.................................................................................................................... ..............6
Output Screen: Template............................................................................................ ....................8
Output Screen: Loop.................................................................................................................. .....8
Output Screen: Table................................................................................................... ...................9
Procedure
Go to transaction SMARTFORMS.
Template, Table, Loop, Command
in Smartform
Create a Form (say zzz_test1).
In Global Definitions->Global Data,
Variable Name
Type Assignment
Reference Type
ZZZ_MAKT
TYPE
ZZZ_MAKT
ITAB
TYPE STANDARD TABLE OF
ZZZ_MAKT
WA
TYPE
ZZZ_MAKT
In Main window->Output Options, fill the necessary details as shown below.
Then right click Main window and create Program line.
In Code, give ZZZ_MAKT as input parameter and itab as output parameter.
Write the following in the coding part.
select * from zzz_makt into table itab.
Template, Table, Loop, Command
in Smartform
Template
Then right click Code and create a Loop.
In its Data tab,
Internal Table ITAB into wa
Right Click the Loop and Create a Template. In that, design the Template as shown below by selecting Pattern
to display Output.
Create three text elements (say Text2, Text4, Text3).
Drag ZMATNR, ZMAKTX and PICK from the Field list and put in the above mentioned Text Elements>General Attributes respectively.
In Text2->Output Options , make the Line and Column as 1 and 1 respectively.
In Text4->Output Options , make the Line and Column as 1 and 2 respectively.
3
Template, Table, Loop, Command
in Smartform
In Text3->Output Options , make the Line and Column as 1 and 3 respectively.
Command
Then Right Click the Loop and create a Command (say %COMMAND2). Make the Command after Template
(move accordingly).
We are making use of Command to page break.
In Command->General Attributes, check mark Go to new page and give the page no. (say %PAGE).
Then right Click the %CODE1 and create another loop and move it after %COMMAND2.
Loop
In Loop->Data,
Internal table itab into wa.
The settings of Loop->Output options is shown below [Since in the output, we are going to display a box with
border].
Template, Table, Loop, Command
in Smartform
Create a text element (say %TEXT1) under that Loop and design the Text->General Attributes as below.
Create a Command (say %Command1) under %Loop1 and do as we did before for %Command2.
Table
Right click %Code1 and Create a Table [say %Table1].
Design Table->Table tab as below.
Template, Table, Loop, Command
in Smartform
In Table->Data,
Internal table itab into wa.
Create three Text Element by right clicking %Table1 [say %CELL1, %CELL2, %CELL3].
Drag ZMATNR, ZMAKTX, PICK from fieldlist and put in the created text elements.
In CELL1->Output Options,
Check mark New Line and New Cell and choose the Line type as Line1 which we created in Table->Table.
For CELL2 and CELL3, check mark New Cell in Output options.
Code Sample
REPORT zzz_jaytest3 .
* Variable Declaration
6
Template, Table, Loop, Command
in Smartform
data : v_form_name TYPE rs38l_fnam.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname
= 'ZZZ_TEST1'
importing
fm_name
= v_form_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.
CALL FUNCTION v_form_name
EXCEPTIONS
FORMATTING_ERROR
=1
INTERNAL_ERROR
SEND_ERROR
=2
=3
USER_CANCELED
OTHERS
=4
= 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.
7
Template, Table, Loop, Command
in Smartform
Output Screen: Template
Then you can see the following output after executing the program in SE38.The following is the Output
because of Template.
Output Screen: Loop
This is the Output we will get for because of LOOP.
Template, Table, Loop, Command
in Smartform
Output Screen: Table
The following is the Output because of table.