Code: Alles auswählen.
data: g_container type scrfname value 'TN_CUSTOM_CONTROL'. " Dynpro 9000
data: alv_grid_tn type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container.
Code: Alles auswählen.
if g_custom_container is initial.
create object g_custom_container
exporting
container_name = g_container.
create object alv_grid_tn
exporting
i_parent = g_custom_container.
...
Code: Alles auswählen.
call method alv_grid_tn->set_table_for_first_display
Code: Alles auswählen.
loop at alv_grid_tn->parent->children assigning <lr_control>.
Code: Alles auswählen.
try.
lr_doi ?= <lr_control>.
* Code zum Bearbeiten
catch cx_root.
endtry.
Code: Alles auswählen.
REPORT.
DATA: go_grid TYPE REF TO cl_gui_alv_grid,
go_cc TYPE REF TO cl_gui_custom_container,
gt_data TYPE STANDARD TABLE OF sflight WITH NON-UNIQUE DEFAULT KEY,
gv_repid TYPE syrepid,
gv_dynnr TYPE sydynnr,
ok_code TYPE syucomm.
*----------------------------------------------------------------------*
* CLASS lcl_eventreceiver DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_eventreceiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: handle_ucomm FOR EVENT after_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_eventreceiver DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_eventreceiver IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_eventreceiver IMPLEMENTATION.
METHOD handle_ucomm.
CASE e_ucomm.
WHEN '&VEXCEL'.
cl_gui_cfw=>set_new_ok_code( 'Excel_angetriggert' ).
WHEN OTHERS.
ENDCASE.
ENDMETHOD. "handle_ucomm
ENDCLASS. "lcl_eventreceiver IMPLEMENTATION
START-OF-SELECTION.
SELECT * UP TO 10 ROWS INTO TABLE gt_data FROM sflight.
END-OF-SELECTION.
gv_repid = sy-repid.
gv_dynnr = '9000'.
CREATE OBJECT go_cc
EXPORTING
container_name = 'CC_9000'
repid = gv_repid
dynnr = gv_dynnr
EXCEPTIONS
OTHERS = 6.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_cc
i_appl_events = ' '
EXCEPTIONS
OTHERS = 5.
SET HANDLER lcl_eventreceiver=>handle_ucomm FOR go_grid.
go_grid->set_table_for_first_display( EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = gt_data
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4 ).
CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
SET PF-STATUS '9000'.
* SET TITLEBAR 'xxx'.
CLEAR ok_code.
ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
CASE ok_code.
WHEN 'ABBR'. SET SCREEN 0.
WHEN 'BACK'. SET SCREEN 0.
WHEN 'EXIT'. LEAVE TO SCREEN 0.
WHEN 'Excel_angetriggert'.
PERFORM get_doi.
WHEN OTHERS.
BREAK-POINT.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
*& Form GET_DOI
*&---------------------------------------------------------------------*
FORM get_doi .
FIELD-SYMBOLS: <child> LIKE LINE OF go_grid->parent->children.
DATA: lr_proxy TYPE REF TO c_oi_container_control_proxy,
ls_document_handle TYPE cntl_handle,
ole2_something TYPE ole2_object,
ole2_sheet TYPE ole2_object,
lv_document_cookie TYPE i,
lv_document_type TYPE text80,
lv_name TYPE text80.
* Childliste des Containers abklappern und das raussuchen, was nicht der Grid selber ist
LOOP AT go_grid->parent->children ASSIGNING <child> WHERE table_line <> go_grid.
EXIT.
ENDLOOP.
CHECK sy-subrc = 0.
* Was wir hier haben ist ein DOI-Proxy-Container
lr_proxy ?= <child>.
* Irgendwie brauchen wir den DocumentCookie - bei mir ist das immer 1 - aber das hier sollte auch klappen
DO 10 TIMES.
lv_document_cookie = sy-index.
lr_proxy->get_document_type( EXPORTING document_cookie = lv_document_cookie
IMPORTING document_type = lv_document_type ).
IF lv_document_type CS 'EXCEL'.
EXIT.
ENDIF.
ENDDO.
* Sicher gehen, dass wir auch wirklich einen Handle auf ein EXCEL-Dokument haben
CHECK lv_document_type CS 'EXCEL'.
* OLE-2 handle auf das EXCEL holen.
* Keine Ahnung ob das jetzt EXCEL.Application oder EXCEL.Workbook oder sonst was ist
* Aber auf jeden Fall hat es ein Attribut ActiveSheet. Damit erhält man das sichtbare Tabellenblatt
lr_proxy->get_document_handle( EXPORTING document_cookie = lv_document_cookie
IMPORTING document_handle = ls_document_handle ).
ole2_something = ls_document_handle-obj.
GET PROPERTY OF ole2_something 'ActiveSheet' = ole2_sheet." no flush. " Kein No flush da SAP wegen lokaler Var. meckert
* Um zu erkennen, dass es funktioniert den Namen des Tabreiters des aktiven Blattes auslesen
GET PROPERTY OF ole2_sheet 'Name' = lv_name." no flush. " Kein No flush da SAP wegen lokaler Var. meckert
cl_gui_cfw=>flush( ).
MESSAGE lv_name TYPE 'I'.
ENDFORM. " GET_DOI
DOI = Document Office Interfacea-dead-trousers hat geschrieben:... die Objekte auf DOI (?) casten.