Текущее время: Ср, сен 03 2025, 17:00

Часовой пояс: UTC + 3 часа




Начать новую тему Ответить на тему  [ Сообщений: 2 ] 
Автор Сообщение
 Заголовок сообщения: Как выгрузить готовый документ из SAP Document Builder
СообщениеДобавлено: Пн, июл 21 2014, 09:02 
Почетный гуру
Почетный гуру

Зарегистрирован:
Вт, ноя 07 2006, 10:12
Сообщения: 1194
Откуда: Москва
Пол: Мужской
Если кто-то использует такую мощную штуку на SAP Document Builder то этот код поможет для выгрузки готового докумета из этого модуля. Код-"болванка" при желании можно его дорастить до нужного и с требуемой оптимизацией;
Code:
:rtfm: report  z_download_docx.

parameters: p_docid like /ipro/tdocmnt-docmnt_id.
parameters: p_cntnt like /ipro/tdocmnt-content.
parameters: p_outdf like /ipro/toutdef-otype.

* implicit constant definition for context node content
types:
   begin of element_content,
     content  type /ipro/tcontent-content,
     content_object  type ref to /ipro/if_content,
     content_lbl  type string,
   end of element_content,
   elements_content type
      standard table of element_content
      with default key.

data:
   lt_content      type elements_content,
   lt_contents     type /ipro/tt_contents,
   lo_content      type ref to /ipro/if_content,
   ls_sel_content  like line of lt_content,
   lr_docb_factory type ref to /ipro/if_docb_factory,
   lr_model        type ref to /ipro/if_model,
   lx_notfound     type ref to /ipro/cx_serializer_failed_at,
   lo_output               type ref to /ipro/if_output.

data: piv_name type string.
move p_cntnt to piv_name.
call function '/IPRO/CONTENT_FACTORY'
   exporting
     piv_name     = piv_name
   importing
     pet_contents = lt_contents.

read table lt_contents into lo_content index 1.
lr_docb_factory = lo_content->get_docb_factory( ).

check lr_docb_factory is not initial.
lr_model = lr_docb_factory->lookup( piv_docmnt_id = p_docid
                                     piv_version = 1 ).
if lr_model is initial.
   try.
       lr_model ?=
         lr_docb_factory->open( piv_docmnt_id = p_docid
                                piv_docmnt_version = 1 ).
     catch /ipro/cx_serializer_failed_at into lx_notfound.
       exit.
     catch /ipro/cx_action_noauth
           /ipro/cx_action_illegal.
       exit.
   endtry.
endif.

if lr_model is bound.
   lo_output ?= lr_model.
endif.

data: ls_doc                  type /ipro/s_output.

if lo_output is bound.
   try.
       lo_output->enable( p_outdf ).
       ls_doc = lo_output->generate( p_outdf ).
     catch /ipro/cx_output_otype_invalid.
     catch /ipro/cx_output_gen_failed.
   endtry.
endif.

data:
   lv_file_len type i,
   out_tab     type standard table of tbl1024.

call function 'SCMS_XSTRING_TO_BINARY'
   exporting
     buffer          = ls_doc-data
*   APPEND_TO_TABLE = ' '
   importing
     output_length   = lv_file_len
   tables
     binary_tab      = out_tab.

call function 'GUI_DOWNLOAD'
   exporting
     bin_filesize = lv_file_len
     filename     = 'd:\1.docx.'
     filetype     = 'BIN'
   tables
     data_tab     = out_tab
   exceptions
     others       = 22.

if sy-subrc <> 0.
* Implement suitable error handling here
endif.

_________________
С уважением, Р.В. Величко


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Как выгрузить готовый документ из SAP Document Builder
СообщениеДобавлено: Пн, дек 08 2014, 09:22 
Младший специалист
Младший специалист

Зарегистрирован:
Вт, сен 18 2007, 08:01
Сообщения: 76
Откуда: Россия, Пермь
Пол: Мужской
Коллеги, добрый день!
Какой компонент/addon надо установить, чтобы появился SAP Document Builder?
Можно ли им пользоваться без активации Procurement for Public sector?


Принять этот ответ
Вернуться к началу
 Профиль  
 
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 2 ] 

Часовой пояс: UTC + 3 часа


Кто сейчас на конференции

Сейчас этот форум просматривают: Yandex [Bot]


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Русская поддержка phpBB