Ja.
Ich habe eine Lösung, welche darauf basiert:
Einen Platzhalter im Formular Textknoten zu hinterlegen.(e.g. Seite $PAGE / $PAGES)
Das Smartform nicht direkt drucken zu lassen, sondern OTF zurückzugeben.
(dann hat man auch die Gesamtzahl der Seiten)
Anschliessend im OTF-Stream die Seitenzahlen gegen die Platzhalter austauschen und
den OTF Stream zum Drucken bzw. der Vorschau zu übergeben.
Beispiel:
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
*&---------------------------------------------------------------------*
*& Report ZTEST_SF_OTF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
DATA: fm_name
TYPE rs38l_fnam
, gv_form TYPE tdsfname VALUE 'ZTEST_PLOT'.
ls_document_output_info TYPE ssfcrespd,
ls_control_para TYPE ssfctrlop,
ls_outopt TYPE ssfcompop.
* OTF data
lt_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
lt_otf_sf TYPE ssfcrescl,
lv_numbytes TYPE i,
result TYPE ssfpp.
PARAMETERS fclip
TYPE c
RADIOBUTTON GROUP 3 DEFAULT 'X'.
ls_control_para-langu = 'E'.
ls_control_para-no_dialog = 'X'.
ls_control_para-preview = space.
ls_control_para-getotf = 'X'.
ls_outopt-tddest = 'LP01'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = gv_form
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
CALL FUNCTION fm_name
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = ls_control_para
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
output_options = ls_outopt
user_settings = ' '
IMPORTING
document_output_info = ls_document_output_info
job_output_info = lt_otf_sf
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
lt_otf[] = lt_otf_sf-otfdata[].
*in ls_document_output_info-TDFPAGES steht die Seitenzahl
LOOP AT lt_otf
ASSIGNING <p
> WHERE tdprintcom EQ 'ST' AND ( tdprintpar CS '$PAGE' OR tdprintpar CS '$PAGES' )
OR
tdprintcom EQ 'IN' AND tdprintpar(2) EQ '05' .
REPLACE '$PAGE' IN <p
>-tdprintpar
WITH l_pc
. REPLACE '$PAGES' IN <p
>-tdprintpar
WITH ls_document_output_info
-tdfpages
.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
CHANGING
rc = rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL METHOD cl_gui_frontend_services=>clipboard_import
IMPORTING
* length =
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL FUNCTION 'SSFDISPLAY_OTF'
* EXPORTING
* DISPLAY_PARAMETERS =
* ARCHIVE_PARAMS =
* SPOOLATTR =
* SHOW_DIALOG = ' '
* IMPORTING
* RESULT =
otf = lt_otf[]
EXCEPTIONS
error = 1
OTHERS = 2.
** ===============OK===========================
*
*data ls type SSFPP.
*ls-TDDEST = ls_outopt-tddest..
*ls-TDIMMED = 'X'.
*ls-TDDELETE = ' '.
*
*CALL FUNCTION 'SSFPRINT_OTF'
* EXPORTING
* printoptions = ls
** IMPORTING
** OTF_PRINTER =
** OTF_DEVICETYPE =
** PRINT_SUCCESSFUL =
** SPOOLID =
* tables
* otf = lt_otf.
** ============================================
** ==================OK========================
*DATA ls TYPE itcpo.
*
*ls-tddest = ls_outopt-tddest.
*ls-tdimmed = ' '.
*ls-tddelete = ' '.
*
*
*CALL FUNCTION 'PRINT_OTF'
* EXPORTING
* printoptions = ls
** IMPORTING
** OTF_PRINTER =
** OTF_DEVICETYPE =
** PRINT_SUCCESSFUL =
** SPOOLID =
* TABLES
* otf = lt_otf.
** ============================================
- GeSHi ©
Zu Übungszwecken habe ich eine Clipboard Funktion eingebaut, damit man ein wenig experimentieren und den OTF-Stream in einen Texteditor "pasten" kann.
Die inaktiven Abschnitte enthalten die Übergabe des OTFs an den Spool zum Drucken.
viel Spass beim Experimentieren
lg Jens
siehe auch
http://help.sap.com/saphelp_40b/helpdat ... ontent.htm