Professional Documents
Culture Documents
Business Requirement : Develop a Smart form to print the Invoice Details along with Copies/Final windows .The Layout is given in the class.
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'
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.
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
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 .
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.
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
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.
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 EXPORTING WA_VBRK V_ADRNR FM_NAME = WA_VBRK = V_ADRNR .
Expand Page1->Right click->Create->Window Give Window Name as INVOICE_TEXT and give desc Click on Form Painter Button->Adjust the Length, Position
Click on Create->Write Some text ->save it ->Go back->and Click on print preview .
Goto Smartforms Double clik on the INVOICE_TEXT ->Right click->Crate Text. Select Text Type as Include text.
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 varibale by name V_SNO for displaying Serial No in the table
Click on the
Icon
Click on
Select
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 clickon 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 workarea And it should displayed in table .
Automatically 4 cells will be displayed under % ROW2. Right Click on Cell5->Text = Cell6->Text = Cell7->Text = Cell8->Text = each cell and create text and write the texts as below. &V_SNO(C)& . &wa_vbrp-matnr&. &wa_vbrp-FKIMG(C)&. &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.
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.
Copy the required windows from page1 to page2 Copy the PAGE NO window from page1
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.
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.
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 .
Double lick on the Table->Click on Table Tab Right click on %LTYPE1->Insert->Empty Line UnderNeath
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.
Double click on Page2->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
Steps: Create a variable under global definition for displaying copy name.
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
Save, Activate, Test it . Before clicking the Print Preview Button...Give the Number of copies as 3 .
Click on
Now.
*************************************************************
Right click->Create Text. Write the Below Text and makeit as Right Aligned.
*****************Finished Guys***************************** I think I have covered all the concepts. Remaining concepts will be discussed in class. Thanks and Bye for Now.