Smartform Calling from Driver Program in SAP ABAP – Practical 6


How to Create a Smartform to display multiple line items using TEMPLATE and calling it from the Driver Program –

Smartform Calling from Driver Program in SAP ABAP

SAP ABAP Fundamentals

SAP ABAP Interview Questions – Real Time

Step 1: Go to Tcode “SMARTFORMS” enter the form name and click on Create.

Step 2: In Form Attributes, enter the description of the form.

Step 3: Now double click on Global Definitions on the left panel, click on Global Data Tab and enter the internal tables & required variable names with their respective types (All declared objects will be global here).

Step 4: Now click on the Types tab and create a user-defined structure as below.

Step 5: Now double click on Page and change the Page name and description.

Step 6: Click on the down arrow beside the Page folder, Main Window will show. Right-click on Main Window: Create -> Template.

Step 7: Double click on the template. Change the name of the template and description. Click on the Pencil icon and draw a number of columns in %C1.

Step 8: After creating a number of columns, click on the Details button.

Step 9: Now here adjust the height and width of the column according to your convenience.

Step 10: After adjusting columns click on the Table Painter button to come back. Now click on the button “Select Pattern..”.

Step 11: A pop-up will display and select a pattern of the template without the border if you want to select a pattern with a border click on Display Framed Pattern.

Step 12: Right click on Template: Create -> Text(As created below).

Step 13: Double click on Text and change its name and description and write the text in the Editor.
Do the same thing and create four more texts under the same template.

Step 14: Now click on the Output Options tab and set the position of the text by allotting column numbers and row numbers under Output Structure.

Step 15: Right click on Main Window: Create -> Flow Logic -> Program Lines.
Now double click on Program Lines and change the name and description of program lines
and enter the SQL code to fetch the data. (As created below already)

Step 16: Right-click on Main Window: Create -> Flow Logic ->Loop. (As created below already). Double click on Loop and change the name and description of it and Loop the internal table: IT_VBAP into work area: WA_VBAP.

Step 17: Now right-click on Loop: Create -> Template. Change the name and description of the template as before.

Step 18: Select the Pencil icon and create 5 columns as before for displaying the data here.

Step 19: Click on Details and set the height and width of the columns.

Step 20: Now Right-click on Template: Create -> Text. Change the name and description of the Text. Click on the Insert Field button to enter the variable on the page.

Step 21: Enter the Work area and field as given below. Do the same step for the other 4 columns.

Step 22: Save and activate the Smartform.

 


Steps for Creating Program and calling above Smartform

 

STEP 23: Now go to SE38, Write the name of the program and click on source code and create.

STEP 24: A pop-up will display, write the title of the program and select ‘Executable Type’ as Type under Attributes.

STEP 25: Now write the Package name and save.

 

STEP 26: In this pop-up, enter the TR number.

 


Now write the Source Code in the Editor:

REPORT ZSMARTFORMS006.

*RS38L_FNAM is a data element that stores the Name of the Function Module
DATA : FNAME TYPE rs38l_fnam.

*Calling Function Module for Smartform
CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’
EXPORTING
formname = ‘ZSMARTFORMS006’
* 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.

*This FM is used to Pass data into Smartform
CALL FUNCTION FNAME
* EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
* CONTROL_PARAMETERS =
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = ‘X’
* 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.

Step 27: Save and activate the Report.

OUTPUT