其实根据代码就可以猜出来,补充上就行了。
这里我没有画CONTAINER控件,用的CL_GUI_DOCKING_CONTAINER类
首先上传模板:
OAOR
这里其实主要是object key,其他基本就是固定值:HRFPM_EXCEL_STANDARD OT
进去后上传Excel模板
模板就是你需要在sap中显示的那个Excel。
首先说明下,代码我是简化了的,仅仅是了解个过程,
比如 一般掉这几个类的方法的时候都有 error参数,其实应该加上并做异常处理的,我没处理,如:
CALL
METHOD DOCUMENT
->HAS_SPREADSHEET_INTERFACE
EXPORTING
NO_FLUSH
=
''
IMPORTING
IS_AVAILABLE
= HAS
ERROR
= ERRORS
.
还有:其实是使用的时候,需要加个锁,我代码里也忽略掉了
CALL
METHOD BDS_INSTANCE
->DOCUMENT_ENQUEUE
EXPORTING
* LOGICAL_SYSTEM =
CLASSNAME
= DOC_CLASSNAME
CLASSTYPE
= DOC_CLASSTYPE
然后说明下这几个类,找到的资料也比较少,目前得到的资料中的描述如下:
I_OI_CONTAINER_CONTROL
When you program office applications to start in the R/3 window, the interface
i_oi_container_control is used to create and manage any further objects for Desktop Office
Integration. To create an instance for this object:
I_OI_DOCUMENT_PROXY
Create an instance with reference to the interface i_oi_document_proxy for every
document to be opened simultaneously. This starts a document container in the SAPgui,
and the corresponding office application is started.
I_OI_SPREADSHEET
You use this interface to communicate with a spreadsheet.
All spreadsheets allow you to define and assign names to ranges. This interface works with
named ranges within a spreadsheet.
The individual ABAP methods contain only functions that are available in the spreadsheet
packages supported by the interface. That is, each method corresponds directly to a function
within the spreadsheet.
最后:开始写代码:
首先创建个执行程序。
然后画个屏幕,100,不用再画控件
然后逻辑流
然后gui状态
好了,然后把我下面的代码copy过去,激活就行了
*&---------------------------------------------------------------------*
*& Report YLM_TEST057
*&
*&---------------------------------------------------------------------*
*& DOI测试
*&---------------------------------------------------------------------*
REPORT YLM_TEST057
.
TABLES MAKT
.
DATA
: OK_CODE
TYPE SY
-UCOMM
,
SAVE_OK
TYPE SY
-UCOMM
.
"数据内表
DATA
: GT_DATA
TYPE
TABLE
OF MAKT
.
"CONTAINER 控件
DATA
: G_CTNER
TYPE
REF
TO CL_GUI_DOCKING_CONTAINER
.
"DOI数据
DATA
:
GCL_CONTROL
TYPE
REF
TO I_OI_CONTAINER_CONTROL
,
GCL_DOCUMENT
TYPE
REF
TO I_OI_DOCUMENT_PROXY
,
GCL_SPREADSHEET
TYPE
REF
TO I_OI_SPREADSHEET
.
DATA
: CL_BDS_INSTANCE
TYPE
REF
TO CL_BDS_DOCUMENT_SET
,
GT_DOC_SIGNATURE
TYPE SBDST_SIGNATURE
,
WA_DOC_SIGNATURE
LIKE
LINE
OF GT_DOC_SIGNATURE
,
GT_DOC_COMPONENTS
TYPE SBDST_COMPONENTS
,
GT_DOC_URIS
TYPE SBDST_URI
,
WA_DOC_URIS
LIKE
LINE
OF GT_DOC_URIS
.
"excel 数据
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
.
"选择屏幕
SELECT-OPTIONS S_MATNR
FOR MAKT
-MATNR OBLIGATORY
.
START-OF-SELECTION
.
"获取数据
PERFORM FRM_GET_DATA
.
"显示
CALL
SCREEN
100
.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text 获取数据
*----------------------------------------------------------------------*
FORM FRM_GET_DATA
.
SELECT *
FROM MAKT
INTO
TABLE GT_DATA
WHERE MAKT
~MATNR
IN S_MATNR
.
ENDFORM
.
"FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100
OUTPUT
.
SET
PF-STATUS
'0100'
.
ENDMODULE
.
" STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100
INPUT
.
SAVE_OK
= OK_CODE
.
CLEAR OK_CODE
.
CASE SAVE_OK
.
WHEN
'&PNT'
. “打印
CALL
METHOD GCL_DOCUMENT
->PRINT_DOCUMENT
EXPORTING
NO_FLUSH
=
'X'
PROMPT_USER
=
'X'
.
WHEN
OTHERS
.
ENDCASE
.
ENDMODULE
.
" USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module MDL_EXIT INPUT
*&---------------------------------------------------------------------*
* text 退出
*----------------------------------------------------------------------*
MODULE MDL_EXIT
INPUT
.
CALL
METHOD GCL_CONTROL
->DESTROY_CONTROL
.
FREE GCL_CONTROL
.
LEAVE
TO
SCREEN
0
.
ENDMODULE
.
" MDL_EXIT INPUT
*&---------------------------------------------------------------------*
*& Module MDL_INIT OUTPUT
*&---------------------------------------------------------------------*
* text 初始化 类 填充数据
*----------------------------------------------------------------------*
MODULE MDL_INIT
OUTPUT
.
PERFORM FRM_INIT
.
"* 屏幕初始化
PERFORM FRM_FILL_EXCEL
.
ENDMODULE
.
" MDL_INIT OUTPUT
*&---------------------------------------------------------------------*
*& Form FRM_INIT
*&---------------------------------------------------------------------*
* text* 屏幕初始化
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_INIT
.
* 屏幕初始化
IF G_CTNER
IS
INITIAL
.
DATA
: L_URL
(
256
)
TYPE
C
.
"get CONTROL
CALL
METHOD
C_OI_CONTAINER_CONTROL_CREATOR
=>GET_CONTAINER_CONTROL
IMPORTING
CONTROL
= GCL_CONTROL
.
CREATE OBJECT G_CTNER
EXPORTING
REPID
= SY
-REPID
DYNNR
=
'0100'
SIDE
= CL_GUI_DOCKING_CONTAINER
=>DOCK_AT_LEFT
"ALV贴屏幕左边,从左边算屏幕宽度,
EXTENSION
=
9000