Решил попробовать вывести содержимое вн. таблицы в WORD через DOI.
Использовал для этого примеры из предыдущих тем. Все работает, но что-то не
получил ожидаемого быстродействия, хоть и выводится за меньшее время, чем OLE.
300 записей (8 столбцов) - за минуту.
Может, кто подскажет, в чем причина?
Привожу код:
Code:
FORM DOI_INTO_WORD.
data: i_control TYPE REF TO i_oi_container_control,
gr_container TYPE REF TO cl_gui_custom_container,
i_document TYPE REF TO i_oi_document_proxy,
error TYPE REF TO I_OI_ERROR,
wp_interface TYPE REF TO i_oi_word_processor_document,
link_server TYPE REF TO i_oi_link_server,
retcode TYPE SOI_RET_STRING,
is_available TYPE i,
it_doc_uris TYPE SBDST_URI,
wa_doc_uris LIKE LINE OF it_doc_uris,
IT_DOC_SIGNATURE TYPE SBDST_SIGNATURE,
handle TYPE CNTL_HANDLE,
s_appl TYPE ole2_object,
tableinfo TYPE SOI_TABLEINFO_TABLE,
col_table TYPE SOI_COLS_TABLE,
col_indexLine TYPE SOI_COLS,
count TYPE sy-tabix.
* Creating the instance i_control * Создаем экземпляр SAP DOI ActiveX Control
call method c_oi_container_control_creator=>get_container_control
IMPORTING
control = i_control.
* Initializing control * Инициализируем объект i_control
call method i_control->init_control
EXPORTING
r3_application_name = 'R/3 application'
parent = gr_container
inplace_enabled = ' ' "'X'
no_flush = 'X'.
* register_on_close_event = 'X'
* register_on_custom_event = 'X'
* inplace_scroll_documents = 'X'
* inplace_show_toolbar
* inplace_resize_documents
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
call method i_control->get_document_proxy
EXPORTING
document_type = 'Word.Document' "'Excel.Sheet.8'
register_container = 'X'
no_flush = 'X'
IMPORTING
document_proxy = i_document
ERROR = ERROR
retcode = retcode.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
* Получаем урл - обращается к BDS
CALL METHOD cl_bds_document_set=>get_with_url
EXPORTING
classname = 'SOFFICEINTEGRATION' "doc_classname
classtype = 'OT' "doc_classtype
OBJECT_KEY = 'Z_ORDER_SPP' "Ключ объекта
CHANGING
uris = IT_DOC_URIS
SIGNATURE = IT_DOC_SIGNATURE
EXCEPTIONS
nothing_found = 1
error_kpro = 2
internal_error = 3
parameter_error = 4
not_authorized = 5
not_allowed = 6
OTHERS = 7.
READ TABLE IT_DOC_URIS INTO WA_DOC_URIS INDEX 1.
* Открываем документ
CALL METHOD i_document->open_document
EXPORTING
document_url = wa_doc_uris-uri
no_flush = 'X'
open_inplace = '' "'X'
IMPORTING
ERROR = ERROR
retcode = retcode.
CALL METHOD i_document->get_document_handle
EXPORTING
no_flush = 'X' "''
IMPORTING
error = error
handle = handle
retcode = retcode.
GET PROPERTY OF handle-obj 'Application' = s_appl.
CALL FUNCTION 'FLUSH'.
SET PROPERTY OF s_appl 'DisplayAlerts' = 0.
SET PROPERTY OF s_appl 'ScreenUpdating' = 0.
SET PROPERTY OF s_appl 'Visible' = 0.
CALL FUNCTION 'FLUSH'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 0
text = 'Подождите, формируется документ в Word...'.
*You use this method to query whether there is an application-specific interface
*for the document type of the instance document:
CLEAR is_available.
CALL METHOD i_document->has_wordprocessor_interface
EXPORTING
no_flush = ' ' "'X'
IMPORTING
is_available = is_available
error = error
retcode = retcode.
IF NOT is_available IS INITIAL.
* to create the instance wp_interface to manage the application-specific interface
* Use the method get_wordprocessor_interface on the document instance for document management
* to create the instance for the word processor interface
CALL METHOD i_document->get_wordprocessor_interface
EXPORTING
no_flush = 'X' "''
IMPORTING
wp_interface = wp_interface "The instance created for the application-specific interface
error = error
retcode = retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING
type = 'E'.
ELSE.
MESSAGE e000 WITH 'Ошибка создания печатной формы!'.
ENDIF.
count = lines( out_table ).
do 8 TIMES.
CLEAR col_indexLine.
col_indexLine-colindex = sy-index.
APPEND col_indexLine to col_table.
ENDDO.
CALL METHOD WP_INTERFACE->INSERT_TABLE
EXPORTING
DATA_TABLE = out_table[] " Value Table: Contains Data to be Transferred
INFO_TABLE = col_table " Info Table: Specifies the Columns to be Transferred
LOWERBOUND = 1 " First Line of Internal Table to be Transferred
UPPERBOUND = count " Last Line of Intenral Table to be Transferred
DOCTABLE_NUMBER = 1 " первая по порядку табл в файле
CLEAROPTION = 1 " Overwrite Behavior (for Document Table Contents)
STARTROW = 2 " Line in the Document Table from Which Data is to be Inserted
VARSIZE = 'X' " Adjust Size of Document Table to Fit?
NO_FLUSH = 'X' " Flush Behavior
* WHOLETABLE = 'X' " Option: Transfer Entire Contents of Internal Table
IMPORTING
ERROR = ERROR " Error Object
RETCODE = RETCODE. " Error Return Code
CALL FUNCTION 'FLUSH'.
SET PROPERTY OF s_appl 'Visible' = 1.
SET PROPERTY OF s_appl 'DisplayAlerts' = 1.
SET PROPERTY OF s_appl 'ScreenUpdating' = 1.
CALL FUNCTION 'FLUSH'.
CALL METHOD OF s_appl 'ScreenRefresh' .