Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Search method I_OI_WORD_PROCESSOR_DOCUMENT

bmartini34
Discoverer
0 Kudos
405

The "pos" parameter of the search and replace method does not specify the values it should take for each of the options. According to the documentation, the options are "global", "up", and "down."

call method wp_wordpro->replace

exporting
flag = 'X'
pos = ¿Value for the 'global' option.?
replace_string = p_valor
search_string = p_search_string
importing
error = l_error
retcode = l_retcode.

Based on the cursor position, it is unable to replace the text.

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos
353

The "values it should take for each of the options [...] are "global", "up", and "down."

Correct, what is your question?

Sandra_Rossi
Active Contributor
0 Kudos
353

Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

Better use Actions > Edit to indicate your question "how to reposition the cursor at the beginning of the document"

bmartini34
Discoverer
0 Kudos
353

if any of the indicated options are used, the replace method does not work. My question is whether the value 'global' equals 0, 'up' equals 1, or something similar.

Sandra_Rossi
Active Contributor
0 Kudos
353

Reposition the cursor at the beginning of the document before each search or replace to make sure.

You may directly access OLE and execute OLE Word methods to reposition the cursor before the texts to search and replace (e.g. at the top) = equivalent to VBA code "Call Selection.HomeKey(Unit:=wdStory)":

DATA doi_control TYPE REF TO I_OI_CONTAINER_CONTROL.

c_oi_container_control_creator=>get_container_control(
    IMPORTING
      control = doi_control ).

... " MS Word initialization

" direct OLE Call of "Selection.HomeKey(Unit:=wdStory)"
DATA(doi_handle) = doi_control->get_control_handle( ). " type CNTL_HANDLE in type pool CNTL
DATA(ole_handle) = doi_handle-obj. " type OBJ_RECORD
GET PROPERTY OF ole_handle 'Selection' = selection.
CALL METHOD OF selection 'HomeKey' EXPORTING #1 = 6. " Constant wdStory = 6 ... " Search or Replace

The code is incomplete, you can find what is missing in the forum.