0% found this document useful (0 votes)
90 views

Smartform

This document provides steps to create a smart form for printing invoice details with copies and final windows. Key steps include: 1. Creating the smart style and defining paragraph formats. 2. Creating the smart form and adding windows like Title, Page Number, Invoice Details, Address, and Text. 3. Developing a driver program to export data to the smart form and display invoice information, line items, and totals. 4. Adding logic to calculate subtotals for each page and grand totals.

Uploaded by

Rajesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

Smartform

This document provides steps to create a smart form for printing invoice details with copies and final windows. Key steps include: 1. Creating the smart style and defining paragraph formats. 2. Creating the smart form and adding windows like Title, Page Number, Invoice Details, Address, and Text. 3. Developing a driver program to export data to the smart form and display invoice information, line items, and totals. 4. Adding logic to calculate subtotals for each page and grand totals.

Uploaded by

Rajesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 40

Smart forms

A real time scenario on Smart forms

Business Requirement :
Develop a Smart form to print the Invoice Details along with
Copies/Final windows .The Layout is given as below.
Steps:
 Goto Smartforms Tcode
 Select Smartstyle
 Give a name as ZINVICE_STYLE
 Click on Create
 Double click on Paragraph Format Folder
 Click on Create Node

 Give Name as TL and desc as Title


 Click on Font Tab
 Give the options as below
 Save it

 Double click on Paragraph Format Folder again


 Click on Create Node
 Give Name as NT and desc as Normal text
 Click on Font Tab
 Give the options as below
 Save it
 Double click on Paragraph Format Folder again
 Click on Create Node
 Give Name as RT and desc as Right Aligned text
 GIve Alignment as RIGHT Aligned
 And Indent-Right Margin as 4 cms(Approximately)

Save it

 Double click on Header data Folder


 Specify Standard Paragraph as NT
 SAVE, ACTIVATE
 Goto Smartforms Tcode
 Select SmartForm
 Give a name as ZINVOICE
 Click on Create
 Give desc->Click on Output Options Tab->Give style Name as
ZINVICE_STYLE

Expand Page1->Rightclick->Create->Window

 Give Window Name as Title and give desc


 Click on Form Painter Button->Adjust the Length, Position
 Click on Form Painter Button Again so that it disappears
 Right Click on Title Window->Create Text
 Write text as INVOICE->Select the entire text and select the Paragraph Format
'TL'

Save->Activate->Test it->The output is as Below




 Create a Graphics Node and display Image which is uploaded through SE78
Tcode.
 Right Click on Page1->Create ->Graphic
 Give the Name of the image or Press F4 on Name field.

Give the Name AS BELOW IN THE POPUP

Click on Execute->select the Image.

Save->Activate->Test it->The output is as Below


 Expand Page1->Right click->Create->Window
 Give Window Name as PAGE_NO and give desc
 Click on Form Painter Button->Adjust the Length, Position

 Click on Form Painter Button Again so that it disappears


 Right Click on PAGE_NO Window->Create Text
 Write text as 'Page No : '

 Click on Icon
 A popup will be displayed
 Write the below code
 Press Enter
 Put '/' at the end

 Click on Icon
 A popup will be displayed
 Write &SFSY-FORMPAGES& in the poup.
 Finally It should look as below

Save->Activate->Test it->The output is as Below

 Expand Page1->Right click->Create->Window


 Give Window Name as INVOICE_DETAILS and give desc
 Click on Form Painter Button->Adjust the Length, Position
 Click on Form Painter Button Again so that it disappears
 The INVOICE details will be imported from driver program
 So, goto Form Interface and declare Workarea By name
 WA_VBRK TYPE VBRK under IMPORTING tab .

 Right Click on INVOICE_DETAILS Window->Create Text


 Write text as below .
 Now, Write the Driver Program and export Workarea WA_VBRK from the
 Dynamically generated Funtion Module .
 Below is the code.
REPORT ZINVOICE_DRIVER_PRG.

DATA : FM_NAME TYPE RS38L_FNAM .


DATA : WA_VBRK TYPE VBRK .

PARAMETERS : P_VBELN TYPE VBELN .

SELECT SINGLE * FROM VBRK INTO CORRESPONDING FIELDS OF WA_VBRK


WHERE VBELN = P_VBELN .

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'


EXPORTING
FORMNAME = 'ZINVOICE'
IMPORTING
FM_NAME = FM_NAME.

CALL FUNCTION FM_NAME


EXPORTING
WA_VBRK = WA_VBRK.
Save->Activate->Test the Driver program->The output is as Below
 If we want the the invoice Details to be displayed in a box, Then
 Click on the Output Options Tab->Select the checkbox LINES WITH

Save->Activate->Test the Driver program->The output is as Below

 Expand Page1->Right click->Create->Address


 Click on Form Painter Button->Adjust the Length, Position
 Click on Form Painter Button Again so that it disappears

 We Need to give address number in the


 This number will be imported from driver Program.
 So declare an importing parameter in the Form Interface.
 V_ADRNR TYPE KNA1-ADRNR.

Double click on ADDRESS node give the value as below


 Save->Activate.
 Modify the driver as below for writing the logic to fetch address number.
 Add the below statements to the Driver Program.

DATA : V_ADRNR TYPE KNA1-ADRNR .


SELECT SINGLE ADRNR FROM KNA1 INTO V_ADRNR
WHERE KUNNR = WA_VBRK-KUNAG .

CALL FUNCTION FM_NAME


EXPORTING
WA_VBRK = WA_VBRK
V_ADRNR = V_ADRNR .

Save->Activate->Test the Driver program->The output is as Below

 Expand Page1->Right click->Create->Window


 Give Window Name as INVOICE_TEXT and give desc
 Click on Form Painter Button->Adjust the Length, Position
Create a standard Text in SO10 Tcode as below .

Click on Create->Write Some text ->save it ->Go back->and Click on print preview .
 Goto Smartforms
 Double click on the INVOICE_TEXT ->Right click->Create Text.
 Select Text Type as Include text.

 A message will appear->Click on Yes


 Give the Details as Below .

Save->Activate Smartform->Test the Driver program->The output is as Below


 Now, Lets start to use MAIN window to print Line item Information.
 The Line item Information will be imported from driver program
 So, Create an internal table under TABLES tab in FORM INTERFACE .

And also create an workarea WA_VBRP under Global Definations

And also Create an varibale by name V_SNO for displaying Serial No in the table
under Global Definations

Right Click oN the MAIN window->Create Table.

Click on the Icon and divide the %LTYPE1 into 4 blocks.


 Again Click on the Icon
 Select all the 4 Blocks

 Click on Icon
 A Popup Will appear

 Click on

 Select

 The Output is Below

 Now, Right Click on HEADER->Create->Table Line


Select Line type as %LTYPE1

Automatically 4 cells will be displayed under % ROW1.

Right Click on Cell1->Create Text


 Write the text as "Sl.No" .
 Repeat the same and create text for each cell and write the texts.
 Cell1->Text = "Sl.No" .
 Cell2->Text = "Material" .
 Cell3->Text = "Quantity" .
 Cell4->Text = "Price" .

 Now, Double click on table


 Click on Data Tab
 Check the checkbox internal table and specify the values as below.
 This is Because, Each record form internal table should be moved into work area
 And it should displayed in table.

Now,Right Click on MAIN Area->Create Table line.

Select Line type as %LTYPE1

 Automatically 4 cells will be displayed under % ROW2.

 Right Click on each cell and create text and write the texts as below.
 Cell5->Text = &V_SNO(C)& .
 Cell6->Text = &wa_vbrp-matnr&.
 Cell7->Text = &wa_vbrp-FKIMG(C)&.
 Cell8->Text = &wa_vbrp-netwr& .
 Here, We are displaying currency/quantity Fields in a table .
 So , we Need to specify the reference currency/quantity Fields under
 Global Definitions Tab.

 We need to increment the serial no "V_SNO" for each Loop Iteration.


 For this, Create Program Lines Under CELL5 TEXT.

Write the below code With Input and Output parameters in the Program lines.
 Everything is complete for displaying Line item Information.
 Now adjust the Main Window Length, position .
 Save->activate the form .

 Modify the Driver Program for Including the logic for selecting Line Item
Information.
 Add the below lines of code .

DATA : I_VBRP TYPE TABLE OF VBRP .


DATA : WA_VBRP TYPE VBRP .

SELECT * FROM VBRP


INTO CORRESPONDING FIELDS OF TABLE I_VBRP
WHERE VBELN = P_VBELN .

READ TABLE I_VBRP INTO WA_VBRP INDEX 1.

DO 100 TIMES .
APPEND WA_VBRP TO I_VBRP .
ENDDO.

CALL FUNCTION FM_NAME


EXPORTING
WA_VBRK = WA_VBRK
V_ADRNR = V_ADRNR
TABLES
I_VBRP = I_VBRP.

Save->Activate the Program->Test it. Below is the Output.


 Now, Create Page %PAGE2 , Because we dont need all the windows from page2
 As they are required only on %PAGE1.
 So, Create Page %PAGE2 , and copy the required windows from page1 to page2
 And increase the height the Main Window.
 I have copied Title, Page No and Main Window.

 Right Click on PAGE1->Create Page


 %Page2 will be created .
 Copy the required windows from page1 to page2

 Copy the PAGE NO window from page1

And Paste it on Page2

 Repeat the same and copy TITLE window and MAIN window .

 The Page2 Should look as below
 Click On Form Painter Button->Increase the Height of Main window by dragging
 It upper side .It should Look as below.

Now Double click on Page1 and specify Next Page as %PAGE2 .

Save, Activate the Form->Test the driver Program.


The first page will be as below .
Calculating Grand Totals
 Create A variable in Global Definitions by name V_TOT.


 Double lick on the Table
 Select Calculations Tab.
 We want to calculate the total on WA_VBRP-NETWR field
 Give the values as below .

Now create a text under the node TABLE print the grand total.

Write the text as below and make it as Right Aligned


Now->Go to the conditions tab.... check the checkbox 'ONLY BEFORE END OF MAIN
WINDOW'.

 Save, Activate the Form->Test the driver Program.


 Go to the Last Page and check the Output .
Calculating Sub-Totals for Each Page

 Create A variable in Global Definitions by name V_SUBTOT

.
 Goto Table->Expand Main Area->Expand ROw->Expand Last Cell->Text Will be
visible

Right click on the text->Create Program Lines.

Write the Below Code for calculating Subtotals.


 Double lick on the Table->Click on Table Tab
 Right click on %LTYPE1->Insert->Empty Line UnderNeath

%LTYPE2 will be created

 Double lick on Footer->Create Table Line


 GIve Line type as %LTYPE2

Automatically 1 cell will be created under Footer

 Right click on Cell->Create Text


 Write the below text
 After Printing the subtotal, We need to clear the value.
 So Right CLick on the text and.........follow as below

 Program Lines will be created.


 Write the below code in it with input and output parameters.

Save Activate test


Printing Terms and conditions on a separate Page.
 Create a New Page.
 Right Click on Page2->Create Page
 Create a window by name "TERMS".
 Create a text.
 Write some text.

 Double click on Page3->Specify Next Page as Blank .


 Because...If a page has MAIN window...then only it can point next page as itself.
 Here we don't have main window.......that's why...... it is blank.

 Expand Page1->Expand Main Window->select text which is under table


 And right click -> create a command as below.
 A command will be displayed.
 Select the check box GO to new Page and give page3 as new page

 Save, Activate, Test it .


 The alst page will be as below.
Using Copies Window .
 Generally this window is used to print the Name of copy like
 First copy Name as Original Copy,
 Second copy Name as Bank Copy
 Third copy as Name as Customer copy.

Steps:
Create a variable under global definition for displaying copy name.

Right Click on Page1->Create a window of type Copies Window..

Adjust the Length, Position.

Right click on copies window->Create Program Lines.


Write the Below Code with input/output parameters.
 The Smart form system variable SFSY-COPYCOUNT will store weather it is a
 First copy or second copy or third copy.
 So, as Per my requirement...if it is a first copy, I want the first copy to be as
 ORIGINAL COPY etc.

Now Right click on Program lines->Create Text and display the copy name

Write the below text.

 Save, Activate, Test it .


 Before clicking the Print Preview Button...Give the Number of copies as 3 .

Click on Now.
***********************************************************
The output is as below : First copy will be

*************************************************************

Second copy will be

*************************************************************
Third copy will be

*************************************************************
Using FINAL Window .

 Final windows are generally processed after all the windows in smart form are
finished.
 Generally Smart form will not execute any final windows initially.
 It will skip all final windows and it executes remaining windows.
 After Finishing all windows....Then it comes back to first page and it will check
weather
 Any final window is available on page1 or page2 or page3 etc..
 If it is available it will execute the final window .

Requirement :
 Here My requirement is: Print the Grand total on the first page itself.
 But the Grand total is calculated only after all the line items are displayed
from main window .
 So to Print Grand total on the first page...lets create a final window on
page1.
 And print the grand total from the variable V_TOTAL.

Steps:
Right Click on Page1->Create a window of type FINAL Window..

Select the Lines with option to provide box if you want .

Right click->Create Text.

Write the Below Text and make it as Right Aligned.

Please remember that Grand total is available in variable V_TOTAL .


Save, Activate, Test it .

*****************Finished Guys*****************************

I think I have covered all the concepts. Remaining concepts will be discussed in class.

Thanks and Bye for Now.

You might also like