Warning: include_once(http://erpgenie.com/_borders/topabap.htm) [function.include-once]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/vhosts/erpgenie.com/httpdocs/abaptips/templates/rhuk_solarflare_ii/index.php on line 52

Warning: include_once() [function.include]: Failed opening 'http://erpgenie.com/_borders/topabap.htm' for inclusion (include_path='.:') in /var/www/vhosts/erpgenie.com/httpdocs/abaptips/templates/rhuk_solarflare_ii/index.php on line 52

Login

Login to view more content!!!





Lost Password?
No account yet? Register

Registered Access

Poll

What area of ABAP are you interested in?
 
Home arrow Sample Code arrow ABAP OO arrow Displaying excel using classes
Displaying excel using classes PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Anon.   
Tuesday, 27 February 2007
Instantiates the control framework using i_oi_document factory. Excapsulates SAP Office Integration specific functionality.  Uses the i_oi_document_proxy class to create the document link then uses the i_oi_table collection for transporting SAP internal tables from the server to the client for display in the active document server.

  1 *----------------------------------------------------------------------*

  2 *   INCLUDE ZIOIEXCEL                                                  *

  3 *----------------------------------------------------------------------*

  4 * Instantiates the control framework using i_oi_document factory.

  5 * Excapsulates SAP Office Integration specific functionality.  Uses the

  6 * i_oi_document_proxy class to create the document link then

  7 * uses the i_oi_table collection for transporting SAP internal tables

  8 * from the server to the client for display in the active document

  9 * server.

 10

 11 INCLUDE <CTLDEF>.                "General Definitions For Controls (CET)

 12 * Platform- and application-indep. Office integration

 13 INCLUDE OFFICEINTEGRATIONINCLUDE.

 14

 15 CLASS COIEXCEL DEFINITION.  "Excel DOI wrapper class

 16   PUBLIC SECTION.

 17

 18 * Create the control framework and returns a document proxy interface

 19   METHODS: CONSTRUCTOR,

 20 * Clean up routine

 21            DESTROY.

 22 * Catch the on_close event to process cleanup

 23   METHODS: ON_CLOSE_DOCUMENT

 24              FOR EVENT ON_CLOSE_DOCUMENT OF I_OI_DOCUMENT_PROXY.

 25   METHODS: CREATEDOCUMENT   "Not used

 26              IMPORTING S_DOCTITLE TYPE C

 27              EXPORTING RETCODE TYPE T_OI_RET_STRING.

 28   METHODS: OPENDOCUMENT

 29              IMPORTING FILEURL TYPE C

 30              EXPORTING RETCODE TYPE T_OI_RET_STRING.

 31   METHODS: TRANSFERTABLE

 32               IMPORTING S_TABLENAME TYPE C

 33               EXPORTING RETCODE TYPE T_OI_RET_STRING

 34               CHANGING I_TAB TYPE TABLE.

 35   METHODS: LAUNCHSE16 IMPORTING C_TBLNAME TYPE C

 36                                 C_FILEPATH TYPE C

 37                       CHANGING  TBL_TAB TYPE TABLE.

 38   PRIVATE SECTION.

 39   DATA:

 40     H_FACTORY TYPE REF TO I_OI_DOCUMENT_FACTORY,

 41     H_TABLES TYPE REF TO I_OI_TABLE_COLLECTION,

 42     H_DOCUMENT TYPE REF TO I_OI_DOCUMENT_PROXY,

 43     S_RETCODE TYPE T_OI_RET_STRING,

 44     S_FILEURL(256) TYPE C,

 45     S_DOCURL(256) TYPE C.

 46

 47 ENDCLASS.

 48

 49 CLASS COIEXCEL IMPLEMENTATION.

 50   METHOD CONSTRUCTOR.

 51 *-----------------------------------------------------------------------

 52 *  For external execution we simply use the factory class.  (vs 4.5)

 53 *

 54 *-----------------------------------------------------------------------

 55 DATA: DOCUMENT_EXCEL TYPE SOI_DOCUMENT_TYPE

 56                  VALUE SOI_DOCTYPE_EXCEL97_SHEET.

 57

 58     CALL FUNCTION 'CONTROL_INIT'   "Initialize the control framework

 59          EXCEPTIONS

 60               CONTROL_INIT_ERROR = 1

 61               OTHERS             = 2.

 62 * Starting point - get a reference to the control framework

 63     call method c_oi_factory_creator=>get_document_factory

 64          exporting factory_type = 'OLE'

 65          IMPORTING FACTORY = H_FACTORY

 66                    RETCODE = S_RETCODE.

 67     call method c_oi_errors=>show_message exporting type = 'E'.

 68 * DOI Container object creation

 69     CALL METHOD H_FACTORY->START_FACTORY

 70          EXPORTING R3_APPLICATION_NAME = 'SAP-Excel DOI'

 71                    REGISTER_ON_CLOSE_EVENT = 'X'

 72          IMPORTING RETCODE = S_RETCODE.

 73 * Get a reference to the document proxy

 74     CALL METHOD H_FACTORY->GET_DOCUMENT_PROXY

 75       EXPORTING DOCUMENT_TYPE = DOCUMENT_EXCEL

 76       IMPORTING DOCUMENT_PROXY = H_DOCUMENT

 77             RETCODE = S_RETCODE.

 78     CALL METHOD C_OI_ERRORS=>SHOW_MESSAGE

 79                             EXPORTING TYPE = 'E'.

 80 * Register the on_close event

 81    SET HANDLER ME->ON_CLOSE_DOCUMENT FOR H_DOCUMENT.

 82

 83   ENDMETHOD.                           " Constructor.. COIExcel

 84

 85 * Cleanup

 86   METHOD DESTROY.

 87

 88     IF NOT H_TABLES IS INITIAL.

 89       CALL METHOD H_TABLES->REMOVE_ALL_TABLES

 90                     IMPORTING RETCODE = S_RETCODE.

 91       FREE H_TABLES.

 92     ENDIF.

 93

 94     IF NOT H_FACTORY IS INITIAL.

 95       CALL METHOD H_FACTORY->STOP_FACTORY.

 96       FREE H_FACTORY.

 97     ENDIF.

 98

 99     FREE H_DOCUMENT.

100     CALL FUNCTION 'CONTROL_EXIT'.

101

102   ENDMETHOD.                           " Destructor.... COIExcel

103

104   METHOD ON_CLOSE_DOCUMENT.

105 *        for event on_close_document of i_oi_document_proxy.

106     IF NOT H_DOCUMENT IS INITIAL.

107       CALL METHOD H_DOCUMENT->CLOSE_DOCUMENT

108         IMPORTING RETCODE = S_RETCODE.

109       CALL METHOD C_OI_ERRORS=>SHOW_MESSAGE

110                                     EXPORTING TYPE = 'E'.

111     ENDIF.

112

113 * Cleanup the DOI allocations and the control framework.

114     CALL METHOD ME->DESTROY.

115 *   message id 'mo' type 'S' number '001' with 'Enter selection table.'.

116   ENDMETHOD.

117

118   METHOD CREATEDOCUMENT.

119 *        importing s_doctitle type c

120 *        exporting s_retcode type t_oi_ret_string.

121

122     IF NOT H_DOCUMENT IS INITIAL.

123       CALL METHOD H_DOCUMENT->CREATE_DOCUMENT

124         EXPORTING OPEN_INPLACE = ' '

125                 DOCUMENT_TITLE = S_DOCTITLE

126         IMPORTING RETCODE = S_RETCODE.

127       CALL METHOD C_OI_ERRORS=>SHOW_MESSAGE EXPORTING TYPE = 'E'.

128     ENDIF.

129

130   ENDMETHOD.

131

132 * Parameters are set to open the document specified by fileurl,

133 *  opened externally, and run the startup macro that resides

134 *  inside the Excel document.

135   METHOD OPENDOCUMENT.

136 *   importing fileurl type c

137 *   exporting s_retcode type t_oi_ret_string.

138

139     CALL METHOD H_DOCUMENT->OPEN_DOCUMENT

140            EXPORTING

141                     DOCUMENT_URL = FILEURL

142                     OPEN_INPLACE = ' '

143                     STARTUP_MACRO    = 'Module1.LoadR3Data'

144           IMPORTING RETCODE = S_RETCODE.

145

146     CALL METHOD C_OI_ERRORS=>SHOW_MESSAGE EXPORTING TYPE ='E'.

147

148   ENDMETHOD.

149

150   METHOD TRANSFERTABLE.

151 *    importing s_tblname type c

152 *    exporting retcode type t_oi_ret_string

153 *    changing i_tab type table

154

155     IF H_TABLES IS INITIAL.

156       CALL METHOD H_FACTORY->GET_TABLE_COLLECTION

157                     IMPORTING TABLE_COLLECTION = H_TABLES

158                               RETCODE = S_RETCODE.

159       CALL METHOD C_OI_ERRORS=>SHOW_MESSAGE EXPORTING TYPE = 'E'.

160     ENDIF.

161

162 *transfer data to presentation server

163     CALL METHOD H_TABLES->ADD_TABLE

164          EXPORTING TABLE_NAME   = 'ITAB'

165                    TABLE_TYPE   = H_TABLES->TABLE_TYPE_OUTPUT

166                    DDIC_NAME    = S_TABLENAME

167                    DESCRIPTION  = 'Block Data'

168          IMPORTING

169                    RETCODE      = S_RETCODE

170          CHANGING  DATA_TABLE   = I_TAB.

171     RETCODE = S_RETCODE.

172   ENDMETHOD.

173

174 * Specific method for use in the ZBTableListGeneration program.

175 * Simplifies the dynamic program creation

176   METHOD LAUNCHSE16.

177 *      importing c_tblname type c

178 *                c_filepath type c

179 *      changing  tbl_tab type table

180

181     CALL METHOD ME->TRANSFERTABLE

182                   EXPORTING S_TABLENAME = C_TBLNAME

183                   IMPORTING RETCODE = S_RETCODE

184                   CHANGING I_TAB = TBL_TAB.

185

186     CALL METHOD ME->OPENDOCUMENT

187                  EXPORTING FILEURL = C_FILEPATH.

188   ENDMETHOD.

189

190 ENDCLASS.                              "COIEXCEL Implemetation


Related Items:

 
< Prev   Next >

Google Search

Statistics

Contribution Activity
Utilities: 38
Tips and Tricks: 333
Sample Code: 164
Total Contributions: 550

Member Activity
Members: 6244 since 2/1/2007!
New: 0 since yesterday!
Visitors: 1080608
We have 1 guest online

Newest Members

Welcome our newest members:

Google Ads


Warning: include(http://erpgenie.com/_borders/bottom.htm) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/vhosts/erpgenie.com/httpdocs/abaptips/includes/footer.php on line 22

Warning: include() [function.include]: Failed opening 'http://erpgenie.com/_borders/bottom.htm' for inclusion (include_path='.:') in /var/www/vhosts/erpgenie.com/httpdocs/abaptips/includes/footer.php on line 22