SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Desktop Integration between R/3 and Word



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> OLE2, Excel, WinWord
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Fri Jan 22, 2010 4:34 pm    Post subject: Desktop Integration between R/3 and Word Reply with quote

Code:
REPORT ZWORDOLE MESSAGE-ID Z1.
*----------------------------------------------------------------------*
* Topic:       Desktop Integration between R/3 and Word.               *
*                                                                      *
* Description: Example program using OLE 2.0 to call up Microsoft Word *
*              and feeding Word with Data. Word is used for formating  *
*              the document.                                           *
*                                                                      *
* Process:     Open Word, For each new ... create new document.        *
*                                                                      *
* Authori-     ..                                                      *
* zation:                                                              *
*                                                                      *
* Execute:     Use transaction SA38 or create own transaction.         *
*              You have to execute the program in Online.              *
* Parameters:  none:                                                   *
*                                                                      *
* Customizing: No need for customizing.                                *
*                                                                      *
* Change of    Check tables, includes and call transaction.            *
* R/3 Release:                                                         *
*                                                                      *
* Programmer:  Benny G. Sшrensen, BGS Consulting ApS http://www.bgs.dk *
* Date:        April 1997                                              *
* Version:     1                                                       *
*                                                                      *
*-------------------------------Version--------------------------------*
* Date        Userid     Correction   Description                      *
* 18-03-1997  BGS        T11K900715 : New development                  *
*----------------------------------------------------------------------*


*----------------------------------------------------------------------*
* Include:                                                             *
*----------------------------------------------------------------------*
INCLUDE  OLE2INCL.                    "Standard R/3 Include

*----------------------------------------------------------------------*
* Tables:                                                              *
*----------------------------------------------------------------------*
TABLES:  EKKO.

*----------------------------------------------------------------------*
* Global Constants                                                     *
*----------------------------------------------------------------------*
Constants:
         OK                LIKE SY-SUBRC  VALUE 0        "Code for OK
        ,ERROR             LIKE SY-SUBRC  VALUE -1       "Code for ERROR
        ,YES               TYPE I         VALUE 1        "Boolean = YES
        ,NO                TYPE I         VALUE 0        "Boolean = No
        .
*----------------------------------------------------------------------*
* Globale varianter                                                    *
*----------------------------------------------------------------------*
DATA:   RETURN_CODE           LIKE SY-SUBRC.

*----------------------------------------------------------------------*
* Internal tables                                                      *
*----------------------------------------------------------------------*
DATA:   EKKO_TAB LIKE EKKO OCCURS 0 WITH HEADER LINE.

*----------------------------------------------------------------------*
* Selection-Screen                                                     *
*----------------------------------------------------------------------*
SELECT-OPTIONS: P_SUBMI FOR EKKO-SUBMI OBLIGATORY
               ,P_EBELN FOR EKKO-EBELN MATCHCODE OBJECT MEKK
               ,P_LIFNR FOR EKKO-LIFNR MATCHCODE OBJECT KRED.

*----------------------------------------------------------------------*
* INITIALIZATION, er et EVENT key word som udfшres fшr SELEKTIONS      *
* SKЖRMEN bliver vist.                                                 *
*----------------------------------------------------------------------*
INITIALIZATION.
  RETURN_CODE        = OK.
  REFRESH:  EKKO_TAB.
  CLEAR:    EKKO_TAB.

* Initialize Word
  CREATE OBJECT MS_WORD 'WORD.BASIC'.
  IF SY-SUBRC NE 0.
    MESSAGE I100 WITH SY-MSGLI.
    EXIT.
  ENDIF.

* Put MS-Word in background
  CALL METHOD OF MS_WORD 'APPMINIMIZE'.


*----------------------------------------------------------------------*
* Event: Start-Of-Selection, called after processing selection-screen  *
*----------------------------------------------------------------------*
START-OF-SELECTION.

  SELECT * FROM  EKKO INTO TABLE EKKO_TAB
    WHERE SUBMI IN P_SUBMI
      AND EBELN IN P_EBELN
      AND LIFNR IN P_LIFNR.
  DESCRIBE TABLE EKKO_TAB LINES ANT_LICITATION.
  IF ANT_LICITATION = 0.
    MESSAGE I100 WITH TEXT-001.
    EXIT.
  ENDIF.
  SORT EKKO_TAB BY SUBMI EBELN.

  CLEAR EKKO_TAB.
  LOOP AT EKKO_TAB.
    ON CHANGE OF EKKO_TAB-SUBMI.
*   Open new word document on change of ekko_tab-submi
      CALL METHOD OF MS_WORD 'FILENEW'
           EXPORTING #1 = 'WORDFILE'.
      CALL METHOD OF MS_WORD 'EDITGOTO'
           EXPORTING #1 = 'EKKO_SUBMI'.
      CALL METHOD OF MS_WORD 'INSERT'
           EXPORTING #1 = EKKO_TAB-SUBMI.
      CALL METHOD OF MS_WORD 'EDITGOTO'
           EXPORTING #1 = 'EKKO_ANGDT'.
      CALL METHOD OF MS_WORD 'INSERT'
           EXPORTING #1 = EKKO_TAB-ANGDT.
           PERFORM PRINT_LICITATION.
    ENDON.
  ENDLOOP.

*----------------------------------------------------------------------*
* Event: End-of-Selection                                              *
*----------------------------------------------------------------------*
END-OF-SELECTION.
* Put MS-Word in foreground
  CALL METHOD OF MS_WORD 'APPMAXIMIZE'.
ENDFORM.



*Messages
*-------------
* Message class: Z1
* 100
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> OLE2, Excel, WinWord All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.