Download - Creating a Smart Form
![Page 1: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/1.jpg)
Creating a Smart Form to display data from MAKT table:
Input
MAKT-MATNR
Output
MAKT-MATNR
MAKT-MAKTX
Steps
Step 1: Create a Global Structure for holding MAKT values
Go to transaction ‘SE11’. Choose ‘Data type’ and enter a name (‘ZMAKT’) for the structure and click on ‘Create’ button.
Step 2:
Choose ‘Structure’ in the create type.
![Page 2: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/2.jpg)
Step 3: Enter a short description and the components of the structure (MATNR and MAKTX). Save and activate the structure.
![Page 3: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/3.jpg)
Step 4: Create a table type ‘ZMAKT_TBL’ for the structure ‘ZMAKT’
Go to transaction ‘SE11’. Choose ‘Data type’ and enter a name (‘ZMAKT_TBL’\’) for the structure and click on ‘Create’ button. Choose ‘Table type’ in the create type pop up.
Step 5:
Enter a short description and select the line type as ‘ZMAKT’. Save and activate the table type.
![Page 4: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/4.jpg)
Step 6:
Enter ‘SMARTFORMS’ transaction code in the command box.
Step 7:
Choose ‘Form’ option and enter a form name to create (z/y *) and click on ‘Create’ button.
![Page 5: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/5.jpg)
Step 3:
Enter the ‘Meaning’ for the form and click on Save in the tool bar (Select ‘Local Object’ while saving).
![Page 6: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/6.jpg)
Step 4:
In Form Interface, create table type for the structure ‘ZMAKT’.
![Page 7: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/7.jpg)
Step 5:In the Global Definitions, create a work area of type ‘ZMAKT’ and click on Save.
![Page 8: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/8.jpg)
Step 6: Create a Table in the default ‘MAIN’ window of the PAGE 1.
Right click ‘Main Window’ - > Create -> Table.
Step 7:
A table with three sections Header, Main Area and Footer is created.
In the table painter, draw the lines and columns required. A default line type %LTYPE1 will be available. We can use the same line or create further line types. Create columns in the line by drawing vertical lines in the line. We can create as many columns as possible. Save the changes made to the table layout.
The below diagram shows a line type with two columns.
![Page 9: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/9.jpg)
Step 8:
In the ‘Data’ tab, specify the internal table and work area to be used for data display. You can also specify where conditions for filtering and sorting criteria.
![Page 10: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/10.jpg)
Step 9: Create table line.
Right click on the ‘Header’ section and create a table line. Choose the line type as %LTYPE1.
![Page 11: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/11.jpg)
![Page 12: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/12.jpg)
On selection of the line type, the cells corresponding to the line type will be created in the ‘Header’ section
Step 10: Create cell contents for the Header Section
Create a ‘Text element’ in %CELL1.
Step 11: Enter the text as ‘Material Number’ in the ‘General Attributes’ tab and save.You can also to the editor and specify some paragraph formats created from ‘Smart styles’ (which will be explained later) for the text.
![Page 13: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/13.jpg)
Step 12:
Similarly create a text element for %CELL2 and enter the text ‘Material Description’ and Save.
Step 13:
Create a table line in the ‘Main Area’ section also choosing the line type as %LTYPE1Also create text elements for each cell.In the text element of %CELL1, type the following text in the editor. &GS_MAKT-MATNR&
Similarly in the text element of %CELL2, type the following text in the editor. &GS_MAKT-MAKTX&
Save the form.
![Page 14: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/14.jpg)
Step 14: Create Footer window.
Right click on ‘MAIN Window’ and create a new window.Give the meaning as ‘Footer Window’.
![Page 15: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/15.jpg)
![Page 16: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/16.jpg)
Step 15:
Create a text element on the Footer window and the enter the text ‘Printer by TCS’
Step 16:
Click on ‘Form Painter’ button and align the window positions in the page.
![Page 17: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/17.jpg)
Step 17:
Save and activate the form.
Step 18:
Get the function module generated.Go to Environment - > function module name. Copy the function module name in the pop up.
![Page 18: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/18.jpg)
Driver Program Creation for Smart form input:
Step 1:
Go to ‘SE38’ transaction. Enter a program name (z/y*) and click on ‘Create’.
![Page 19: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/19.jpg)
Step 2:
In the report, create an internal table type for structure ‘ZMAKT’.
Step 3:
Create a select option for material number.
Step 4:
Query the MAKT table with the select option material number range as input and put in the internal table.
Step 5:
Call the function module which is generated from the smart form by passing the internal table as an exporting parameter.
![Page 20: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/20.jpg)
Driver Program:
*&---------------------------------------------------------------------**& Report Z_SF_EX1*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*
REPORT z_sf_ex1.
************************************************************************* Data declarations************************************************************************DATA gv_matnr TYPE matnr.
************************************************************************* Internal table declarations************************************************************************
DATA gt_makt TYPE STANDARD TABLE OF zmakt.
************************************************************************* SELECTION SCREEN************************************************************************
SELECT-OPTIONS so_matnr FOR gv_matnr obligatory.
************************************************************************* START-OF-SELECTION************************************************************************
START-OF-SELECTION.
SELECT matnr maktx FROM makt INTO TABLE gt_makt WHERE matnr IN so_matnr.
IF sy-subrc EQ 0.
CALL FUNCTION '/1BCDWB/SF00000091' EXPORTING* ARCHIVE_INDEX =* ARCHIVE_INDEX_TAB =* ARCHIVE_PARAMETERS =* CONTROL_PARAMETERS =* MAIL_APPL_OBJ =* MAIL_RECIPIENT =* MAIL_SENDER =* OUTPUT_OPTIONS =* USER_SETTINGS = 'X' itab_makt = gt_makt
* IMPORTING* DOCUMENT_OUTPUT_INFO =* JOB_OUTPUT_INFO =* JOB_OUTPUT_OPTIONS =* EXCEPTIONS* FORMATTING_ERROR = 1
![Page 21: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/21.jpg)
* INTERNAL_ERROR = 2* SEND_ERROR = 3* USER_CANCELED = 4* OTHERS = 5 . IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.
ENDIF.
Selection Screen:
![Page 22: Creating a Smart Form](https://reader030.vdocuments.mx/reader030/viewer/2022013121/5528044a497959670b8b4642/html5/thumbnails/22.jpg)
Print preview of the smart form: