You are on page 1of 130

Getting started with Smart Forms (Building a simple

application)
By Sunitha

Go to transaction “Smartforms”.

Enter a name for the form and click on Create.

Enter a short description for the form.

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
Give a name to the text and short description.

Also enter the text you want to see on the form.

SAVE and Activate the Smart form.

To know the function module that is generated upon activation of this smart form, click on
Environment  Function module name.
Following popup with the function module would appear.

Test the smart form by clicking on Test. You would be navigated to the function builder with the
function module defaulting to the one that is generated earlier.

Click on execute.
Since we do not have any parameters to pass on, click on Execute.

Printing Address using Smart Forms


By Sunitha

Go to transaction “Smartforms”.
Enter a name for the form and click on Create.

Enter a short description for the form.

Expand “Pages and Windows” and click on “%PAGE1”. Rename the page to your needs and add
a short description to the same.

To display the address on the form, right click on “Main Window”, select Create  Address
Following screen appears.

Enter a name to the Address and add a short description for the same.

You all might be aware that Addresses are stored in the table ADRC. Now pick an address
number from that table, add provide the same in the “Address Number” as shown below:
Save and Activate the form.

Now execute the Smart form. The output would be similar as shown below:

Calling Smart Form using Driver Program


By Sunitha

Let us prepare a driver program for the Smart Form that displays the address (Click here to for
the demo on ADDRESS). This is a simple demo and doesn’t contain any parameter passing in
this example.

Check the function module that is generated when the Smart Form is activated by clicking on
Environment  Function Module Name.
A pop up would appear displaying the function module name.

We would use this function module in our driver program to call this function module.

Let us create a driver program with a simple call to the above generated function module:

REPORT Zcall_smartform.
* To call a smart form, we would need to call the function module that
* is generated.
* Calling the generated function module directly is not an efficient
* method. For efficient method, click here.
CALL FUNCTION '/1BCDWB/SF00000359'
* 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 =
* 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.
Execute the program for the output.

Displaying Graphics using Smart Forms


Go to transaction SE78 (Administration of Form Graphics).

Double-click on “GRAPHICS” node and click on “Import (F5)” to import the image.
Select the file name by using the F4 functionality available. Name your graphic and enter a short
description. If you have color image, select the radio button “Color Bitmap image”. Click on tick
mark to proceed.

The graphic is imported and is stored in “Business Document Server”.


You can test this by selecting print preview:

Now go to transaction SMARTFORM.

Create a new form and give a short description for the same.

To display an image, right click on Main Window  Create  Graphic


Use F4 help to fill the fields.
Save and activate the workflow.

Test run the smart form, to check the appearance of the graphic.

Passing data to the Smart Forms


Scenario: Let us take a simple scenario of passing Material Number and Material description
from Driver program to the Smart Form.

Go to transaction SMARTFORMS and create a Smart Form.

To pass the values from the driver program to Smart Form, we need to define the form interface
with the parameters to be passed on.

Click on Global Settings  Form Interface.


Now define the import parameters for MATNR and MAKTX (From table MAKT)

Now create a Text in the Main window to display the above two parameters.

To add a field, we need to click on “Insert Field”.


Enter the field names between the ‘&’ (Ampersand) as shown below:

Similarly create for Description.


Save and Activate the Smart Form. Test run the Smart Form by clicking on Execute.

Enter the values as shown below and click on execute.


Working with Global Definitions and Program Lines
Scenario: To calculate the total seats available using the values “Maximum seats available” and
the “Occupied seats”. In this case, we would be defining Maximum Seats and Occupied Seats in
the form interface and Seats Available in the Global definitions. We would write some code to
calculate Seats available and then print the same.

Procedure: Create a new smart form and, in the Form Interface, define the following two fields:
(To know about Form Interface, click here. )

Now click on “Global definitions” :

Now define a variable, SEATS_AVAIL


Now to calculate Seats Available, select Main Window  Create  Flow Logic Program Lines

Now mention the input parameters as SEATS_MAX and SEATS_OCC and the output parameter
as SEATS_AVAIL. Write the code to calculate SEATS_AVAIL.
Now to print these values on the layout, create a text by selecting Main
Window Create  Text:

Save and do the syntax check. Activate the Smart Form.

