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.
Step 3: Enter a short description and the components of the structure (MATNR and MAKTX). Save and activate the structure.
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.
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.
Step 3: Enter the ‘Meaning’ for the form and click on Save in the tool bar (Select ‘Local Object’ while saving).
Step 4: In Form Interface, create table type for the structure ‘ZMAKT’.
Step 5: In the Global Definitions, create a work area of type ‘ZMAKT’ and click on Save.
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.
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.
Step 9: Create table line. Right click on the ‘Header’ section and create a table line. Choose the line type as %LTYPE1.
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.
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 %LTYPE1 Also 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.
Step 14: Create Footer window. Right click on ‘MAIN Window’ and create a new window. Give the meaning as ‘Footer Window’.
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.
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.
Driver Program Creation for Smart form input: Step 1: Go to ‘SE38’ transaction. Enter a program name (z/y*) and click on ‘Create’.
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.
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
* * * *
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:
Print preview of the smart form: