오브젝트특성을 읽는 동안 오류가 발생했습니다
>메시지 번호 SOFFICEINTEGRATION205
>
>
>-------------------------------------
>위와 같이 메시지가 뜨면서 실행이 안되요.
>
>주인장님 소스를 그대로 붙여서 넣었는데, 안되서요..
>이거 어떻게 하면 실행 가능할가요? 엑셀을 ABAP에서 직접 불러서 작업하는거 만들면
>ALV EDIT를 대체해서 쓰기 편할 것 같아서요..
>
>답변 좀 부탁드려요!
제가 샘플링 해놓은 소스가 있는데 도움이 되실지 모르겠네요.
컨테이너에 엑셀 띄어놓고 셀단위 그룹으로 읽기/쓰기 다 가능할 거예요.
약간만 응용하시면 실무에 도움이 되실지도 모르겠네요.
테스트 하고 올려드리는 것이니 잘 될 거예요. ^^
전제 조건 : 화면 100
pf-status '100' .
[flow-logic].
PROCESS BEFORE OUTPUT.
MODULE status.
PROCESS AFTER INPUT.
MODULE exit AT EXIT-COMMAND.
MODULE user_command.
[소스코드]
TYPE-POOLS: soi.
DATA: ok_code TYPE syucomm.
* SAP Desktop Office Integration Interfaces
DATA: control TYPE REF TO i_oi_container_control,
document TYPE REF TO i_oi_document_proxy,
spreadsheet TYPE REF TO i_oi_spreadsheet,
error TYPE REF TO i_oi_error,
errors TYPE REF TO i_oi_error OCCURS 0 WITH HEADER LINE.
* spreadsheet interface structures for Excel data input
DATA: cellitem TYPE soi_generic_item.
DATA: rangeitem TYPE soi_range_item.
DATA: ranges TYPE soi_range_list.
DATA: excel_input TYPE soi_generic_table.
DATA: excel_input_wa TYPE soi_generic_item.
DATA: columns_number TYPE i,
rows_number TYPE i.
START-OF-SELECTION.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
MODULE exit INPUT.
LEAVE TO SCREEN 0.
ENDMODULE. " EXIT INPUT
*&---------------------------------------------------------------------*
*& Module STATUS OUTPUT
*&---------------------------------------------------------------------*
MODULE status OUTPUT.
SET PF-STATUS '100'.
IF control IS NOT BOUND.
* first get the SAP DOI i_oi_container_control interface
CALL METHOD c_oi_container_control_creator=>get_container_control
IMPORTING
control = control
error = error.
* specified above and tell it to run Excel in-place
CALL METHOD control->init_control
EXPORTING
r3_application_name = 'R/3 Basis' "#EC NOTEXT
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = cl_gui_container=>default_screen
register_on_close_event = 'X'
register_on_custom_event = 'X'
no_flush = 'X'
IMPORTING
error = errors.
* ask the SAP DOI container for a i_oi_d0cument_proxy for Excel
CALL METHOD control->get_document_proxy
EXPORTING
document_type = 'Excel.Sheet'
no_flush = 'X'
IMPORTING
document_proxy = document
error = errors.
* and then create a new Excel sheet
CALL METHOD document->create_document
EXPORTING
open_inplace = 'X'
document_title = 'R/3 table contents in Excel' "#EC NOTEXT
no_flush = 'X'
IMPORTING
error = errors.
* check if our d0cument proxy can serve a spreadsheet interface data:
* => SpreadSheet 에 대하여 interface 를 하겠습니다. ^^
DATA: has TYPE i.
CALL METHOD document->has_spreadsheet_interface
EXPORTING
no_flush = 'X'
IMPORTING
is_available = has
error = errors.
CALL METHOD document->get_spreadsheet_interface
EXPORTING
no_flush = ' '
IMPORTING
sheet_interface = spreadsheet
error = errors.
ENDIF.
ENDMODULE. " STATUS OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND INPUT
*&---------------------------------------------------------------------*
MODULE user_command INPUT.
CASE ok_code.
WHEN 'GXLS'. " Get excels
REFRESH: excel_input, ranges.
rangeitem-name = 'SAP_Table'.
APPEND rangeitem TO ranges.
CALL METHOD spreadsheet->get_ranges_data
EXPORTING
all = ' '
no_flush = ' '
IMPORTING
contents = excel_input
CHANGING
ranges = ranges.
* check no errors occured
CALL METHOD error->raise_message
EXPORTING
type = 'E'.
* DESCRIBE TABLE excel_input LINES exceldata-lines.
WHEN 'PXLS'. " Put excels
rows_number = columns_number = 2.
REFRESH: ranges, excel_input.
rangeitem-name = 'SAP_Table'.
excel_input_wa-column = rangeitem-columns = 1.
excel_input_wa-row = rangeitem-rows = 1.
DO rows_number TIMES.
excel_input_wa-value = 'TEST'.
APPEND rangeitem TO ranges.
APPEND excel_input_wa TO excel_input.
ADD 1 TO : excel_input_wa-column, rangeitem-columns,
excel_input_wa-row, rangeitem-rows.
ENDDO.
* create an excel range for our data
CALL METHOD spreadsheet->insert_range_dim
EXPORTING
name = 'SAP_Table'
top = 3
left = 3
rows = rows_number
columns = columns_number
no_flush = 'X'
IMPORTING
error = errors.
CALL METHOD spreadsheet->set_color
EXPORTING
rangename = 'SAP_Table'
back = '45'
front = '2'
no_flush = 'X'
IMPORTING
error = errors.
CALL METHOD spreadsheet->set_ranges_data
EXPORTING
ranges = ranges
contents = excel_input
no_flush = 'X'
IMPORTING
error = errors.
APPEND errors.
CALL METHOD spreadsheet->fit_widest
EXPORTING
name = space
no_flush = 'X'.
* now flush automation queue
CALL METHOD control->set_focus
EXPORTING
no_flush = ' '
IMPORTING
error = errors.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " USER_COMMAND INPUT
댓글 2
-
김기만
2010.03.03 17:54
-
예스맨
2010.03.10 00:54
저도 호기심에 요요님 소스 테스트 해봤는데요...궁금한점이 발생해서요..
엑셀화면의 값을 읽는 로직이 잘 작동이 안되서 그러는데요.. 왜 그럴까요?
밑에 부분 같은데. excel_input 인터널테이블 값에 아무값도 들어오지가 않네요 -_-.
CALL METHOD spreadsheet->get_ranges_data
EXPORTING
all = ' '
no_flush = ' '
IMPORTING
contents = excel_input
CHANGING
고맙습니다.. 소스 갖다가 붙여 넣기 해보니 잘 돌아가네요..
이제 소스 분석 해보도록 하겠습니다. 좋은 하루 되세요!