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: 

How to load a MS Word document template into SAP database table?

former_member386290
Participant
0 Kudos

Dear experts,

I have come across a following piece of code. It appears that a MS Word document template was created and then loaded into SAP. It appears to me that following piece of code is trying to retrieve that template (using IMPORT statement) and then opening that 'MS word' document template. Can someone help me understand that how was the template loaded into SAP database in the beginning? And can I see that template without using the ABAP code? My requiremnt is that we need to replace original template with another template into SAP.

Thanks.

ABAPer.

*-------------------------------------------------------------------------

DATA: document TYPE REF TO i_oi_document_proxy.   
DATA: BEGIN OF t_template OCCURS 0,
        line(255),
        END OF t_template.

    srtfd = 'CONC WORD TEMPLATE'.

    PERFORM set_shape_defaults.

    IMPORT %tab TO t_template       "Read template.
         %l   TO temp_size
         FROM DATABASE indx(zz) ID srtfd.


    CALL METHOD document->open_document_from_table
      EXPORTING
        document_table = t_template[]
        document_size  = temp_size
        document_title = 'QNATT'
        open_inplace   = space
      IMPORTING
        retcode        = retcode.

FORM set_shape_defaults.

  DATA: h_word     TYPE ole2_object,
        h_docs     TYPE ole2_object,
        h_doc1     TYPE ole2_object,
        h_shps     TYPE ole2_object,
        h_shap     TYPE ole2_object,
        h_wrap     TYPE ole2_object.

  CREATE OBJECT h_word 'Word.Application' .
  SET PROPERTY OF h_word 'visible' = 0.

  CALL METHOD OF h_word 'Documents' = h_docs.
  CALL METHOD OF h_docs 'Add' = h_doc1.
  GET PROPERTY OF h_doc1 'Shapes' = h_shps.
  CALL METHOD OF h_shps 'AddShape' = h_shap
    EXPORTING
    #1 = 9
    #2 = '265.05'
    #3 = '117.2'
    #4 = '72'
    #5 = '72'.

  GET PROPERTY OF h_shap 'WrapFormat' = h_wrap.
  SET PROPERTY OF h_wrap 'Type' = 3.
  CALL METHOD OF h_shap 'SetShapesDefaultProperties'.
  CALL METHOD OF h_doc1 'Close'
    EXPORTING
    #1 = 0.
  CALL METHOD OF h_word 'Quit'.

  FREE OBJECT: h_word,
               h_docs,
               h_doc1,
               h_shps,
               h_shap,
               h_wrap.

2 REPLIES 2

UweFetzer_se38
Active Contributor
0 Kudos

Hi ABAP programmer,

the reverse function of IMPORT is EXPORT (but you probably know already).

But it seams not to be a SAP standard function: the cluster ID ZZ of database INDX is a customer ID. So no, you cannot see the template without customer coding.

Best regards
(@se38)

former_member182040
Active Contributor
0 Kudos

you can check t.code  OLE