Top Banner
Smartform Using Select-Options : Create a Form by name Z_INVOICE Go into form printer and create windows as follows.
23

Smartform Using Select-option

Apr 14, 2016

Download

Documents

DIPESH KUMAR
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Smartform Using Select-option

Smartform Using Select-Options :

Create a Form by name Z_INVOICE

Go into form printer and create windows as follows.

Page 2: Smartform Using Select-option

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.

Page 3: Smartform Using Select-option

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

Page 4: Smartform Using Select-option

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

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

Page 5: Smartform Using Select-option

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.

Page 6: Smartform Using Select-option

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.

Page 7: Smartform Using Select-option

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

Page 8: Smartform Using Select-option

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..

Page 9: Smartform Using Select-option

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

Page 10: Smartform Using Select-option

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

Page 11: Smartform Using Select-option

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.

Page 12: Smartform Using Select-option

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

Page 13: Smartform Using Select-option

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:

Page 14: Smartform Using Select-option

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

Page 15: Smartform Using Select-option

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 :

Page 16: Smartform Using Select-option

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.

Page 17: Smartform Using Select-option

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

Page 18: Smartform Using Select-option

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:

Page 19: Smartform Using Select-option

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.

Page 20: Smartform Using Select-option

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.

Page 21: Smartform Using Select-option

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.

Page 22: Smartform Using Select-option

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.

Page 23: Smartform Using Select-option

* 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.