<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Issue while creating OLE - Word document in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-while-creating-ole-word-document/m-p/7230485#M1524788</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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 &amp;amp; hence the 2nd heading is displayed just below the 1st heading &amp;amp; the 1st table is displayed after 2nd heading.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

* Display heading COMPANY CODE DETAILS
CALL METHOD OF gs_selection 'TypeText'
    EXPORTING
    #1 = 'COMPANY CODE DETAILS'.


* Display the contents of Company Code &amp;amp; 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'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output is as follows :-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;COMPANY CODE DETAILS&lt;/STRONG&gt;                                 "1st Heading&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PLANT DETAILS&lt;/STRONG&gt;                                                 "2nd Heading&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Comapny Code                       Description&lt;/STRONG&gt;          "1st Table&lt;/P&gt;&lt;P&gt;1000                                        CC 123&lt;/P&gt;&lt;P&gt;1001                                        CC 234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We expect following output :-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;COMPANY CODE DETAILS&lt;/STRONG&gt;                                    " 1st Heading&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Comapny Code                       Description&lt;/STRONG&gt;             " 1st table&lt;/P&gt;&lt;P&gt;1000                                        CC 123&lt;/P&gt;&lt;P&gt;1001                                        CC 234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PLANT DETAILS&lt;/STRONG&gt;                                                    " 2nd Heading&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any inputs to resolve above issue would be highly appreciated !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Sep 2010 05:12:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-09-03T05:12:07Z</dc:date>
    <item>
      <title>Issue while creating OLE - Word document</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-while-creating-ole-word-document/m-p/7230485#M1524788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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 &amp;amp; hence the 2nd heading is displayed just below the 1st heading &amp;amp; the 1st table is displayed after 2nd heading.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

* Display heading COMPANY CODE DETAILS
CALL METHOD OF gs_selection 'TypeText'
    EXPORTING
    #1 = 'COMPANY CODE DETAILS'.


* Display the contents of Company Code &amp;amp; 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'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output is as follows :-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;COMPANY CODE DETAILS&lt;/STRONG&gt;                                 "1st Heading&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PLANT DETAILS&lt;/STRONG&gt;                                                 "2nd Heading&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Comapny Code                       Description&lt;/STRONG&gt;          "1st Table&lt;/P&gt;&lt;P&gt;1000                                        CC 123&lt;/P&gt;&lt;P&gt;1001                                        CC 234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We expect following output :-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;COMPANY CODE DETAILS&lt;/STRONG&gt;                                    " 1st Heading&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Comapny Code                       Description&lt;/STRONG&gt;             " 1st table&lt;/P&gt;&lt;P&gt;1000                                        CC 123&lt;/P&gt;&lt;P&gt;1001                                        CC 234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PLANT DETAILS&lt;/STRONG&gt;                                                    " 2nd Heading&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any inputs to resolve above issue would be highly appreciated !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Sep 2010 05:12:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-while-creating-ole-word-document/m-p/7230485#M1524788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-03T05:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while creating OLE - Word document</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-while-creating-ole-word-document/m-p/7230486#M1524789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the solution. We need to insert following code after the 1st table is created &amp;amp; before creating the 2nd Heading.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
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'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Sep 2010 09:21:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-while-creating-ole-word-document/m-p/7230486#M1524789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-03T09:21:07Z</dc:date>
    </item>
  </channel>
</rss>

