Skip to Content
author's profile photo Former Member
Former Member

smart form

how to call the function module generated by smart form in program

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 02, 2008 at 12:22 PM

    Hi

    check this report from the code

    http://www.sap-img.com/smartforms/smartform-tutorial.htm

    regards

    Shiva

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 02, 2008 at 12:42 PM

    Hi,

    in Smartforms you are goin to use 'SSF_FUNCTION_MODULE_NAME' to call the functionmodule generated.

    check the sample code

    DATA: ls_print_data_to_read TYPE lbbil_print_data_to_read.

    DATA: ls_bil_invoice TYPE lbbil_invoice.

    DATA: lf_fm_name TYPE rs38l_fnam.

    DATA: ls_control_param TYPE ssfctrlop.

    DATA: ls_composer_param TYPE ssfcompop.

    DATA: ls_recipient TYPE swotobjid.

    DATA: ls_sender TYPE swotobjid.

    DATA: lf_formname TYPE tdsfname.

    DATA: ls_addr_key LIKE addr_key.

    DATA: ls_dlv-land LIKE vbrk-land1.

    DATA: ls_job_info TYPE ssfcrescl.

    • SmartForm from customizing table TNAPR

    lf_formname = tnapr-sform.

    • determine print data

    PERFORM set_print_data_to_read USING lf_formname

    CHANGING ls_print_data_to_read

    cf_retcode.

    IF cf_retcode = 0.

    • select print data

    PERFORM get_data USING ls_print_data_to_read

    CHANGING ls_addr_key

    ls_dlv-land

    ls_bil_invoice

    cf_retcode.

    ENDIF.

    IF cf_retcode = 0.

    PERFORM set_print_param USING ls_addr_key

    ls_dlv-land

    CHANGING ls_control_param

    ls_composer_param

    ls_recipient

    ls_sender

    cf_retcode.

    ENDIF.

    IF cf_retcode = 0.

    • determine smartform function module for invoice

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING formname = lf_formname

    • variant = ' '

    • direct_call = ' '

    IMPORTING fm_name = lf_fm_name

    EXCEPTIONS no_form = 1

    no_function_module = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    • error handling

    cf_retcode = sy-subrc.

    PERFORM protocol_update.

    ENDIF.

    ENDIF.

    IF cf_retcode = 0.

    PERFORM check_repeat.

    IF ls_composer_param-tdcopies EQ 0.

    nast_anzal = 1.

    ELSE.

    nast_anzal = ls_composer_param-tdcopies.

    ENDIF.

    ls_composer_param-tdcopies = 1.

    DO nast_anzal TIMES.

    • In case of repetition only one time archiving

    IF sy-index > 1 AND nast-tdarmod = 3.

    nast_tdarmod = nast-tdarmod.

    nast-tdarmod = 1.

    ls_composer_param-tdarmod = 1.

    ENDIF.

    IF sy-index NE 1 AND repeat IS INITIAL.

    repeat = 'X'.

    ENDIF.

    • call smartform invoice

    CALL FUNCTION lf_fm_name

    EXPORTING

    archive_index = toa_dara

    archive_parameters = arc_params

    control_parameters = ls_control_param

    • mail_appl_obj =

    mail_recipient = ls_recipient

    mail_sender = ls_sender

    output_options = ls_composer_param

    user_settings = space

    is_bil_invoice = ls_bil_invoice

    is_nast = nast

    is_repeat = repeat

    importing job_output_info = ls_job_info

    • document_output_info =

    • job_output_options =

    EXCEPTIONS formatting_error = 1

    internal_error = 2

    send_error = 3

    user_canceled = 4

    OTHERS = 5.

    IF sy-subrc <> 0.

    • error handling

    cf_retcode = sy-subrc.

    PERFORM protocol_update.

    • get SmartForm protocoll and store it in the NAST protocoll

    PERFORM add_smfrm_prot.

    ENDIF.

    ENDDO.

    • get SmartForm spoolid and store it in the NAST protocoll

    DATA ls_spoolid LIKE LINE OF ls_job_info-spoolids.

    LOOP AT ls_job_info-spoolids INTO ls_spoolid.

    IF ls_spoolid NE space.

    PERFORM protocol_update_spool USING '342' ls_spoolid

    space space space.

    ENDIF.

    ENDLOOP.

    ls_composer_param-tdcopies = nast_anzal.

    IF NOT nast_tdarmod IS INITIAL.

    nast-tdarmod = nast_tdarmod.

    CLEAR nast_tdarmod.

    ENDIF.

    Reward if useful.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 02, 2008 at 12:53 PM

    Hi,

    You do like this.

    In the print program.

    Data: fm_name type rs381_fnam.

    The function ssf_function_module_name returns the name of the generated function module.

    call function 'SSF_FUNCTION_MODULE_NAME'

    emporting

    formname = 'FORMNAME'

    importing

    fm_name = fm_name.

    The function module ssf_fieldlist returns a list of form parameters actually used in the form.

    call function fm_name.

    pass the parameters which are returned from ssf_fieldlist.

    Reward.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 02, 2008 at 12:56 PM

    Hi,

    refer this Code

    
    
    REPORT  z_ssf_form.
    
    TABLES : vbrk,vbrp .
    
    
    *Data Declaration:-
    
    DATA : fm_name TYPE rs38l_fnam.
    
    
    *Selection Screen starts here:-
    
    SELECTION-SCREEN :BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_vbeln FOR vbrk-vbeln NO INTERVALS.
    SELECTION-SCREEN :END OF BLOCK b1.
    
    *Selection Screen ends here.
    
    *Message display
    *AT SELECTION-SCREEN.
    *  IF sy-subrc <> 0.
    *    MESSAGE e897(sd) WITH 'Data Not found'.
    *  ENDIF.
    
    
    *Calling function Module for displaying Smart form
    
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname                 = 'ZS_SMART1'                         *<<Smartform Name*
    *    VARIANT                  = ' '
    *    DIRECT_CALL              = ' '
       IMPORTING
         fm_name                  = '/1BCDWB/SF00001336' 
       EXCEPTIONS
         no_form                  = 1
         no_function_module       = 2
         OTHERS                   = 3
                .
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    
    
       CALL FUNCTION '/1BCDWB/SF00001336'            *<< FM generated by Smartform* 
       EXPORTING
    *   ARCHIVE_INDEX              =
    *   ARCHIVE_INDEX_TAB          =
    *   ARCHIVE_PARAMETERS         =
    *   CONTROL_PARAMETERS         =
    *   MAIL_APPL_OBJ              =
    *   MAIL_RECIPIENT             =
    *   MAIL_SENDER                =
    *   OUTPUT_OPTIONS             =
         user_settings              = 'X'
         vbeln                      = s_vbeln-low
    * 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.
    
    

    Edited by: Sandipan Ghosh on Apr 2, 2008 6:27 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.