SAP Smartforms - How to Call Smartform within Example ABAP Program
Here is an SAP Smartforms step by step example to open and call Smartform within ABAP code.
Within ABAP programs an SAP Smartform can be called and opened by calling the ABAP function SSF_FUNCTION_MODULE_NAME, we will see in the example ABAP code which is included with this Smartforms tutorial.
First, create a SAP Smartform report using ABAP transaction code "smartforms" within ABAP Editor.
Or you can use an existing simple SAP Smartforms report to call from the example ABAP program.
In this SAP SmartForms tutorial, the example uses a SmartForm named "ZSMARTFORMS_SALES_DOCUMENTS".
The SmartForm application "ZSMARTFORMS_SALES_DOCUMENTS" takes a table valued parameter to use as an internal table within SmartForms ABAP codes.
This SmartForms parameter table is "it_vbak" which is declared in type table of VBAK SAP Sales and Distribution table.
SAP VBAK table is contains Sales Document header data.
As you will see in the below ABAP codes, the program select a range of VBAK Sales Document records into an internal table variable it_vbak.
Later the variable table is passed to the SAP SmartForm as a TABLE argument.
It is important that the table variable is correctly declared within the Smartform 's "Global Settings > Form Interface > Tables" section.
As you will see in the below screenshot, it_vbak is declared as :
IT_VBAK TYPE VBAK
Example ABAP Program to Call Smartform
Here is the example ABAP code to call SAP SmarForms from a program or an ABAP report.
Please note that we have ABAP codes which call ABAP function SSF_FUNCTION_MODULE_NAME with formname parameter is set to the target SAP Smartforms document.
The SSF_FUNCTION_MODULE_NAME ABAP call returns the FM_NAME which is the compiled ABAP program identifier and is in type rs38l_fnam.
The returned fm_name variable is then called using an ABAP Call Function method to open Smartform.
While calling Smartform, the Table parameter is passed as an input argument.
I hope, SAP Smartforms developers will find this sample ABAP code useful as beginning to SAP Smartforms.