Smart Forms Formularaufruf und Spool-Aufträge

Aus SAP-Wiki
Wechseln zu: Navigation, Suche

Beim Aufruf des Smart Forms ist es optional explizit einen Spool-Auftrag über Funktionsbausteine zu öffnen und zu schließen. Dies kann auch beim Aufruf des Smart Forms-Funktionsbausteins geschehen.

Demoprogramm SF_EXAMPLE_03

Im SAP-Demo-Programm SF_EXAMPLE_03 wird die Verwendung der Funktionsbausteine SSF_OPEN und SSF_CLOSE gezeigt, die explizit einen Spool-Auftrag öffnen, bzw. schließen.

Deklarationen

report sf_example_03.

data: carr_id type sbook-carrid,
      cust_id type scustom-id,
      fm_name type rs38l_fnam,
      control type ssfctrlop,
      errtab  type tsferror.

select-options: s_custid for cust_id   default 50 to 60,
                s_carrid for carr_id   default 'LH' to 'LH'.

parameter:      p_form   type tdsfname default 'SF_EXAMPLE_03'.

data: customers   type ty_customers,
      bookings    type ty_bookings,
      connections type ty_connections,
      customer    type scustom.

Datenselektion

************************ DATA RETRIEVAL ************************
* get data of bookings
  select * from scustom into table customers
           where id in s_custid
           order by primary key.

Ermittlung Funktionsbaustein mit SSF_FUNCTION_MODULE_NAME

************************ PRINTING OF DATA **********************
* get the name of the generated function module using the logical
* Smart Forms name
  call function 'SSF_FUNCTION_MODULE_NAME'
       exporting  formname           = p_form
*                 variant            = ' '
*                 direct_call        = ' '
       importing  fm_name            = fm_name
       exceptions no_form            = 1
                  no_function_module = 2
                  others             = 3.

  if sy-subrc <> 0.
*   error handling
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    exit.
  endif.

  control-no_dialog = 'X'.
  control-preview   = 'X'.
  control-no_open   = 'X'.
  control-no_close  = 'X'.

Funktionsbaustein 'SSF_OPEN'

  call function 'SSF_OPEN'
    exporting
*     ARCHIVE_PARAMETERS       =
*     USER_SETTINGS            = 'X'
*     MAIL_SENDER              =
*     MAIL_RECIPIENT           =
*     MAIL_APPL_OBJ            =
*     OUTPUT_OPTIONS           =
      control_parameters       = control
*   IMPORTING
*     JOB_OUTPUT_OPTIONS       =
    exceptions
      formatting_error         = 1
      internal_error           = 2
      send_error               = 3
      user_canceled            = 4
      others                   = 5.

  if sy-subrc <> 0.
*   error handling
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    exit.
  endif.


Aufruf Formular mit Funktionsbaustein

* print all the bookings of different customers
  loop at customers into customer.

    clear: bookings[], connections[].

    select * from sbook   into table bookings
             where customid = customer-id
             and   carrid in s_carrid
             order by primary key.
    select * from spfli into table connections
           for all entries in bookings
           where carrid = bookings-carrid
           and   connid = bookings-connid
           order by primary key.
*   now call the generated function module
    call function fm_name
         exporting
*                   archive_index        =
*                   archive_parameters   =
                    control_parameters   = control
*                   mail_appl_obj        =
*                   mail_recipient       =
*                   mail_sender          =
*                   output_options       =
*                   user_settings        = 'X'
                    customer          = customer
                    bookings             = bookings
                    connections          = connections
*        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.
*     error handling
      message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.

  endloop.

Funktionsbaustein 'SSF_CLOSE'

  call function 'SSF_CLOSE'
*   IMPORTING
*     JOB_OUTPUT_INFO        =
    exceptions
      formatting_error       = 1
      internal_error         = 2
      send_error             = 3
      others                 = 4.

  if sy-subrc <> 0.
*   error handling
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

* analyse internal error table of Smart Forms
  call function 'SSF_READ_ERRORS'
       importing
            errortab = errtab.
  if not errtab is initial.
*   add your handling
  endif.

Web-Links

Literatur