Anda di halaman 1dari 23

Smartform Using Select-Options :

TechVantage IT Solution & Private Ltd.


By-Nilesh Mahajan

Create a Form by name Z_INVOICE

Go into form printer and create windows as follows.

Window1 for logo.


Window2 for Billing document detail.
Window3 for customer detail .
Main window for displaying the Item Details and the Total Amount.
Now go into the form interface and give parameters and select options that u want ,
We gave p_vbeln, p_kunnr and S_POSNR.

For select-option , we have create a structure in SE11>data type>structure as below.

And also create table type from SE11 for that structure

And then add select-option in form interface >tables.

For Global Definitions, double click on the Global Definitions and include the lines as follows

IT_VBRK : internal table for vbrk table.


WA_VBRK: work area for vbrk.
IT_KNA1 : internal table for kna1.
WA_KNA1:work area for kna1.
IT_VBRP : internal table for vbrp.
WA_VBRP: work area for vbrp.
W_TOTAL: Stores the Total Amount of the field NETWR.
Now in types , write structures for three tables i.e. vbrp, vbrk,kna1.

In initialization , you have to write your select query and also declare local data in input
parameters that is known only within the entered coding and cannot be accessed from outside.

Select query: SELECT vbeln


waerk
vkorg
vtweg
spart
fkdat
FROM vbrk
INTO TABLE it_vbrk
WHERE vbeln = p_vbeln.
*****************************************
*used for all entries.for fetching data from vbrp
* depending on value of vbeln.
******************************************
IF it_vbrk IS NOT INITIAL.
SELECT vbeln
posnr
matnr
arktx
netwr
FROM vbrp
INTO TABLE it_vbrp

FOR ALL ENTRIES IN it_vbrk


WHERE vbeln = it_vbrk-vbeln
and posnr in s_posnr.
ENDIF.
Input Parameters:IT_VBRk
P_VBELN
IT_VBRP
S_POSNR

Now,
Displaying the contents in window2 (Billing Window).
Create a Loop under the node window2

Name the Loop as LOOP1 give a description Details. In the field Operand give the details as
it_vbrk INTO wa_VBRK. In the where condition give the field name as vbeln, Select the operator as =
and comparison value as P_VBELN..

Create Text under the Loop text2 to display Billing Document Details.

Give the Name for the TEXT and a Description. To display the fields click on
Field List on/off button
on the application toolbar. A list with field names appear at the bottom left corner as shown in the screen
shot above. Drag & Drop the fields from wa_VBRK on to the editor.
Now, Displaying the contents in main window.( in table format).
Create a Table under the node MAIN.

Give Name for the table and Description. Right click on %LTYPE1 and rename the Line as Line1

Since we have to display 4 columns, LINE1 has to be divided into 4 cells. To draw lines Select the
button

Draw Lines and Columns.

Now create a Table line under the node Header and give the Line Type as Line1.

As soon as you give the Line type as Line1 and press ENTER you can see that under the
%ROW1 4 Cells namely %CELL1%CELL4 are created. Now Rename each of these as
shown below:

Now under each Cell create TEXT for Displaying the Column Headings.

Repeat the same steps for the node Main Area.


Define a Table line. Give the Line Type as LINE1.
As soon as you give the Line type as Line1 and press ENTER you can see that under the %ROW1 4
Cells namely %CELL1%CELL4 are created. Now Rename each of these Cells and Create Texts
under each Cell to display the Details from VBRP. After Creating all these your screen should look like
this :

In the Main Area Drag and Drop the fields from the field string WA_VBRP to print the Item Details. So in
the Text .it will be &WA_VBRP-POSNR& and so on as shown above.
Since we have to display the Total amount in the Footer area, Create a Table Line with one Cell. To
create a Table Line Right Click on the Line 1 Insert Empty line underneath . An empty Line appears
after Line 1. Name this Line as Line2.

Create a Text under the cell TOTAL. Give the Line type as Line 2. The Following screen appears

In order to calculate the Total (W_TOTAL) go to the Table ITEMDET. Select the Tab Calculations
and give the details as shown in the screen shot below:

Go back to the Footer Text for Displaying the TOTAL. Drag and Drop W_TOTAL from the
Global Data. To display the field list Click on the button

Field list on/off.

Now save and activate.


As we know, when we Activate the Smart Form it generates a Function Module automatically. To view the
Function Module generated for this Smart Form, Go to Environment Function Module Name.

By Clicking on the Function Module Name, a pop up appears which gives the name of the
Function Module.
Note down the Function Module name.

Driver program to Execute the form ZSF_INVOICE:


*&--------------------------------------------------------------------*
*& Report Z_PROG_FOR_SMARTFORMS
*&
*&--------------------------------------------------------------------*
*&
*&
*&--------------------------------------------------------------------*
REPORT Z_PROG_FOR_SMARTFORMS.
tables: VBRP,vbrk,kna1.
***********************************************************************
**
*SELECTION-SCREEN
***********************************************************************
***
PARAMETERS: P_VBELN TYPE vbrk-VBELN.
SELECT-OPTIONS: s_POSNR for VBRP-POSNR.
PARAMETERS: p_kunnr type kna1-kunnr.
*"Data Declarations....................................................
*"--------------------------------------------------------------------*
* Work Variables
*
*"--------------------------------------------------------------------*
data: fm_name type RS38L_FNAM.
***********************************************************************
***
*START-OF-selection
***********************************************************************
****
START-OF-SELECTION.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname
= 'Z_INVOICE'
*
VARIANT
= ' '
*
DIRECT_CALL
= ' '
IMPORTING
FM_NAME
= fm_name
* EXCEPTIONS
*
NO_FORM
= 1
*
NO_FUNCTION_MODULE
= 2
*
OTHERS
= 3
.
IF sy-subrc <> 0.

* Implement suitable error handling here


ENDIF.
*
OTHERS
= 3
*
.
*IF sy-subrc <> 0.
** Implement suitable error handling here
*ENDIF.
CALL FUNCTION '/1BCDWB/SF00000286'
EXPORTING
*
ARCHIVE_INDEX
=
*
ARCHIVE_INDEX_TAB
=
*
ARCHIVE_PARAMETERS
=
*
CONTROL_PARAMETERS
=
*
MAIL_APPL_OBJ
=
*
MAIL_RECIPIENT
=
*
MAIL_SENDER
=
*
OUTPUT_OPTIONS
=
*
USER_SETTINGS
= 'X'
p_vbeln
= p_vbeln
p_kunnr
= p_kunnr
* IMPORTING
*
DOCUMENT_OUTPUT_INFO
=
*
JOB_OUTPUT_INFO
=
*
JOB_OUTPUT_OPTIONS
=
TABLES
s_posnr
= s_posnr
* EXCEPTIONS
*
FORMATTING_ERROR
= 1
*
INTERNAL_ERROR
= 2
*
SEND_ERROR
= 3
*
USER_CANCELED
= 4
*
OTHERS
= 5
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

Anda mungkin juga menyukai