然后输入文本描述,再根据自己的需求把组件都填上,下面是我之前做好的一个范例:
在这里我们要特别注意两个问题:
1. 我们的字段如果用到了QUAN和CURR类型,则必须在【货币/数量字段】页签维护【参考表】与【参考字段】,并且所维护的这两个字段是源字段的【货币/数据字段】中的最原始参考,否则无法激活
2. 在激活的时候还会出现一个警告,提示你没有维护增强目录,此时在菜单栏中选择【转到】 -> 【增强目录】 -> 【 Can Be Enhanced(Deep) 】,如下图:最后,激活结构即可。
然后切换到【TABLES】页签,输入如下参数,其中参数【E_T_DATA】是标准的目标数据参数名称,必填,否则无法创建数据源(在创建的时候会提示你先创建一个名为E_T_DATA的表参数),如下图:
其中1是目标数据表名称,2是提取结构,其中【I_T_SELECT】是抽取的选择条件,【I_T_FIELDS】是选择条件的字段。
从上往下依次是:请求次数、数据源名称、数据包大小、是否是初始化、只读标识。这些参数都是来自我们的数据源,系统自动带过来。
其他全局参数我们可以在菜单栏选择:【转到】->【全局参数】,我们可以看到,我们要写的代码要用到的参数都在这里了:
最后,转到【源代码】页签,把要抽的目标数据写入【E_T_DATA】即可,下面是我做的一个【账龄库存分析】的一个例子:
FUNCTION ZMY_BW_DATASOURCE_020.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" TABLES
*" E_T_DATA STRUCTURE ZSZMM020 OPTIONAL
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*"----------------------------------------------------------------------
TABLES : MSEG,MAKT,MARD,MSLB,MSPR,MSKA,MKPF,MKOL,MBEW.
STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
S_COUNTER_DATAPAKID LIKE SY-TABIX,
S_CURSOR TYPE CURSOR.
DATA : S_BUKRS LIKE RANGE OF ZSZMM020-BUKRS WITH HEADER LINE,
S_WERKS LIKE RANGE OF ZSZMM020-WERKS WITH HEADER LINE,
S_LGORT LIKE RANGE OF ZSZMM020-LGORT WITH HEADER LINE,
S_MATNR LIKE RANGE OF ZSZMM020-MATNR WITH HEADER LINE,
S_BUDAT LIKE RANGE OF ZSZMM020-BUDAT WITH HEADER LINE,
L_S_SELECT TYPE SRSC_S_SELECT.
IF I_INITFLAG = 'X'.
CASE I_DSOURCE.
WHEN 'Z_MM_021'.
WHEN OTHERS.
MESSAGE 'This Function Module Only Available For DataSource Z_MM_021.' TYPE 'E'.
ENDCASE.
APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT.
S_S_IF-REQUNR = I_REQUNR.
S_S_IF-DSOURCE = I_DSOURCE.
S_S_IF-MAXSIZE = I_MAXSIZE.
APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.
ELSE.
IF S_COUNTER_DATAPAKID = 0.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'BUKRS'.
MOVE-CORRESPONDING L_S_SELECT TO S_BUKRS.
APPEND S_BUKRS.
ENDLOOP.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'WERKS'.
MOVE-CORRESPONDING L_S_SELECT TO S_WERKS.
APPEND S_WERKS.
ENDLOOP.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'LGORT'.
MOVE-CORRESPONDING L_S_SELECT TO S_LGORT.
APPEND S_LGORT.
ENDLOOP.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'MATNR'.
MOVE-CORRESPONDING L_S_SELECT TO S_MATNR.
APPEND S_MATNR.
ENDLOOP.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'BUDAT'.
MOVE-CORRESPONDING L_S_SELECT TO S_BUDAT.
APPEND S_BUDAT.
ENDLOOP.
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT A~BUKRS A~WERKS A~LGORT A~MATNR B~MAKTX A~MEINS A~MENGE D~LBINS D~LBLAB C~SPEME C~INSME C~LABST E~PRSPE E~PRINS E~PRLAB I~PEINH I~STPRS F~KASPE F~KAINS F~KALAB H~BUDAT G~SLABS G~SINSM G~SSPEM
FROM MSEG AS A
INNER JOIN MAKT AS B ON A~MATNR = B~MATNR
LEFT JOIN MARD AS C ON A~WERKS = C~WERKS AND A~LGORT = C~LGORT AND A~MATNR = C~MATNR
LEFT JOIN MSLB AS D ON A~WERKS = D~WERKS AND A~MATNR = D~MATNR
LEFT JOIN MSPR AS E ON A~WERKS = E~WERKS AND A~LGORT = E~LGORT AND A~MATNR = E~MATNR
LEFT JOIN MSKA AS F ON A~WERKS = F~WERKS AND A~LGORT = F~LGORT AND A~MATNR = F~MATNR
LEFT JOIN MKOL AS G ON A~WERKS = G~WERKS AND A~LGORT = G~LGORT AND A~MATNR = G~MATNR
INNER JOIN MKPF AS H ON A~MBLNR = H~MBLNR
INNER JOIN MBEW AS I ON A~WERKS = I~BWKEY AND A~MATNR = I~MATNR
WHERE A~SHKZG = 'S'
AND B~SPRAS = '1'
AND A~BUKRS IN S_BUKRS
AND A~WERKS IN S_WERKS
AND A~LGORT IN S_LGORT
AND A~MATNR IN S_MATNR
AND H~BUDAT IN S_BUDAT.
ENDIF.
FETCH NEXT CURSOR S_CURSOR APPENDING CORRESPONDING FIELDS OF TABLE E_T_DATA PACKAGE SIZE S_S_IF-MAXSIZE.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
ENDIF.
ENDFUNCTION.
最后激活即可。PS:通过复制RSAX_BIW_GET_DATA_SIMPLE函数修改也可以,这个函数是标准的抽取模板函数。
3.进入RSO2创建数据源,选择事务数据,输入数据源名称,点击创建,如下图:
然后输入所属组,及名称描述,点击【按财务管理提取】,如下图:
在【按功能模块提取】中选择相应的功能模块和提取结构(也就是我们自己之前两个步骤创建的东西),如下图:
点击保存之后,进入字段定义:
把在函数模块定义过的选择片段都打上√,点击保存,创建完成。
数据过来了,整个过程完成了