How to Use Form Routines in SAP Smartforms Documents
Creating Form Routines in SAP Smartform documents help ABAP developers who are working with SAP Smartforms documents keep their ABAP codes clean and create reusable form routines that can be called within Smartforms.
In this SAP Smartforms tutorial, I'll demonstrate how to create a sample Form Routine and how to call it from Initialization code block.
On the Global Data, add the following line to define gs_vbrk global variable.
GS_VBRK TYPE VBRK
Go to Form Routines tab, add the following form routine code block.
FORM get_vbrk_data
USING cs_bil_number TYPE VBELN
CHANGING cs_vbrk TYPE vbrk.
SELECT SINGLE * FROM vbrk INTO cs_vbrk
WHERE vbeln = cs_bil_number.
ENDFORM.
On the Initialization tab, add the following code which will call and populate gs_vbrk variable structure.
Of course, gs_vbrk should be defined among Input Parameters and Output Parameters of Initialization code block.
And is_bil_invoice-hd_gen should be defined in the Input Parameters of Initialization code section.
* Populate internal VBRK structure variable
PERFORM get_vbrk_data
USING is_bil_invoice-hd_gen-bil_number
CHANGING gs_vbrk.