1. *&---------------------------------------------------------------------*
  2. *& Report DEMOEXCELINTEGRATION *
  3. *&---------------------------------------------------------------------*
  4. INCLUDE rdemoexcelintegration2top.
  5.  
  6. DATA: control TYPE REF TO i_oi_container_control.
  7. DATA: container TYPE REF TO cl_gui_custom_container.
  8. DATA: link_server TYPE REF TO i_oi_link_server.
  9. DATA: table_coll TYPE REF TO i_oi_table_collection.
  10.  
  11. DATA: document_type TYPE soi_document_type
  12. VALUE soi_doctype_excel_chart,
  13. document_format TYPE soi_document_type.
  14.  
  15. DATA: doc_size TYPE i, doc_url TYPE t_url,
  16. doc_table TYPE sbdst_content.
  17.  
  18. DATA: usa_sales TYPE i VALUE 1000,
  19. europe_sales TYPE i VALUE 2000,
  20. japan_sales TYPE i VALUE 1000,
  21. asia_sales TYPE i VALUE 100,
  22. america_sales TYPE i VALUE 100,
  23. africa_sales TYPE i VALUE 100.
  24. DATA: total_sales TYPE i VALUE 0.
  25.  
  26. DATA: BEGIN OF test_line, region(50), sales TYPE i, END OF test_line.
  27. DATA: test_table LIKE TABLE OF test_line.
  28. DATA: wa_test_table LIKE test_line.
  29.  
  30. *---------------------------------------------------------------------*
  31. * CLASS c_excel_document DEFINITION
  32. *---------------------------------------------------------------------*
  33. * ........ *
  34. *---------------------------------------------------------------------*
  35. CLASS c_excel_document DEFINITION.
  36.  
  37. PUBLIC SECTION.
  38. DATA: proxy TYPE REF TO i_oi_document_proxy.
  39. DATA: document_type TYPE soi_document_type.
  40. DATA: data_table TYPE sbdst_content,
  41. data_size TYPE i,
  42. doc_url TYPE t_url.
  43.  
  44. METHODS: constructor
  45. IMPORTING control TYPE REF TO i_oi_container_control
  46. document_type TYPE soi_document_type.
  47.  
  48. METHODS: on_close_document
  49. FOR EVENT on_close_document OF i_oi_document_proxy
  50. IMPORTING document_proxy has_changed.
  51.  
  52. METHODS: on_custom_event
  53. FOR EVENT on_custom_event OF i_oi_document_proxy
  54. IMPORTING document_proxy event_name param_count
  55. param1 param2 param3.
  56.  
  57. METHODS: create_document
  58. IMPORTING open_inplace TYPE c DEFAULT ' '
  59. value(no_flush) TYPE c DEFAULT ' '
  60. EXPORTING error TYPE REF TO i_oi_error.
  61.  
  62. METHODS: open_document
  63. IMPORTING open_inplace TYPE c DEFAULT ' '
  64. open_readonly TYPE c DEFAULT ' '
  65. value(no_flush) TYPE c DEFAULT ' '
  66. EXPORTING error TYPE REF TO i_oi_error.
  67.  
  68. METHODS: open_document_url
  69. IMPORTING open_inplace TYPE c DEFAULT ' '
  70. open_readonly TYPE c DEFAULT ' '
  71. doc_url TYPE t_url DEFAULT ' '
  72. EXPORTING error TYPE REF TO i_oi_error.
  73.  
  74. METHODS: retrieve_document
  75. IMPORTING documents TYPE document_list
  76. EXPORTING document_format TYPE soi_document_type
  77. doc_url TYPE t_url.
  78.  
  79. METHODS: close_document
  80. IMPORTING do_save TYPE c DEFAULT ' '
  81. value(no_flush) TYPE c DEFAULT ' '
  82. EXPORTING error TYPE REF TO i_oi_error.
  83.  
  84. PRIVATE SECTION.
  85. DATA: control TYPE REF TO i_oi_container_control.
  86. ENDCLASS.
  87.  
  88. DATA: document TYPE REF TO c_excel_document.
  89. DATA: error TYPE REF TO i_oi_error.
  90. DATA: error_table TYPE TABLE OF REF TO i_oi_error.
  91. DATA: bds_instance TYPE REF TO cl_bds_document_set.
  92. *&---------------------------------------------------------------------*
  93. *& Module STATUS_0100 OUTPUT
  94. *&---------------------------------------------------------------------*
  95. MODULE status_0100 OUTPUT.
  96.  
  97. SET PF-STATUS 'MAIN0100'.
  98. SET TITLEBAR '001'.
  99.  
  100. IF control IS INITIAL.
  101. CLEAR error_table.
  102.  
  103. DATA: b_has_activex.
  104.  
  105. CALL FUNCTION 'GUI_HAS_ACTIVEX'
  106. IMPORTING
  107. return = b_has_activex.
  108. IF b_has_activex IS INITIAL. MESSAGE e007. ENDIF.
  109.  
  110. CALL METHOD c_oi_container_control_creator=>get_container_control
  111. IMPORTING control = control
  112. error = error.
  113. APPEND error TO error_table.
  114.  
  115. CREATE OBJECT container
  116. EXPORTING container_name = 'CONTAINER'.
  117.  
  118. CALL METHOD control->init_control
  119. EXPORTING r3_application_name =
  120. 'R/3 Basis' "#EC NOTEXT
  121. inplace_enabled = 'X'
  122. inplace_scroll_documents = 'X'
  123. parent = container
  124. register_on_close_event = 'X'
  125. register_on_custom_event = 'X'
  126. no_flush = 'X'
  127. IMPORTING error = error.
  128. APPEND error TO error_table.
  129.  
  130. CALL METHOD control->get_link_server
  131. EXPORTING no_flush = 'X'
  132. IMPORTING link_server = link_server
  133. error = error.
  134. APPEND error TO error_table.
  135.  
  136. CALL METHOD link_server->start_link_server
  137. EXPORTING no_flush = 'X'
  138. IMPORTING error = error.
  139. APPEND error TO error_table.
  140.  
  141. CALL METHOD control->get_table_collection
  142. EXPORTING no_flush = 'X'
  143. IMPORTING table_collection = table_coll
  144. error = error.
  145. APPEND error TO error_table.
  146.  
  147. CALL METHOD table_coll->add_table
  148. EXPORTING table_name = 'SALES_IN'
  149. table_type = table_coll->table_type_input
  150. no_flush = ' '
  151. IMPORTING error = error
  152. CHANGING data_table = test_table.
  153. APPEND error TO error_table.
  154.  
  155. LOOP AT error_table INTO error.
  156. CALL METHOD error->raise_message EXPORTING type = 'E'.
  157. ENDLOOP.
  158. CLEAR error_table.
  159.  
  160. PERFORM refresh_sales.
  161.  
  162. CREATE OBJECT document
  163. EXPORTING control = control
  164. document_type = document_type.
  165.  
  166. ENDIF.
  167. IF bds_instance IS INITIAL.
  168. CREATE OBJECT bds_instance.
  169. ENDIF.
  170.  
  171. ENDMODULE. " STATUS_0100 OUTPUT
  172.  
  173. *&---------------------------------------------------------------------*
  174. *& Module USER_COMMAND_0100 INPUT
  175. *&---------------------------------------------------------------------*
  176. MODULE user_command_0100 INPUT.
  177. DATA: l_fcode LIKE fcode.
  178.  
  179. l_fcode = fcode.
  180. CLEAR fcode.
  181.  
  182. CALL METHOD cl_gui_cfw=>dispatch.
  183.  
  184. CASE l_fcode.
  185. WHEN 'EXIT'. "Zurück
  186. IF NOT document IS INITIAL.
  187. CALL METHOD document->close_document.
  188. FREE document.
  189. ENDIF.
  190. IF NOT link_server IS INITIAL.
  191. CALL METHOD link_server->stop_link_server.
  192. FREE link_server.
  193. ENDIF.
  194. IF NOT table_coll IS INITIAL.
  195. FREE table_coll.
  196. ENDIF.
  197. IF NOT control IS INITIAL.
  198. CALL METHOD control->destroy_control.
  199. FREE control.
  200. ENDIF.
  201. IF NOT bds_instance IS INITIAL.
  202. FREE bds_instance.
  203. ENDIF.
  204.  
  205. LEAVE PROGRAM.
  206. WHEN 'CREATE'.
  207. IF NOT control IS INITIAL.
  208. CALL METHOD document->create_document.
  209. CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
  210. ENDIF.
  211. WHEN 'SELECT'.
  212. IF NOT control IS INITIAL.
  213. DATA: documents TYPE document_list.
  214. DATA: descr TYPE document_descr.
  215.  
  216. CLEAR documents.
  217. descr-document_name = 'Car Sales Chart'(do1).
  218. descr-document_id = 'DEMOEXCELCHART1'.
  219. APPEND descr TO documents.
  220. descr-document_name = 'Car Sales Chart 2'(do3).
  221. descr-document_id = 'DEMOEXCELCHART2'.
  222. APPEND descr TO documents.
  223. descr-document_name = 'Car Sales Sheet'(do2).
  224. descr-document_id = 'DEMOEXCELSHEET1'.
  225. APPEND descr TO documents.
  226.  
  227. CLEAR doc_url.
  228. CALL METHOD document->retrieve_document
  229. EXPORTING documents = documents
  230. IMPORTING document_format = document_format
  231. doc_url = doc_url.
  232.  
  233. IF NOT doc_url IS INITIAL.
  234. CALL METHOD document->close_document.
  235.  
  236. CALL METHOD document->open_document_url
  237. EXPORTING open_inplace = 'X'
  238. doc_url = doc_url
  239. IMPORTING error = error.
  240. CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
  241. ELSE.
  242. MESSAGE e010.
  243. ENDIF.
  244. ENDIF.
  245. WHEN 'OPEN'.
  246. IF document->data_size NE 0.
  247. IF NOT control IS INITIAL.
  248. CALL METHOD document->open_document
  249. IMPORTING error = error.
  250. CALL METHOD error->raise_message EXPORTING type = 'E'.
  251. ENDIF.
  252. ELSE.
  253. MESSAGE e005.
  254. ENDIF.
  255. WHEN 'INPLACE'.
  256. IF document->data_size NE 0.
  257. IF NOT control IS INITIAL.
  258. CALL METHOD document->open_document
  259. EXPORTING open_inplace = 'X'
  260. open_readonly = 'X'
  261. IMPORTING error = error.
  262. CALL METHOD error->raise_message EXPORTING type = 'E'.
  263. ENDIF.
  264. ELSE.
  265. MESSAGE e005.
  266. ENDIF.
  267. WHEN 'SAVEAS'.
  268. IF NOT document IS INITIAL AND NOT document->proxy IS INITIAL.
  269. CALL METHOD document->proxy->save_as
  270. EXPORTING prompt_user = 'X'
  271. IMPORTING error = error.
  272. CALL METHOD error->raise_message EXPORTING type = 'E'.
  273. ELSE.
  274. MESSAGE e000.
  275. ENDIF.
  276. WHEN 'CLOSE'.
  277. IF NOT document IS INITIAL.
  278. CALL METHOD document->close_document
  279. EXPORTING do_save = 'X'
  280. IMPORTING error = error.
  281. CALL METHOD error->raise_message EXPORTING type = 'E'.
  282. ELSE.
  283. MESSAGE e000.
  284. ENDIF.
  285. WHEN 'COPYLINK'.
  286. IF NOT link_server IS INITIAL.
  287. PERFORM refresh_sales.
  288. CALL METHOD link_server->execute_copy_link_dialog
  289. IMPORTING error = error.
  290. CALL METHOD error->raise_message EXPORTING type = 'E'.
  291. ELSE.
  292. MESSAGE e004.
  293. ENDIF.
  294. WHEN 'REFRESH'.
  295. IF NOT link_server IS INITIAL.
  296. PERFORM refresh_sales.
  297. ELSE.
  298. MESSAGE e004.
  299. ENDIF.
  300. IF NOT document IS INITIAL AND NOT document->proxy IS INITIAL.
  301. CALL METHOD document->proxy->execute_macro
  302. EXPORTING macro_string = 'module1.R3StartupMacro'
  303. param_count = 1
  304. param1 = 10
  305. IMPORTING error = error.
  306. * CHANGING retvalue = usa_sales.
  307. * CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
  308. ELSE.
  309. MESSAGE e000.
  310. ENDIF.
  311. WHEN 'PRINT'.
  312. IF NOT document IS INITIAL AND NOT document->proxy IS INITIAL.
  313. CALL METHOD document->proxy->print_document
  314. EXPORTING prompt_user = 'X'
  315. IMPORTING error = error.
  316. CALL METHOD error->raise_message EXPORTING type = 'E'.
  317. ELSE.
  318. MESSAGE e000.
  319. ENDIF.
  320. ENDCASE.
  321. ENDMODULE. " USER_COMMAND_0100 INPUT
  322.  
  323. ************************************************************************
  324. * CLASS c_excel_document IMPLEMENTATION.
  325. ************************************************************************
  326. CLASS c_excel_document IMPLEMENTATION.
  327. METHOD: constructor.
  328. * IMPORTING control TYPE REF TO i_oi_container_control
  329. * document_type TYPE soi_document_type
  330. me->control = control.
  331. me->document_type = document_type.
  332. ENDMETHOD.
  333.  
  334. METHOD create_document.
  335. * IMPORTING open_inplace TYPE c DEFAULT ' '
  336. * EXPORTING error TYPE REF TO i_oi_error.
  337. IF NOT proxy IS INITIAL.
  338. CALL METHOD me->close_document.
  339. ENDIF.
  340. CALL METHOD control->get_document_proxy
  341. EXPORTING document_type = document_type
  342. register_container = 'X'
  343. IMPORTING document_proxy = proxy
  344. error = error.
  345. IF error->error_code NE c_oi_errors=>ret_ok.
  346. EXIT.
  347. ENDIF.
  348.  
  349. CALL METHOD proxy->create_document
  350. EXPORTING create_view_data = 'X'
  351. open_inplace = open_inplace
  352. document_title = 'R/3 Demo' "#EC NOTEXT
  353. IMPORTING error = error.
  354. IF error->error_code NE c_oi_errors=>ret_ok.
  355. EXIT.
  356. ENDIF.
  357.  
  358. SET HANDLER me->on_close_document FOR proxy.
  359. SET HANDLER me->on_custom_event FOR proxy.
  360. ENDMETHOD.
  361.  
  362. METHOD open_document.
  363. * IMPORTING open_inplace TYPE c DEFAULT ' '
  364. * open_readonly TYPE c DEFAULT ' '
  365. * EXPORTING error TYPE REF TO i_oi_error.
  366. IF NOT proxy IS INITIAL.
  367. CALL METHOD me->close_document.
  368. ENDIF.
  369. CALL METHOD control->get_document_proxy
  370. EXPORTING document_type = document_type
  371. register_container = 'X'
  372. IMPORTING document_proxy = proxy
  373. error = error.
  374. IF error->error_code NE c_oi_errors=>ret_ok.
  375. EXIT.
  376. ENDIF.
  377.  
  378. CALL METHOD proxy->open_document_from_table
  379. EXPORTING document_table = data_table
  380. document_size = data_size
  381. open_inplace = open_inplace
  382. open_readonly = open_readonly
  383. document_title = 'R/3 Demo'
  384. IMPORTING error = error.
  385. IF error->error_code NE c_oi_errors=>ret_ok.
  386. EXIT.
  387. ENDIF.
  388.  
  389. SET HANDLER me->on_close_document FOR proxy.
  390. SET HANDLER me->on_custom_event FOR proxy.
  391.  
  392. CALL METHOD proxy->update_document_links
  393. IMPORTING error = error.
  394. ENDMETHOD.
  395.  
  396. METHOD open_document_url.
  397. * IMPORTING open_inplace TYPE c DEFAULT ' '
  398. * open_readonly TYPE c DEFAULT ' '
  399. * doc_url TYPE t_url DEFAULT ' '
  400. * EXPORTING error TYPE REF TO i_oi_error.
  401. DATA: save_error TYPE REF TO i_oi_error.
  402.  
  403. IF NOT proxy IS INITIAL.
  404. CALL METHOD me->close_document.
  405. ENDIF.
  406. CALL METHOD control->get_document_proxy
  407. EXPORTING document_type = document_type
  408. register_container = 'X'
  409. IMPORTING document_proxy = proxy
  410. error = error.
  411. IF error->error_code NE c_oi_errors=>ret_ok.
  412. EXIT.
  413. ENDIF.
  414.  
  415. me->doc_url = doc_url.
  416. CALL METHOD proxy->open_document
  417. EXPORTING document_url = doc_url
  418. open_inplace = open_inplace
  419. open_readonly = open_readonly
  420. IMPORTING error = error.
  421. IF error->error_code NE c_oi_errors=>ret_ok.
  422. EXIT.
  423. ENDIF.
  424.  
  425. data: is_available TYPE I.
  426. data: sheet_interface TYPE REF TO i_oi_spreadsheet.
  427. CALL METHOD proxy->has_spreadsheet_interface
  428. IMPORTING is_available = is_available
  429. error = error.
  430. if is_available EQ 1.
  431. CALL METHOD proxy->get_spreadsheet_interface
  432. IMPORTING sheet_interface = sheet_interface
  433. error = error.
  434.  
  435. CALL METHOD sheet_interface->select_sheet
  436. EXPORTING name = 'Sheet1'
  437. IMPORTING error = error.
  438.  
  439. CALL METHOD proxy->update_document_links
  440. IMPORTING error = error.
  441.  
  442. CALL METHOD sheet_interface->select_sheet
  443. EXPORTING name = 'Chart1'
  444. IMPORTING error = error.
  445.  
  446. endif.
  447.  
  448. * Document shall also be available in ITAB for respective operations:
  449. CALL METHOD proxy->save_document_to_table
  450. IMPORTING error = save_error
  451. CHANGING document_table = data_table
  452. document_size = data_size.
  453. IF NOT save_error IS INITIAL.
  454. IF save_error->error_code NE c_oi_errors=>ret_ok.
  455. error = save_error.
  456. EXIT.
  457. ENDIF.
  458. ENDIF.
  459. SET HANDLER me->on_close_document FOR proxy.
  460. SET HANDLER me->on_custom_event FOR proxy.
  461.  
  462. CALL METHOD proxy->update_document_links
  463. IMPORTING error = error.
  464. ENDMETHOD.
  465.  
  466. METHOD retrieve_document.
  467. * importing documents type document_list
  468. * exporting document_format type soi_document_format
  469. * doc_url type t_url.
  470. *------BDS-Data-Structures:---------------------------------------------
  471.  
  472. * Tables and WAs:
  473. DATA: doc_signature TYPE sbdst_signature,
  474. wa_doc_signature LIKE LINE OF doc_signature,
  475. doc_components TYPE sbdst_components,
  476. wa_doc_components LIKE LINE OF doc_components,
  477. doc_properties TYPE sbdst_properties,
  478. wa_doc_properties LIKE LINE OF doc_properties,
  479. doc_uris TYPE sbdst_uri,
  480. wa_doc_uris LIKE LINE OF doc_uris.
  481. * ID's:
  482. DATA: doc_classname TYPE sbdst_classname VALUE 'SOFFICEINTEGRATION',
  483. doc_classtype TYPE sbdst_classtype VALUE 'OT',
  484. doc_object_key TYPE sbdst_object_key VALUE 'SOFFICEINTEGRATION',
  485. doc_mimetype TYPE bapicompon-mimetype.
  486. *-----------------------------------------------------------------------
  487.  
  488. DATA: field_desc TYPE TABLE OF rsvbfidesc.
  489. DATA: wa_field_desc TYPE rsvbfidesc.
  490. DATA: l_nr LIKE sy-tabix.
  491.  
  492. CLEAR: field_desc, wa_field_desc.
  493. wa_field_desc-fieldnum = 1.
  494. wa_field_desc-display = 'X'.
  495. APPEND wa_field_desc TO field_desc.
  496.  
  497. l_nr = 0.
  498. CALL FUNCTION 'RS_VALUES_BOX'
  499. EXPORTING
  500. left_upper_col = 5
  501. left_upper_row = 5
  502. pagesize = 10
  503. title = 'Select document'(sdc)
  504. IMPORTING
  505. linenumber = l_nr
  506. TABLES
  507. field_desc = field_desc
  508. value_tab = documents
  509. EXCEPTIONS
  510. OTHERS = 1.
  511.  
  512. IF sy-subrc EQ 0 AND l_nr NE 0.
  513. READ TABLE documents INDEX l_nr INTO descr.
  514. IF sy-subrc EQ 0.
  515. CLEAR: wa_doc_signature, wa_doc_components, wa_doc_uris.
  516. CLEAR: doc_signature, doc_components, doc_uris.
  517.  
  518. wa_doc_signature-prop_name = 'DESCRIPTION'.
  519. wa_doc_signature-prop_value = descr-document_id.
  520. APPEND wa_doc_signature TO doc_signature.
  521.  
  522. CALL METHOD bds_instance->get_info
  523. EXPORTING classname = doc_classname
  524. classtype = doc_classtype
  525. object_key = doc_object_key
  526. CHANGING components = doc_components
  527. signature = doc_signature
  528. EXCEPTIONS nothing_found = 1
  529. error_kpro = 2
  530. internal_error = 3
  531. parameter_error = 4
  532. not_authorized = 5
  533. not_allowed = 6.
  534. IF sy-subrc NE 0 AND sy-subrc NE 1.
  535. MESSAGE e016.
  536. ENDIF.
  537. IF sy-subrc = 1.
  538. MESSAGE e017.
  539. ENDIF.
  540.  
  541. CALL METHOD bds_instance->get_with_url
  542. EXPORTING classname = doc_classname
  543. classtype = doc_classtype
  544. object_key = doc_object_key
  545. CHANGING uris = doc_uris
  546. signature = doc_signature
  547. EXCEPTIONS nothing_found = 1
  548. error_kpro = 2
  549. internal_error = 3
  550. parameter_error = 4
  551. not_authorized = 5
  552. not_allowed = 6.
  553. IF sy-subrc NE 0 AND sy-subrc NE 1.
  554. MESSAGE e016.
  555. ENDIF.
  556. IF sy-subrc = 1.
  557. MESSAGE e017.
  558. ENDIF.
  559.  
  560. READ TABLE doc_components INTO wa_doc_components INDEX 1.
  561. READ TABLE doc_uris INTO wa_doc_uris INDEX 1.
  562. doc_mimetype = wa_doc_components-mimetype.
  563. doc_url = wa_doc_uris-uri.
  564.  
  565. CASE doc_mimetype.
  566. WHEN 'application/x-rtf' OR 'text/rtf'.
  567. document_format = soi_docformat_rtf.
  568. WHEN 'application/x-oleobject'.
  569. document_format = soi_docformat_compound.
  570. WHEN 'text/plain'.
  571. document_format = soi_docformat_text.
  572. WHEN OTHERS.
  573. document_format = soi_docformat_native.
  574. ENDCASE.
  575.  
  576. ENDIF.
  577. ENDIF.
  578. ENDMETHOD.
  579.  
  580. METHOD close_document.
  581. * IMPORTING do_save TYPE c DEFAULT ' '
  582. * EXPORTING error TYPE REF TO i_oi_error.
  583. DATA: is_closed TYPE i, has_changed TYPE i.
  584. DATA: save_error TYPE REF TO i_oi_error.
  585.  
  586. IF NOT proxy IS INITIAL.
  587. CALL METHOD proxy->is_destroyed IMPORTING ret_value = is_closed.
  588.  
  589. IF is_closed IS INITIAL.
  590. CALL METHOD proxy->close_document
  591. EXPORTING do_save = do_save
  592. IMPORTING has_changed = has_changed
  593. error = error.
  594. IF error->error_code NE c_oi_errors=>ret_ok.
  595. EXIT.
  596. ENDIF.
  597. ENDIF.
  598.  
  599. IF NOT has_changed IS INITIAL.
  600. CALL METHOD proxy->save_document_to_table
  601. EXPORTING no_flush = 'X'
  602. IMPORTING error = save_error
  603. CHANGING document_table = data_table
  604. document_size = data_size.
  605. ENDIF.
  606.  
  607. CALL METHOD proxy->release_document
  608. IMPORTING error = error.
  609.  
  610. IF NOT save_error IS INITIAL.
  611. IF save_error->error_code NE c_oi_errors=>ret_ok.
  612. error = save_error.
  613. ENDIF.
  614. ENDIF.
  615.  
  616. SET HANDLER me->on_close_document FOR proxy ACTIVATION ' '.
  617. SET HANDLER me->on_custom_event FOR proxy ACTIVATION ' '.
  618. ELSE.
  619. CALL METHOD c_oi_errors=>create_error_for_retcode
  620. EXPORTING retcode = c_oi_errors=>ret_document_not_open
  621. no_flush = ' '
  622. IMPORTING error = error.
  623. ENDIF.
  624. ENDMETHOD.
  625.  
  626. METHOD on_close_document.
  627. * FOR EVENT on_close_document OF c_oi_container_control
  628. * IMPORTING document_proxy has_changed.
  629. DATA: answer, do_save.
  630.  
  631. IF has_changed EQ 1.
  632. CALL FUNCTION 'POPUP_TO_CONFIRM'
  633. EXPORTING
  634. titlebar = 'Office Integration Demo'(oid)
  635. text_question = 'Save Document?'(sav)
  636. display_cancel_button = ' '
  637. IMPORTING
  638. answer = answer.
  639. IF answer EQ '1'.
  640. do_save = 'X'.
  641. ELSE.
  642. do_save = ' '.
  643. ENDIF.
  644. CALL METHOD me->close_document
  645. EXPORTING do_save = do_save
  646. IMPORTING error = error.
  647. CALL METHOD error->raise_message
  648. EXPORTING type = 'E'.
  649. ENDIF.
  650. ENDMETHOD.
  651.  
  652. METHOD on_custom_event.
  653. * FOR EVENT on_custom_event OF i_oi_document_proxy
  654. * IMPORTING document_proxy event_name param_count
  655. * param1 param2 param3.
  656. IF event_name EQ 'ON_SERIES_CHANGE'.
  657. CALL METHOD table_coll->get_table
  658. EXPORTING table_name = 'SALES_IN'
  659. IMPORTING error = error
  660. CHANGING data_table = test_table.
  661. CALL METHOD error->raise_message
  662. EXPORTING type = 'E'.
  663. CLEAR wa_test_table.
  664. READ TABLE test_table INTO wa_test_table INDEX 1.
  665. usa_sales = wa_test_table-sales.
  666. CLEAR wa_test_table.
  667. READ TABLE test_table INTO wa_test_table INDEX 2.
  668. europe_sales = wa_test_table-sales.
  669. CLEAR wa_test_table.
  670. READ TABLE test_table INTO wa_test_table INDEX 3.
  671. japan_sales = wa_test_table-sales.
  672. CLEAR wa_test_table.
  673. READ TABLE test_table INTO wa_test_table INDEX 4.
  674. asia_sales = wa_test_table-sales.
  675. CLEAR wa_test_table.
  676. READ TABLE test_table INTO wa_test_table INDEX 5.
  677. america_sales = wa_test_table-sales.
  678. CLEAR wa_test_table.
  679. READ TABLE test_table INTO wa_test_table INDEX 6.
  680. africa_sales = wa_test_table-sales.
  681. CLEAR wa_test_table.
  682.  
  683. ENDIF.
  684. ENDMETHOD.
  685. ENDCLASS.
  686.  
  687. ************************************************************************
  688. * FORM refresh_sales.
  689. ************************************************************************
  690. FORM refresh_sales.
  691. DATA: BEGIN OF item_line,
  692. region(60),
  693. sales TYPE i,
  694. date TYPE d,
  695. time TYPE t,
  696. weight TYPE f,
  697. amount TYPE p DECIMALS 3,
  698. id(10) TYPE n,
  699. END OF item_line.
  700. DATA: sales_table LIKE TABLE OF item_line.
  701. DATA: wa_sales_table LIKE item_line.
  702. DATA: fields_table TYPE TABLE OF rfc_fields.
  703. DATA: wa_fields_table TYPE rfc_fields.
  704. DATA: ind TYPE i.
  705.  
  706. CALL FUNCTION 'DP_GET_FIELDS_FROM_TABLE'
  707. TABLES
  708. data = sales_table
  709. fields = fields_table.
  710.  
  711. READ TABLE fields_table INDEX 1 INTO wa_fields_table.
  712. wa_fields_table-fieldname = 'Region'."#EC NOTEXT
  713. MODIFY fields_table FROM wa_fields_table INDEX 1.
  714. CLEAR wa_fields_table.
  715. READ TABLE fields_table INDEX 2 INTO wa_fields_table.
  716. wa_fields_table-fieldname = 'Sales'. "#EC NOTEXT
  717. MODIFY fields_table FROM wa_fields_table INDEX 2.
  718.  
  719. CLEAR: sales_table, wa_sales_table.
  720.  
  721. wa_sales_table-region = 'USA'(usa).
  722. wa_sales_table-sales = usa_sales.
  723. APPEND wa_sales_table TO sales_table.
  724. CLEAR wa_sales_table.
  725. wa_sales_table-region = 'Europe'(eur).
  726. wa_sales_table-sales = europe_sales.
  727. APPEND wa_sales_table TO sales_table.
  728. CLEAR wa_sales_table.
  729. wa_sales_table-region = 'Japan'(jap).
  730. wa_sales_table-sales = japan_sales.
  731. APPEND wa_sales_table TO sales_table.
  732. CLEAR wa_sales_table.
  733. wa_sales_table-region = 'Asia'(asi).
  734. wa_sales_table-sales = asia_sales.
  735. APPEND wa_sales_table TO sales_table.
  736. CLEAR wa_sales_table.
  737. wa_sales_table-region = 'America'(ame).
  738. wa_sales_table-sales = america_sales.
  739. APPEND wa_sales_table TO sales_table.
  740. CLEAR wa_sales_table.
  741. wa_sales_table-region = 'Africa'(afr).
  742. wa_sales_table-sales = africa_sales.
  743. APPEND wa_sales_table TO sales_table.
  744. CLEAR wa_sales_table.
  745.  
  746. LOOP AT sales_table INTO wa_sales_table.
  747. ind = sy-tabix.
  748. wa_sales_table-date = sy-datum + ind.
  749. wa_sales_table-time = sy-uzeit + ind.
  750. wa_sales_table-weight = 100000 * ind.
  751. wa_sales_table-amount = 11111 * ind.
  752. wa_sales_table-id = ind.
  753. MODIFY sales_table FROM wa_sales_table INDEX ind.
  754. ENDLOOP.
  755.  
  756. CALL METHOD table_coll->add_table
  757. EXPORTING table_name = 'SALES_OUT'
  758. table_type = table_coll->table_type_output
  759. no_flush = 'X'
  760. IMPORTING error = error
  761. CHANGING data_table = sales_table
  762. fields_table = fields_table.
  763.  
  764. CALL METHOD link_server->add_table_item2
  765. EXPORTING item_name = 'Sales' "#EC NOTEXT
  766. item_title = 'Car Sales Figures'(sal)
  767. no_flush = 'X'
  768. IMPORTING error = error
  769. CHANGING data_table = sales_table
  770. fields_table = fields_table.
  771.  
  772. CALL METHOD link_server->add_string_item
  773. EXPORTING item_name = 'ChartTitle'
  774. item_title = 'Chart Title'(ti0)
  775. item_value = 'Car Sales by Region'(ti1)
  776. no_flush = 'X'
  777. IMPORTING error = error.
  778. CALL METHOD link_server->add_string_item
  779. EXPORTING item_name = 'ColumnTitle1'
  780. item_title = 'Column Title 1'(ti2)
  781. item_value = 'Region'(ti3)
  782. no_flush = 'X'
  783. IMPORTING error = error.
  784. CALL METHOD link_server->add_string_item
  785. EXPORTING item_name = 'ColumnTitle2'
  786. item_title = 'Column Title 2'(ti4)
  787. item_value = 'Sold Cars'(ti5)
  788. no_flush = ' '
  789. IMPORTING error = error.
  790.  
  791. ENDFORM.
  1. *----------------------------------------------------------------------*
  2. * INCLUDE RDEMOEXCELINTEGRATIONTOP2 *
  3. *----------------------------------------------------------------------*
  4. REPORT saprdemoexcelintegration2 MESSAGE-ID demoofficeintegratio.
  5.  
  6. SET SCREEN 100.
  7.  
  8. TYPE-POOLS: sbdst, soi.
  9.  
  10. CLASS c_oi_errors DEFINITION LOAD.
  11.  
  12. TYPES: BEGIN OF document_descr,
  13. document_name(40), document_id(64),
  14. END OF document_descr.
  15.  
  16. TYPES: document_list TYPE TABLE OF document_descr.
  17. TYPES: t_url LIKE bapiuri-uri.
  18.  
  19. DATA: fcode LIKE sy-ucomm.

