Hi
Analiza el código a continuación.
*&---------------------------------------------------------------------*
*& Report Z_KRSA_WORD *
*& *
*&---------------------------------------------------------------------*
REPORT Z_KRSA_WORD .
DATA: fcode TYPE SY-UCOMM,
icode TYPE SY-UCOMM,
already_done TYPE c,
control TYPE REF TO i_oi_container_control,
document TYPE REF TO i_oi_document_proxy,
error TYPE REF TO i_oi_error,
container TYPE REF TO cl_gui_custom_container,
handle TYPE REF TO I_OI_WORD_PROCESSOR_DOCUMENT,
item_url(256),
document_type(80),
first.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
module STATUS_0100 output.
SET PF-STATUS 'PFSTAT'.
SET TITLEBAR 'TITBA'.
endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
module USER_COMMAND_0100 input.
icode = fcode.
CLEAR fcode.
CASE icode.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
endmodule. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module create_basic_objects OUTPUT
*&---------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
module create_basic_objects output.
DATA: bds_instance TYPE REF TO cl_bds_document_set,
doc_components TYPE sbdst_components,
doc_signature TYPE sbdst_signature,
doc_uris TYPE sbdst_uri,
wa_doc_uris LIKE LINE OF doc_uris,
wa_doc_signature LIKE LINE OF doc_signature,
doc_classname TYPE sbdst_classname VALUE 'Z_WORD_TABLE_TST',
doc_classtype TYPE sbdst_classtype VALUE 'OT',
doc_object_key TYPE sbdst_object_key VALUE 'ZLEC_EGZEK_01',
has TYPE i.
CHECK already_done IS INITIAL.
CALL METHOD c_oi_container_control_creator=>get_container_control
IMPORTING
control = control
error = error.
CREATE OBJECT container
EXPORTING container_name = 'CONTAINER'.
CALL METHOD control->init_control
EXPORTING
r3_application_name = 'R/3 Basis'
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = container
register_on_close_event = 'X'
register_on_custom_event = 'X'
no_flush = 'X'
IMPORTING
error = error.
already_done = 'X'.
CLEAR item_url.
wa_doc_signature-prop_name = 'DESCRIPTION'.
document_type = 'Word.Document'.
wa_doc_signature-prop_value = 'RANGES'.
APPEND wa_doc_signature TO doc_signature.
CREATE OBJECT bds_instance.
CALL METHOD bds_instance->get_info
EXPORTING
classname = doc_classname
classtype = doc_classtype
object_key = doc_object_key
CHANGING
components = doc_components
signature = doc_signature.
CALL METHOD bds_instance->get_with_url
EXPORTING
classname = doc_classname
classtype = doc_classtype
object_key = doc_object_key
CHANGING
uris = doc_uris
signature = doc_signature.
READ TABLE doc_uris INTO wa_doc_uris INDEX 1.
item_url = wa_doc_uris-uri.
CALL METHOD control->get_document_proxy
EXPORTING
document_type = document_type
IMPORTING
document_proxy = document
error = error.
CALL METHOD document->open_document
EXPORTING
open_inplace = 'X'
document_url = item_url.
CALL METHOD document->has_wordprocessor_interface
IMPORTING
is_available = has.
IF NOT has IS INITIAL.
CALL METHOD document->get_wordprocessor_interface
IMPORTING
ERROR = error
WP_INTERFACE = handle.
IF first IS INITIAL.
perform sell_word_doc.
first = 'X'.
ENDIF.
ENDIF.
endmodule. " create_basic_objects OUTPUT
*&---------------------------------------------------------------------*
*& Form sell_word_doc
*&---------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
form sell_word_doc .
DATA: retcode TYPE soi_ret_string,
l_makro(128) TYPE c.
l_makro = 'CreateTables'.
CALL METHOD document->execute_macro
EXPORTING
macro_string = l_makro
param_count = 2
param1 = 4
param4 = 5
IMPORTING
retcode = retcode.
endform. " sell_word_doc
En MSWORD debes crear un macro, que llamas en el formulario sell_word_doc.
Mi macro "CreateTables" se ve así
Dim oRange As Word.Range
Dim oTable As Word.Table
Set oRange = ActiveDocument.Bookmarks("bmTab001").Range
'Add table to range of bookmark (oRange)
Set oTable = ActiveDocument.Tables.Add(Range:=oRange, _
NumRows:=3, _
NumColumns:=3, _
AutoFitBehavior:=wdAutoFitFixed)
Al final de tu informe sugiero llamar a tu macro "Guardar como RTF"
Puse mi documento MSWORD con mis macros en el sistema con el código de transacción OAOR.
Si necesitas más información, pregúntame.
¿Podrías darme algunos ejemplos de implementación pequeños de cómo se puede usar para descargar los datos en el archivo rtf (dentro del cual los datos están dispuestos en formato de columnas o en formato de tabla)?
Quedo a la espera de tu respuesta.
Gracias
Hola
He trabajado en una tarea similar y he utilizado DOI (Integración de Oficina de Escritorio)
Revisa el enlace
http://help.sap.com/saphelp_nw70/helpdata/en/0f/f68994db9b11d2bdb5080009b4534c/frameset.htm
Si tienes más preguntas, pregúntame.
JS