Wednesday, 19 October 2016

HOW TO CREATE A SMARTFORM USING DRIVER PROGRAM


HOW TO CREATE A SMARTFORM USING DRIVER PROGRAM

step  - 1

Create a structure  using the  t-code- SE11 :


Table Structure


step  - 2
Create the smartform using the t-code- smartforms  :

step  - 3
Under the Global Settings tab  ->   In the Tables tab  define the parameter name  type and associated type , which will be pass through our driver program .

step  - 4
Under the Global Definitions Tab  - >  In the Global data define the work area for the internal table .

step  - 5
Design your form under pages and windows tab .
In this example i am using  two windows in which the first window holds the data for page header and the second window hold the table data with header .
 

Create the Header data text node :

Create the main Area Text node : 

create a loop in the main Area for getting all the data in the table .

Save and Activate the Smartform .

To know the function module that is generated upon activation of this smart form, click on Environment -> Function module name. 
step  - 6

Code to be written in the Driver program .
REPORT ZTEST_SMARTFORM.

DATA FNAME TYPE  RS38L_FNAM,
       
CONTROL TYPE SSFCTRLOP.

DATA ITAB TYPE TABLE OF ZSPFLI,
       WA 
TYPE ZSPFLI.

SELECT FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE ITAB.



CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  
EXPORTING
    FORMNAME                 
'ZTEST_SMARTFORM'
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
 
IMPORTING
   FM_NAME                  
FNAME
* EXCEPTIONS
*   NO_FORM                  = 1
*   NO_FUNCTION_MODULE       = 2
*   OTHERS                   = 3
          
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION fname "'/1BCDWB/SF00000011'
 
EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
   CONTROL_PARAMETERS         
control
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
  
TABLES
    ITAB                       
itab
* 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.

Save and execute .

Select your output Device and click on print preview to see the test data .