SAP Office Excel Intergration的更多相关文章

  1. Microsoft Office Excel 不能访问文件及COM无法访问

    Microsoft Office Excel 不能访问文件及COM无法访问 Microsoft Office Excel 不能访问文件“*.xls”. 可能的原因有: 1 文件名称或路径不存在. 2  ...

  2. Microsoft Office Excel 不能访问文件 的解决办法

    Microsoft Office Excel 不能访问文件"a.xls". 可能的原因有: ? 文件名称或路径不存在.  ? 文件正被其他程序使用.  ? 您正要保存的工作簿与当前 ...

  3. PHPExcel 是用来操作Office Excel 文档的一个PHP类库

    PHPExcel 是用来操作Office Excel 文档的一个PHP类库,它基于微软的OpenXML标准和PHP语言.可以使用它来读取.写入不同格式的电子表格,如 Excel (BIFF) .xls ...

  4. [Excel操作]Microsoft Office Excel 不能访问文件

    最近,客户服务器迁移,因操作系统环境变化而引起的的环境问题一堆,遇到的问题并解决方法在“[Excel]操作”类别会体现. Microsoft Office Excel 不能访问文件“C:\\LMSEx ...

  5. Microsoft Office Excel 不能访问文件

    问题描述: Microsoft Office Excel 不能访问文件“XX.xls”.可能的原因有: 1 文件名称或路径不存在.2 文件正被其他程序使用.3 您正要保存的工作簿与当前打开的工作簿同名 ...

  6. ERP中通过EDI导入资料的时候出现【Microsoft Office Excel不能访问文件‘C:\Windows\TEMP\433....’

    问题描述: ERP中导入单据的时候报错,Microsoft Office Excel不能访问文件'C:\Windows\TEMP\433....可能的原因有:·文件名称或路径不存在,文件正被其他程序使 ...

  7. OS + Windows 10 / office excel vlookup / CredSSP

    s https://support.microsoft.com/zh-cn/help/10749/windows-10-find-product-key 查找 Windows 7 或 Windows ...

  8. office excel中怎么添加批注及修改批注用户名

    office excel中怎么添加批注及修改批注用户名 参考:https://jingyan.baidu.com/article/c33e3f48a52853ea15cbb5db.html 1. of ...

  9. CVE-2011-0104 Microsoft Office Excel缓冲区溢出漏洞 分析

    漏洞简述   Microsoft Excel是Microsoft Office组件之一,是流行的电子表格处理软件.        Microsoft Excel中存在缓冲区溢出漏洞,远程攻击者可利用此 ...

随机推荐

  1. Linux 开启远程访问

    系统:Ubuntu16.0 虚拟机 问题:Windows访问Ubun被拒绝 解决方法: 1.先检测是否安装SSH服务 1 sudo apt-get install ssh 2.编辑ssh配置文件 1 ...

  2. 汇编语言实验1—Debug基础操作

    1.使用Debug,将下面的程序段写入内存,逐条执行,观察每条指令执行后CPU中相关寄存器中内容的变化. 记录1:最后一条指令执行完BX=(4026)H,AL=(66)H,检验结果. 两种写入:e命令 ...

  3. JavaScript学习总结6-apply

    JS中的apply方法可以控制this指向 任何JS支持的类型都可以转化为JSON JS对象是键值对型的,JSON是字符串型的 原型对象:__proto__ JS万物皆对象,ES6开始提供了对后端开发 ...

  4. 【课程汇总】OpenHarmony全场景Demo数字管家系列课(附链接)

    小孩放学了,做作业的时间到,窗帘.护眼灯自动打开,关掉电视和扫地机,给小孩一个安静舒适的学习环境:碰到学习难题,可以随时请求你的远程指导:晚上回家休息了,选择舒适的氛围灯,伴随着睡眠音乐进入梦乡:出门 ...

  5. python爬取快手小姐姐视频

    流程分析 一.导入需要的三方库 import re #正则表表达式文字匹配 import requests #指定url,获取网页数据 import json #转化json格式 import os ...

  6. 自己的~/.vimrc

    " 语法高亮syntax on " 搜索高亮set hlsearch " 显示行号set number" let mapleader="," ...

  7. 虚拟机(Vmvare)与配置,得到一台学习机

    准备: 1.Vmvare 2.CentOS7.4镜像 安装与配置操作系统: 1.配置虚拟机上网 2.配置静态ip地址 开始安装 1. 2.直接下一步选择我们准备好的镜像,然后下一步 3.修改虚拟机的名 ...

  8. 让服务调用更简单 - Caller.HttpClient

    前言 绝大多数项目都离不开服务调用,服务的调用方式通常是基于Http.RPC协议的调用,需要获取到对应服务的域名或者ip地址以及详细的控制器方法后才能进行调用,如果项目需要支持分布式部署,则需要借助服 ...

  9. 异步编程利器:CompletableFuture

    一.一个示例回顾Future 一些业务场景我们需要使用多线程异步执行任务,加快任务执行速度. JDK5新增了Future接口,用于描述一个异步计算的结果.虽然 Future 以及相关使用方法提供了异步 ...

  10. 探索 Python/Django 支持分布式多租户数据库,如 Postgres+Citus

    在 确定分布策略 中,我们讨论了在多租户用例中使用 Citus 所需的与框架无关的数据库更改. 在这里,我们专门研究如何借助 django-multitenant 库将多租户 Django 应 用程序 ...