Skip to Content
Former Member
Oct 28, 2010 at 02:27 AM

How to use the DOI METHOD(Insert_table and Insert_table)


Hello All,

I want insert some data into MS Office word.(The word template has some table)

(I know the DOI function is good solution.)

I have use the METHOD search to get the area.then use the METHOD insert_table can add data to MS Office Word.

The METHOD search can get right area. But the METHOD insert_table can not add data into the MS office word.

Code as below:


*Get the area

CALL METHOD ref_word_document->search


search_string = '<Search1>'

pos = '0'

flag = space


retcode = g_retcode.

lw_info-colindex = 0.

APPEND lw_info TO lt_info.

*Insert tabel to current area.


lv_char TYPE char20,

END OF ty_data.

DATA: lw_data TYPE ty_data.

DATA: lt_data TYPE TABLE OF ty_data.

lw_data-lv_char = 'test the insert data to word'.

APPEND lw_data TO lt_data.

*Insert above data to Word file.

CALL METHOD ref_word_document->insert_table


data_table = p_lt_data[]

info_table = p_lt_info[]

lowerbound = 0 " propose 1

upperbound = 0 " table rows to be counted first but review parameter wholetable

doctable_number = 1 " to be figured out what is table number logic in WORD

clearoption = 1 " I would leave 1

startrow = 1 " I would leave 1

varsize = 'X'

no_flush = 'X'

wholetable = 'X'


retcode = g_retcode

error = g_error.


the g_retcode value is "CONTROL_INTERNAL_ERROR".

Can you give me a example about how to use the Call METHOD I_OI_WORD_PROCESSOR_DOCUMENT->insert_table?

I have refer to the SAP help,But it still can not add data to Word.

(MS Office 2003 and 2007 Version,SAP Version:7200.1.0.1050,Windows Version:Windows 7 and XP).

Best Regards

Roy Cai