smartform using select-option.pdf

Upload: dipesh

Post on 07-Aug-2018

258 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/20/2019 Smartform Using Select-option.pdf

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

  • 8/20/2019 Smartform Using Select-option.pdf

    2/23

     

      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.

  • 8/20/2019 Smartform Using Select-option.pdf

    3/23

     

    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

  • 8/20/2019 Smartform Using Select-option.pdf

    4/23

     

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

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

  • 8/20/2019 Smartform Using Select-option.pdf

    5/23

    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.

  • 8/20/2019 Smartform Using Select-option.pdf

    6/23

    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.

  • 8/20/2019 Smartform Using Select-option.pdf

    7/23

    Select query: SELECT vbeln

    waerk

    vkorgvtweg

    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

  • 8/20/2019 Smartform Using Select-option.pdf

    8/23

      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 asit_vbrk INTO wa_VBRK. In the where condition give the field name as vbeln, Select the operator as ‘=’and comparison value as P_VBELN..

  • 8/20/2019 Smartform Using Select-option.pdf

    9/23

     

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

  • 8/20/2019 Smartform Using Select-option.pdf

    10/23

  • 8/20/2019 Smartform Using Select-option.pdf

    11/23

     

    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.

  • 8/20/2019 Smartform Using Select-option.pdf

    12/23

     

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

  • 8/20/2019 Smartform Using Select-option.pdf

    13/23

     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:

  • 8/20/2019 Smartform Using Select-option.pdf

    14/23

  • 8/20/2019 Smartform Using Select-option.pdf

    15/23

  • 8/20/2019 Smartform Using Select-option.pdf

    16/23

     

    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. Tocreate a Table Line Right Click on the Line 1  Insert Empty line underneath . An empty Line appearsafter Line 1. Name this Line as Line2.  

  • 8/20/2019 Smartform Using Select-option.pdf

    17/23

     

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

  • 8/20/2019 Smartform Using Select-option.pdf

    18/23

    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:

  • 8/20/2019 Smartform Using Select-option.pdf

    19/23

    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.

  • 8/20/2019 Smartform Using Select-option.pdf

    20/23

    Now save and activate.

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

  • 8/20/2019 Smartform Using Select-option.pdf

    21/23

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

    Note down the Function Module name.

  • 8/20/2019 Smartform Using Select-option.pdf

    22/23

    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. 

  • 8/20/2019 Smartform Using Select-option.pdf

    23/23

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