Reportvorlage Smart Forms

Aus SAP-Wiki
Wechseln zu: Navigation, Suche

Das nachfolgende Programm ist eine Kopie vom SAP-Testprogramm SF_EXAMPLE_01.

*----------------------------------------------------------------------*
*       Report ZREB_SF_EXAMPLE_01
*----------------------------------------------------------------------*
*       Printing of documents using Smart Forms
*       Copy form SF_EXAMPLE_01
*----------------------------------------------------------------------*
report zreb_sf_example_01.

data: carr_id type sbook-carrid,
      fm_name type rs38l_fnam.

************************
* Selektionsbildschirm *
************************
parameter:      p_custid type scustom-id default 1.
select-options: s_carrid for carr_id     default 'LH' to 'LH'.
parameter:      p_form   type tdsfname   default 'ZREB_SF_EXAMPLE_01'.
parameter:      p_tddest type SSFCOMPOP-tddest default 'LOCL'.


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

******************
* Datenselektion *
******************
select single * from scustom into customer where id = p_custid.

check sy-subrc = 0.

select * from sbook into table bookings
         where customid = p_custid
         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.

***************************
* Formularnamen ermitteln *
***************************
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.

******************************************
* Smart Forms Funktionsbaustein aufrufen *
******************************************
* Exportstrukturen
DAta: lv_DOCUMENT_OUTPUT_INFO TYPE  SSFCRESPD,
      ls_JOB_OUTPUT_INFO      TYPE  SSFCRESCL,
      ls_JOB_OUTPUT_OPTIONS   TYPE  SSFCRESOP.

Data: ls_control_parameters type SSFCTRLOP,
      ls_OUTPUT_OPTIONS     type SSFCOMPOP.

* Importfelder für Unterdrückung Druckdialog
"ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-device    = 'PRINTER'.
ls_control_parameters-preview   = 'X'.    "Es wird dann kein Spool-Auftrag erzeugt
ls_output_options-TDDEST        = 'LOCL'.
"ls_control_parameters-langu     = 'D'.
"ls_control_parameters-getotf    = 'X'.



CALL FUNCTION fm_name
  EXPORTING
*   archive_index        =
*   archive_parameters   =
    control_parameters   = ls_control_parameters
*   mail_appl_obj        =
*   mail_recipient       =
*   mail_sender          =
    output_options       = ls_output_options
    user_settings        = space
    customer             = customer
    bookings             = bookings
    connections          = connections
*  IMPORTING
*   document_output_info = lv_DOCUMENT_OUTPUT_INFO  "Anzahl der Formularseiten
*   job_output_info      = ls_JOB_OUTPUT_INFO
*   job_output_options   = ls_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.