You are on page 1of 7

SMARTFORMS

Driver Program:
In Smartforms, Driver program contains data retrieval logic and function module. We need to pass
the Internal tables & structures to this function module.

Finally, the function module will call the form and print the data in specified positions by using
data from internal tables and structures.

Based on the requirement we can also transfer the data from a single field to form.

Generally, data can be transferred from driver program to form either in the form of structures and
internal tables.

Simple data transfer from Driver program to form:


Example: we want to print data from program to form. (Transferring only one Single
Variable)

Steps in Smartforms:
Go to the T-Code Smartforms then we get the following screen.

By default, we get one page and one main window as shown. Choose form Interface in left
side then declare the variable as shown.
Select main Window and Create text as shown below.

Select the text(In our case % TEXT2) and choose at right side .
Then if the following screen comes then choose GotoChange Editor

Then declare &V_MATNR& in the following screen.

SAVE , Check, activate .

Steps in SE38:
Create a executable program (In Our case : Zdriver_R_test001) .

Then save and choose localobject.


SOURCE CODE:
Through the source code we get the MATNR value from mara which is given as an input in
P_matnr .
REPORT ZDRIVER_R_TEST001.

DATA : lv_matnr type matnr,


lv_form TYPE RS38L_FNAM .

PARAMETERS: p_matnr TYPE matnr .

START-OF-SELECTION .

SELECT SINGLE matnr FROM mara into lv_matnr WHERE matnr = p_matnr .

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'


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

CALL FUNCTION lv_form " '/1BCDWB/SF00000352'


EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
* CONTROL_PARAMETERS =
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'
V_MATNR = lv_matnr
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
* 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.

In the source code, SSF_FUNCTION_MODULE should be called to get the function module
name which was generated at runtime. In our case '/1BCDWB/SF00000352' is the function
module which was generated at runtime.
Function module name can be obtained in two ways.
1. Activate the form and execute(F8). we get the following screen.

2. Open the form and Environment Function Module Name

Calling lv_form :
After taking the function Module Name (In our case the function module name is:
'/1BCDWB/SF00000352’) use the pattern button in SE38 to call it.
After calling the function module name pass the parameters and replace the function
module name with the variable lv_form (In our case lv_form). Generally use the name
against FM_NAME of Importing of SSF_FUNCTION_MOULE_NAME .

OUTPUT:
After coding SAVE, CHECK, Activate & Execute (execute driver program). Input material
number in selection screen.(Put F4 and provide a value .In our case 2906)

Then provide LP01 in print preview screen and see the preview. We get the following output.

You might also like