Application Development and Automation 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: 
Read only

Issue while creating OLE - Word document

Former Member
0 Likes
375

Hi Experts,

We are using OLE - Word to create a report output. We want to create tables one below the other in Word document. Below is the code, but looks like we are missing something wrt cursor position & hence the 2nd heading is displayed just below the 1st heading & the 1st table is displayed after 2nd heading.



* Display heading COMPANY CODE DETAILS
CALL METHOD OF gs_selection 'TypeText'
    EXPORTING
    #1 = 'COMPANY CODE DETAILS'.


* Display the contents of Company Code & Description in a Table format
 CLEAR lv_row.
  LOOP AT gt_t001 INTO wa_t001.
    lv_row = lv_row + 1.
    IF lv_row = 1.
      lv_row = 2.
    ENDIF.

CLEAR lv_text1.
    lv_col = 1.
    lv_text1 = wa_t001-bukrs.

  CALL METHOD OF gs_table 'Cell' = gs_cell
    EXPORTING #1 = lv_row
    #2 = lv_col.
  GET PROPERTY OF gs_cell 'Range' = gs_range.
  SET PROPERTY OF gs_range 'Text' = lv_text1.


  CLEAR lv_text1.
    lv_col = 2.
    lv_text1 = wa_t001-butxt.

  CALL METHOD OF gs_table 'Cell' = gs_cell
    EXPORTING #1 = lv_row
    #2 = lv_col.
  GET PROPERTY OF gs_cell 'Range' = gs_range.
  SET PROPERTY OF gs_range 'Text' = lv_text1.


endloop


* Goto the next line - 5 lines down
  DO 5 TIMES.
    CALL METHOD OF gs_selection 'TypeParagraph'.
  ENDDO.


 * Next heading - PLANT DETAILS
  CALL METHOD OF gs_selection 'TypeText'
    EXPORTING
    #1 = 'PLANT DETAILS'.

The output is as follows :-

COMPANY CODE DETAILS "1st Heading

PLANT DETAILS "2nd Heading

Comapny Code Description "1st Table

1000 CC 123

1001 CC 234

We expect following output :-

COMPANY CODE DETAILS " 1st Heading

Comapny Code Description " 1st table

1000 CC 123

1001 CC 234

PLANT DETAILS " 2nd Heading

Any inputs to resolve above issue would be highly appreciated !

Thanks,

Best regards,

Prashant

1 REPLY 1
Read only

Former Member
0 Likes
308

Guys,

Here's the solution. We need to insert following code after the 1st table is created & before creating the 2nd Heading.


data : gv_pos(5) type n.

loop at gt_t001 into wa_t001.


endloop.

* Get current cursor position after filling up the internal table
  GET PROPERTY OF gs_range 'End'   = gv_pos .
  SET PROPERTY OF gs_range 'Start' = gv_pos .
  CALL METHOD OF gs_range 'Select' .

* Goto the next line - 5 lines down
  DO 5 TIMES.
    CALL METHOD OF gs_selection 'TypeParagraph'.
  ENDDO.
 
 
 * Next heading - PLANT DETAILS
  CALL METHOD OF gs_selection 'TypeText'
    EXPORTING
    #1 = 'PLANT DETAILS'.

Thanks,

Best regards,

Prashant