Wednesday, April 16, 2014
Smart Forms are used to design print forms. ABAP programs are used to call Smartforms and spools are printed.

Step by step tutorial on Smart Forms

Step 1: Create Smart Form

 Step 2: Define Smart Form interface.

  • You can define Importing parameters, Exporting Parameters or Tables.

 Step 3: Insert Template Node

Use node type Template to display a table whose layout and size (number of lines and columns) is determined before the runtime of the print program.
  • Right click on Main Window and insert on Template node
  •  Design template  using Table Painter tool. Click on details button.

  •  Define  line type and number of columns for line and width of the columns 
  •  Display separator lines by clicking on Select Pattern button.
  •  Insert six text symbols
  •  Define variables to display data in text symbols
  •  Define Template output structure. We need to set it for each text symbol. 
  •  Save and Activate Smartform.

Step 4: Develop ABAP Driver program to call Function module.

  • ABAP Program steps
      • When you activate, system generates one function module. Function module is not fixed.
      • Use SSF_FUNCTION_MODULE_NAME to get smartform function module name.
      • Call function module /1BCDWB/SF00000034.
      • ABAP Source code
        REPORT zovh_simple_driver.
        
        DATA:wa_p0001 TYPE p0001.
        
        PARAMETERS:p_pernr TYPE pernr_d.
        PARAMETERS :p_printr TYPE ssfcompop-tddest DEFAULT 'LP01'.
        
        START-OF-SELECTION.
        
          SELECT SINGLE *
            FROM pa0001
            INTO wa_p0001
            WHERE  pernr EQ p_pernr
              AND begda LE sy-datum
              AND endda GE sy-datum.
          IF sy-datum EQ 0.
            DATA formname    TYPE tdsfname.
            DATA fm_name     TYPE rs38l_fnam.
        
            formname = 'ZOVH_SIMPLE_SMARTFORM'.
            CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
              EXPORTING
                formname           = formname
              IMPORTING
                fm_name            = fm_name
              EXCEPTIONS
                no_form            = 1
                no_function_module = 2.
            IF sy-subrc EQ 0.
              DATA control_parameters   TYPE ssfctrlop.
              DATA output_options       TYPE ssfcompop.
        
              control_parameters-no_dialog = 'X'.
              output_options-tddest = p_printr.
              CALL FUNCTION fm_name
                EXPORTING
                  control_parameters = control_parameters
                  output_options     = output_options
                  giw_p0001          = wa_p0001
                EXCEPTIONS
                  formatting_error   = 1
                  internal_error     = 2
                  send_error         = 3
                  user_canceled      = 4.
        
            ENDIF.
          ENDIF.
        
      • Run the program.
      •  Report Output

2 comments:

  1. after creating source code i am not getting desired output. Do I need to create Call function module /1BCDWB/SF00000034(may be change) in source code??

    ReplyDelete
  2. thanks for this tutorial , kindly consider this error in the code "IF sy-datum EQ 0."
    delete this statement since it make the output doesnt appear or you can replace it by IF sy-subrc EQ 0. (i guess that want u want)

    ReplyDelete

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.