Test the smart form by clicking on F8. Enter some values for max_seats and avail_seats
Execute the function module.

Working with Secondary Window


Create a Smart Form using the transaction SMARTFORMS.

To create a Secondary Window,

Right click on Page  Create  Window (as shown below)


A secondary window is created.

To position the secondary window to meet our needs, click on Form Painter.

Following screen appears:


The highlighted window in the above screenshot is the secondary window.

Move the secondary window (and even stretch) according to your needs.

To close the above page design, click on Form Painter again.

Now let us write some content in these areas.


Now select the Page  Secondary Window

Right click on Secondary Window  Create  Text

Write some text inside.

Similarly, create some text in the Main window as well.


Save and activate the Smart Form. Test run the Smart Form; you would get the following output:

Demo on Copies Window (Real time scenario)


Scenario: To print three copies of a particular document and the first copy should mention as
Customer copy, second one as Bank copy and the third one say College copy.

Create a Smart Form using the transaction SMARTFORMS.

In this demo, we would print in the Copies window whether it is bank copy, company copy or
others.

Create a secondary window as shown below:


Select Window type as “Copies Window” as shown below:

Also name your window and give it a proper description. Do not change any other settings.
Adjust the window size using the Form Painter available on the application toolbar.

The variable SFSY-COPYCOUNT would provide us count of the copy whether it is a first copy,
second copy and others. We would use this field to print the owner of the copy.

We would define a string, which would hold the name of the copy (bank copy and others)
depending on the value of SFSY-COPYCOUNT. Define a variable in the global definition as
shown below:
Now select your Copies window, right click – Select Create  Flow Logic  Program Lines

Enter the following code:


Do not forget to enter the variable TEXT in the output parameters.

Now create a text by selecting the Copies window, right click Create  Text.

In this, just enter the field name as shown below by selecting insert field.

Now include a text in the Main window as well with some content.

Save and activate. Test your Smart Form.


In the print preview screen, enter the number of copies as 3

Check the output:


Working with Smart Styles
By Swathi, Wipro

Scenario: In this demo, we would create a small text as shown below with outline numbering as
shown below

Go to transaction “SmartStyles”
Enter a style name and click on Create.

Following screen appears:

To create a paragraph, click on folder “Paragraph Formats” and click on Create (as shown in the
above screenshot).

Following pop-up appears: Enter a paragraph format name.

Enter a suitable description for your graph and enter the left margin value as 2 CH.
Now select the tab “Numbering and Outline”:

Enter the Top Outline Paragraph as the current paragraph name and select “1,2,3..” from the list
for the Numbering Type.

Now create another paragraph format P2 as per the above method.

In the tab “Numbering and Outline” of P2, do the following:

Select the “Top Outline Paragraph” as “P1” and put the left delimiter as “.”. If the left delimiter is
not mentioned, the values would be displayed as “11, 12, 13...” instead of “1.1, 1.2, 1.3…”
Also, in the same window, check the “Number Chaining” Box. If this is selected, the parent value
would be displayed (like 1.1, 1.2, 2.1,2.2..). If this is not checked, only numbering would appear
like 1, 2,3 without the parent number prefixing.

Save and activate your Smart Style.

Now go to transaction “SmartForms”.

Create a Smart Form and create a text in the Main Window:

Select the tab “Output Options” to mention the Smart Style to be used.
Now go to tab “General Attributes”.

Select the icon “Txt Editor” (Though the text could be written directly on this screen, we are
avoiding this method for easy understanding to the consultants who are used with SAP Script
editor)

Now to change the editor, Click on “Goto” -> Change Editor

Here enter the desired text:


Return to the main screen of the Text. The screen would appear as follows:

Save and activate the Smart Form. Test run the Smart Form. Following would be the output:

Smart Forms - Working with Loop


By Venkat

Step1: Provide the name of the smart form is YDEMO_LOOP on the initial screen of the smart
form and meaningful description.

Step2: Now go to Global definitions where we can define the Global data, Types, Initialization
and etc.

Define Structure using Types Parameter as shown below. In Types parameters we usually define
user defined data types.

Step3: Now define the internal table and work area in Global Data parameter.

Step4: In Initialization parameter, we can write a code as shown below. We have to mention the
output result in the output parameter so that we can use it further. Here in this case we are
outputting IT_TAB and we are going to use this IT_TAB further in the LOOP in the Flow Logic.
Step5: Create a LOOP statement as shown below.

Step6: Now Loop the internal table.

Step7: To create the character, paragraph formats and Tabs, we use the smart style. The
transaction for create smart style is SMARTSTYLE or we can be created the initial screen
ofSMARTFORMS. Here SMART STYLE is created to define Tab positions for the columns.
Step8: Create a node for PARAGRAPH FORMAT as shown below.

The following screen appears.

Step9: Now define the Tabs as shown below.


Step10: Now Import SMART STYLE in to the SMART FORM as shown below.

Step11: Now create a text element for the loop statement.

Step12: Save and activate the smart form. The output is as shown below.
Designing Tables in Smart Forms
By Venkat

Step1: T-code for smart forms is “SMARTFORMS”. Provide the name of the smart form.
And provide the short text for this smart form “YDEMO_TABLE”.

Step2: Now go to Global definitions where we can define the Global data, Types, Initialization
and etc.

Define Structure using Types Parameter as shown below. In Types parameters we usually define
user defined data types.

Step3: Now define the internal table and work area in Global Data parameter.

Step4: In Initialization parameter, we can write a code as shown below. We have to mention the
output result in the output parameter so that we can use it further. Here in this case we are
outputting IT_TAB and we are going to use this IT_TAB further in the Table painter.
Step5: Now we create a Table painter as shown below.
Step6: Now we define number of table columns in %LTYPE1. Here, %LTYPE1 is renamed as
LINE as shown below.

Here, in this scenario we have to divide the LINE area into 4 columns as we have to display 5
columns. To draw a line we have to select Draw lines and columns button as shown above.

Step7: Now we have to create Table line for Header and Main area of Table painter as shown
below.
Here we have to provide line type. Here, the line type is LINE.

Step8: Provide the text for all columns.

Step9: Repeat the same process to the Main Area too.

Step10: Now Loop the internal table data as shown below.

Step11: Save and activate the smart form. Execute the smart form now. The output is as shown
below.
Using Text Modules in Smart Forms
By Jaya Vani B, YASH Technologies

Step1: Go to transaction smart forms.


Step 2: Click on create. The following screen appears:

Step 3: Enter the required text and save.

Now this text can be included in our smart form.

Go back to smart forms initial screen, and create a smart form.

Step 4: In the Main window create a text box.


Step 5:In the text box general attributes TAB select Text module from the drop down list

Step 6: Give the name of the Text Module created and click on COPY button.
Step 7: The text in the text Module will be copied into the Text Editor.

Step 9: Save and activate. Execute and check the print preview.

Passing Select-Options to Smart Forms


By Venkat

Step1: Create a Structure ZSELECTION in SE11 with following fields.


This structure is similar to the selection-option internal table.

Step2: In smart form ‘ZSELECT_FORM’, create an entry in to TABLES in the Form Interface.

Step3: Define Structures in TYPES tabs in GLOBAL DEFINITIONS.

Step4: In Global Data,


Step5: In program line, write the following code.

Step6: The PERNRS given in the select-option in the driver program is captured in T_SELECT.
In program lines, T_SELECT is input to SELECT query and the results are captured in internal
table T_0002. We have to mention resulted internal table T_0002 in output parameters for further
use.
Step7: Now, loop the internal table T_0002 as shown below.

Step8: Create driver program ‘ZSELECT_FORM_REP’. Write the following code in report.
Step9: Execute the driver program.

Step-by-step approach in creating a PO Layout using Smart


Forms
By Nageshwar, Satyam Computers

Smart Forms:

Transaction Code for Create Smart Forms: SMARTFORMS

Transaction Code for Create Styles (Paragraph Formats, Character Formats, etc.,) Used in
Smart Forms: SMARTSTYLES

Steps to be followed while creating Smart Forms:


1. Enter the Form Name (e.x. ZEKKO_EKPO) and Press Create

Button.

2. Enter Form Description and Select the “Output options” Tab  Enter the Page Format
(e.x. DINA4) and Style
(e.x.SF_STYLE_01).

3. Double click the Form interface Left Sub-tree.

4. Enter the Import Parameters (The values that passed from the Print Program into the
Form) (e.x. Company Code)

Parameter name Type assignment Reference type Default


value Pass value
COMPANY_CODE TYPE EKKO-BUKRS
R

5. Double click the Global definitions from the Left Sub-tree.

Assume that we are using two tables EKKO and EKPO in this example:

6. Click the “Types” Tab.

7. Enter the Code as following:


8. Click the “Global data” Tab.

Declare the Internal Tables and Work Areas as follows:


9. Double click the “%PAGE1 New Page” in the Left Sub-tree.

10. Change the %PAGE1 to “FIRST” or any name and Enter the Description (e.x. First
Page).

11. Select the Next Page as “FIRST”

12. Select the “Output options” Tab and select the format of the page (Portrait or
Landscape) and all other print attributes.
13. Select the “Background Picture” Tab, and Enter the Name, Object and Id of the image
file. (Before this step, go to SE78 and import the image first) for the Image which has to
be appeared in the Background of the Script.

14. If you want to add any LOGO in the First Page of the Script then right click the “FIRST
New Page” in the Left Sub-tree from the Menu option “Create”  select the “Graphic”.

15. Double click the “%Graphic1 New Graphic 1” in the Left Sub-tree.

16. Give the Name and Description (e.x. Graphic = “COMP_LOGO” and Description =
“LOGO WINDOW”)for the New Graphic Inserted.

17. Enter Name, Object and ID for the Graphic image and Select the Color grid screen
(BCOL) option button in the “General attributes” Tab.
Click - Output options Tab. Set Left and Upper Margins as given:

18. Right click the “FIRST New Page” in the Left Sub-tree and from the Menu option
“Create”  select the “Window”.
Double click the “%WINDOW1 New Window1” in the Left Sub-tree and enter the Window
name and Description (e.x. Window = “ADD_WIN” and Description = “Address Window”)

Set the Left and Upper margins for the ADD_WIN as follows:
19. Right click “ADD_WIN Address Window” in Left Sub-tree and from the Menu option
“Create” select the “Program Lines”.

20. Enter the Program Lines name and description (e.x. Program Lines = “ADD_FETCH”
and Description = “FETCHING COMPANY ADDRESS”)
21. Enter the Input Parameter as COMPANY_CODE and Export Parameter as V_ADRNR
in the “General attributes” Tab and write the select query as following:

SELECT SINGLE ADRNR INTO V_ADRNR

FROM T001 WHERE BUKRS EQ COMPANY_CODE.

(Note: Before writing the select query first declare the Variable V_ADRNR in the Global
definitions area as follows:

V_ADRNR TYPE T001-ADRNR.

22. Right click the “ADD_WIN Address Window” in the Left Sub-tree and from the Menu
option “Create” select the “Address”.
23. Double click the “%ADDRESS1 New address1” and change the Address name and
description (e.x. Address = COMP_ADD and Description = “COMPANY ADDRESS”).
24. Select the Type of the address in the “General attributes” Tab. (Since we are retrieving
the Organization address, we selected the first radio button) and in the Address number
text box pass the V_ADRNR Variable as &V_ADRNR&.

25. Set the Main window attributes like this: (Setting of window co-ordinates)
26. Right click the “MAIN Main Window” in the Left Sub-tree and from the Menu option
“Create”  select the “Program Lines”.

27. Enter the name and description (e.x. Program Lines = “SELECT_RECORD” and
Description = “SELECTING RECORDS”).
28. Enter the Input Parameter as COMPANY_CODE and Output Parameter as I_EKKO
and I_EKPO in the “General attributes” Tab and write the select query as following:

SELECT EBELN BUKRS

INTO TABLE I_EKKO

FROM EKKO

UP TO 10 ROWS

WHERE BUKRS EQ COMPANY_CODE.


IF SY-SUBRC EQ 0.

SORT I_EKKO BY EBELN.

SELECT EBELN EBELP MENGE NETPR

INTO TABLE I_EKPO

FROM EKPO

FOR ALL ENTRIES IN I_EKKO

WHERE EBELN EQ I_EKKO-EBELN.

IF SY-SUBRC EQ 0.

SORT I_EKPO BY EBELN EBELP.

ENDIF.

ENDIF.

29. Right click “MAIN Main Window” in the Left Sub-tree and from the Menu option
“Create”  select the “Complex Section”.

30. Enter the Section name and description (e.x. Section = “PO_LOOP” and Description =
“PURCHASE ORDER NUMBER LOOP”) and check the “Repeat processing” check box
and select the “Output type” as Unstructured (i.e. select the Unstructured radio button) in
the “General attributes” Tab.
31. Select the “Data” Tab.

32. Enter the Internal Table Name as I_EKKO and Work area name as WA_EKKO and sort
by the BUKRS and EBELN fields.

33. Right click “PO_LOOP PURCHASE ORDER NUMBER LOOP” in Left Sub-tree and from
the Menu option “Create”  select the “Text”.
34. Enter the Text name and description (e.x. Text = “PO_NO_DISPLAY” and Description =
“PURCHASE ORDER NUMBER DISPLAY”) and enter the values as in the screen shot
Click the Text Editor
Display the values of Company Code and Purchase Order Number as shown below:

Press Back Button, then Press Save and Check Buttons


35. Right click the “PO_LOOP PURCHASE ORDER NUMBER LOOP” in the Left Sub-tree
and from the Menu option “Create”  select the “Template”.
36. Double click on “%TEMPLATE1 New template” and enter the Template name and
description (e.x. Template Name = “OI_HEAD” and Description = “ORDER ITEM
HEADER”).

Before press save or enter click the “Table Painter Button” which will take you to following
screen.

To avoid the “cross line” in the Editor click the “Settings Button”
which will result in the following popup, in which you un-check the “Cross” Check Box and
press enter.

37. Split the Cell into Four or into any number of columns you want to display in the script by
right clicking the “%C1”.

and press “Back” Button.


38. Select the cv cv of the table to be displayed in the script by the clicking “Select pattern”
Button
Selected table pattern

39. Inorder to Display the “Column Text“ for the table columns, insert the Text as shown
below:

40. Right click the “OI_HEAD ORDER ITEM HEADER” and from the Menu path
“Create”  Select the “Text” .

41. Enter the Text name and description (e.x. Text = “HEAD1” and Description =
“COLUMN1”) and enter the values as in the screen shot (i.e. as explained in the point no
34).
42. In order to match the Template Column with the inserted Text “HEAD1 COLUMN1”,
select the “Output options” Tab and Enter the Line Number and Column Number in
which the above Text has to be printed in the form

Repeat Step No.40 & 41 for all the remaining column headings.
43. The Form is ready with all data upto Table Header. Inorder to populate data under each
column header, insert a table.

44. Insert the Table under “PO_LOOP PURCHASE ORDER NUMBER LOOP” by right
clicking the same.
45. Enter Table Name and Description (e.x. Table Name = “OI_DISPLAY” and Description =
“ORDER ITEM DISPLAY”)

46. Match the column width with the “OI_HEAD ORDER ITEM HEADER” Template (refer
step no 38 screet shot no 2) and Select the “Default” radio button and “No page break”
check box. Click the “Select pattern” push button to select the table pattern to be
displayed.
47.

Click the “Data” and populate the Item details by looping the Internal Table I_EKPO into
the Work Area WA_EKPO sorted by EBELN and EBELP as shown in the following
screen shot
48. Inorder to Display the values for each column, we have to Insert Separate Text for each
column under the Table “OI_DISPLAY ORDER ITEM DISPLAY” by Right clicking the
same. Enter the Name and Description for the Each Text Inserted under the Table.

Column 1 for Line Item of each Purchase Order – Populate the values for each column
as explained in the step no 34.
Inorder to Match the Item values with the Template Header, In the Inserted Text
“ORD_ITM_COL COLUMN1” Click the “Output options” and Select the “New line” Check
box and Select the “Line type” as “Detail” and also check the “New cell” Check box.

49. Similarly add one Text for the remaining columns.


For the Third Column Text also You need only to select the “New cell” Check box.

50. Before Inserting the 4th Text for the 4th Column, we have to calculate the Amount by
Multiplying the Quantity and Unit Price and for the same we have to insert “Program
Lines” by Right clicking “OI_DISPLAY ORDER ITEM DISPLAY”
51. Similarly calculate the subtotal by adding the totals and calculate the grand total by
adding the subtotals.

Before doing the calculations, declare variables for total, subtotal and grand total in
Global definitions.

InputParameters: WA_EKPO-MENGE,WA_EKPO-NETPR & OutputParameters:


V_TOTAL,V_SUBTOTAL, V_GRDTOTAL.
52. Now add the 4th Text to display the 4th column in the Form.

For the Fourth Column Text also You need only to select the “New cell” Check box.
53. In order to display the Subtotals (which has been created earlier i.e. refer to step no 52)
of all the Line Items for each Purchase Order, we have to Insert a separate Text Under
the Table OI_DISPLAY ORDER ITEM DISPLAY” by right clicking the same.
54. Enter the Name and Description for the Inserted Text (e.x. Text =
“SUB_TOTAL_DISPLAY” and Description = “SUB_TOTAL_DISPLAY” and populated the
value for subtotal.

55. After each purchase order, the Variable V_SUBTOTAL has to be refreshed, In order the
clear the subtotal variable we have to insert “Program Lines” by right clicking the
“OI_DISPLAY ORDER ITEM DISPLAY”.
56. Enter Name and Description for the Program Lines (%CODE1 New program lines 1)
Inserted (e.x. Program lines = “CLR_VAR” and Description = “CLEAR SUBTOTAL
VARIABLE”. Input parameters = “V_SUBTOTAL”. Clear the variable as shown below:

57. Now, we have to display the Grand Total (i.e. summation of all the subtotals). Insert
“Text” under the “PO_LOOP PURCHASE ORDER NUMBER LOOP” by right clicking the
same.
Text “%TEXT1 New text1” gets inserted. Now enter the name and description for the
same and also populated the value for grand total
Text = “GRD_TOT_DISP”, Description = “GRAND TOTAL DISPLAY” and Variable
V_GRDTOTAL has been populated to display the grand total in the form.
58. Inorder to display the Current Page Number and Total Number of pages in the form we
need a separate window and to obtain the same right click the “FIRST First Page” and
the insert window.
Window “%WINDOW1 New window 1” get inserted under the first page.
59. Enter the Window name and description (e.x. Window = “PG_WIN” and Description
“PAGE NUMBER WINDOW”)
Set the window co-ordinates for page number window “PG_WIN” as given below:
60. In order to display the page numbers we have to insert a “Text” by right clicking the
“PG_WIN PAGE NUMBER WINDOW”.
Text “%TEXT1 New text 1” gets inserted and now enter the text name and description.
Text = “PG_DISP”, Description = “PAGE NUMBER DISPLAY” and Page Number gets
displayed from the Transparent Table “SFSY”.
61. General Screen Shot of Entire Left Sub-tree:
62. Form output:
63. SOME MORE FURTHER MODIFICATIONS / ADDITIONAL OPTIONS IN THE ABOVE
CREATED FORM:

Condition-1: Create second page and company logo should get printed only in the first
page and not in the second page. Similarly, company address window should get printed
only in the last page and not in other pages.

To create the second page right click the “FIRST First Page” in the left sub-tree.
64. Another page gets inserted with name “%PAGE1 New page 1”.

65. Enter Page name and description for the inserted new page (e.x. Page = “SECOND”
and Description = “Second Page”) and set the next page as inserted second page and
select the mode as increase counter as shown below:
66. Now change the “FIRST First Page”s Next page as “SECOND” and change the mode as
Initialize counter.

67. Now copy the Main, Company Address, Page No windows from “FIRST First Page “ to
“SECOND Second
Page”.

68. Arrange all the windows under the Main window in both first and second page. In order
to restrict the company logo to be printed only in the first page, go to the first page and
double click the “LOGO_WIN LOGO WINDOW” and select the “Conditions” tab and
Check the “only on first page” Check Box.

69. Output showing the main window got printed only in the first page and not in the second
page and so on ….

First Page: With LOGO


Second Page: Without LOGO
70. In order to restrict the Company address to be printed only in the last page and not
in the remaining pages, double click the “ADD_WIN ADDRESS WINDOW” in the first
page and Check the “only after end of main window” Check Box. Repeat the same
process for the second page also.
71. Output showing the address window got printed only in the last page and not in the first
page and so on ….

First Page: without company address


Last page (second page): with company address window
72. Condition-2: Purchase order’s whose value is more than 5000 only should get
displayed / printed.

Inorder to achieve the same, right click the “PO_LOOP PURCHASE ORDER NUMBER
LOOP” and select the “Loop”.
73. “%LOOP1 New loop 1” gets inserted

74. Enter Loop name and description.


75. Select the “Data” Tab Loop the Internal I_EKPO as shown below:

76. In order to check the subtotal value for each purchase order (i.e. purchase order value
should be more than 5000), Insert a program lines under the new loop inserted.
77. “%CODE1 New program lines 1” gets inserted

78. Enter the name and description for Program lines. Before calculating the subtotal
declare two variables one for total and another for subtotal in Global definitions. Calculate
the Subtotal as shown below:
Input parameters: “WA_EKPO-MENGE, WA_EKPO-NETPR, V_TOT”; Output
Parameters: “V_VALUE”.

79. Now we calculated the subtotal for each purchase order. Inorder to restrict the display of
purchase orders whose values are more than 5000, we need to insert “Alternate” and for
the same right click the “PO_LOOP PURCHASE ORDER NUMBER LOOP” and from the
menu path create  select the “Alternate”.
80. “%CONDITION1 New alternate 1” gets inserted.

81. Enter Alternate name and description. Select the “General attributes” Tab and Enter the
condition of subtotal > 5000 as shown:
82. Now, move “PO_NO_DISPLAY PURCHASE ORDER NUMBER DISPLAY, OI_HEAD
ORDER ITEM HEADER, OI_DISPLAY ORDER ITEM DISPLAY, SUB_TOTAL_DISPLAY
DISPLAY SUBTOTAL and CLR_VAR New program lines” under the “TRUE” part.

83. In the “FALSE” part (i.e. If subtotal value is less than 5000, then clear the variable),
insert program lines and code as shown:
84. Only those purchase order whose value is more than 5000 gets displayed – First Page.
Only those purchase order whose value is more than 5000 gets displayed – Second
Page.
85. Condition-3 Each Purchase Order should get printed in a new page. Logo should get
printed in the first page along with the first purchase order and similarly, Grand total
should get printed in the last page with the last purchase order.
86. Inorder to achieve this, when the first successful purchase order whose value is more
than 5000 is found then increase one counter variable by 1 (this is required because the
“New page command” should not get triggered in the first page itself”) and for the same
we have to insert a “Program lines” under the “TRUE” part of “CHK_COND SUBTOTAL
CONDITION”.

Before increasing the counter variable first declare the counter variable in the “Global
definitions” part.
Output parameters: V_COUNTER.

7. Inorder to avoid triggering “New page command” in the first page, we have to insert
“Command” in the “TRUE” part of “CHK_COND SUBTOTAL CONDITION” by right
clicking the same as shown below:
88. “%COMMAND1 New command 1” gets inserted.

89. Enter name and description for the inserted Alternative. Select “General attributes” Tab
and check whether for the counter variable is more than 1.
90. If the counter variable is more than 1 means, we got the second successful purchase
order whose value is more than 5000. Hence, we can trigger new page command here
and for the same right click the “TRUE” part in “NEW_PG NEW PAGE COMMAND” as
shown:

“%COMMAND1 New command 1” gets inserted


91. Enter the name and description for Command and select the “General attributes” Tab
and Check the “Go to new page” and select the page as “SECOND” as shown below:

92. The following is the output: First Page with company logo and without company address
window, first purchase order whose value is more than 5000.
Second page: without company logo and with company address window for the last
purchase order whose value is more than 5000.
93. The new PROBLEM we faced when we create the smart form is page number. Total
Page Number got displayed as “*” as shown:
94. In order to solve the above problem Double Click the “PG_DISP PAGE NUMBER
DISPLAY” and Click the Text Editor.
Upon clicking the text editor it will take you to the following screen:

Go to the menu path Insert  Symbols  New as shown

Which will result you in the following popup and fill the popup as shown.
95. It will takes you to the following screen.

96. Now replace &SFSY-FORMPAGES+4(4CZ)& as &SFSY-FORMPAGES+0(4CZ)&

97. Press back and then check, activate and execute – You can observe that the problem
has resolved.
Enjoy and try to create more smart forms.

You might also like