本文主要是介绍BW数据源创建之从函数模块+提取结构,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、到SE11创建提取结构(一般与抽取的目标数据字段相同),如图下,输入数据类型名称,点击创建:
然后选择数据类型:结构
创建一个新结构ZMMR0015_JG
结构中参考表与参考字段可以参考自己结构中的字段
或者;在这里我们要特别注意两个问题:
1. 我们的字段如果用到了QUAN和CURR类型,则必须在【货币/数量字段】页签维护【参考表】与【参考字段】,并且所维护的这两个字段是源字段的【货币/数据字段】中的最原始参考,否则无法激活
2. 在激活的时候还会出现一个警告,提示你没有维护增强目录,此时在菜单栏中选择【转到】->【增强目录】->【Can Be Enhanced(Deep)】,如下图
2.到SE37创建要抽取数据的函数模块,输入名称:可以自己创建
后者复制标准的函数: RSAX_BIW_GET_DATA_SIMPLE
然后切换到【TABLES】页签,输入如下参数,其中参数【E_T_DATA】是标准的目标数据参数名称,必填,否则无法创建数据源(在创建的时候会提示你先创建一个名为E_T_DATA的表参数),如下图:
其中1是目标数据表名称,2是提取结构,其中【I_T_SELECT】是抽取的选择条件,【I_T_FIELDS】是选择条件的字段。
我们还可以到【IMPORT】页签中添加如下参数:
从上往下依次是:请求次数、数据源名称、数据包大小、是否是初始化、只读标识。这些参数都是来自我们的数据源,系统自动带过来。
源代码:修改的地方
源代码:
FUNCTION ZMM_GET_DATA_ZMMR0015.
*"----------------------------------------------------------------------
*"*"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
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZMMR0015_JG OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------
* Example: DataSource for table SFLIGHT
*
TABLES: ZMMR0015_LOG.
* Auxiliary Selection criteria structure
DATA: L_S_SELECT TYPE SRSC_S_SELECT.
* Maximum number of lines for DB table
STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
* counter
S_COUNTER_DATAPAKID LIKE SY-TABIX,
* cursor
S_CURSOR TYPE CURSOR.
* Select ranges
RANGES: S_MANDT FOR ZMMR0015_LOG-MANDT,
S_JZDATE FOR ZMMR0015_LOG-JZDATE,
S_WERKS FOR ZMMR0015_LOG-WERKS,
S_MATNR FOR ZMMR0015_LOG-MATNR,
S_LGORT FOR ZMMR0015_LOG-LGORT.
* Initialization mode (first call by SAPI) or data transfer mode
* (following calls) ?
IF I_INITFLAG = SBIWA_C_FLAG_ON.
************************************************************************
* Initialization: check input parameters
* buffer input parameters
* prepare data selection
************************************************************************
* Check DataSource validity
CASE I_DSOURCE.
WHEN 'ZMMR0015_DS'.
WHEN OTHERS.
IF 1 = 2. MESSAGE E009(R3). ENDIF.
* this is a typical log call. Please write every error message like this
LOG_WRITE 'E' "message type
'R3' "message class
'009' "message number
I_DSOURCE "message variable 1
' '. "message variable 2
RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDCASE.
APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT.
* Fill parameter buffer for data extraction calls
S_S_IF-REQUNR = I_REQUNR.
S_S_IF-DSOURCE = I_DSOURCE.
S_S_IF-MAXSIZE = I_MAXSIZE.
* Fill field list table for an optimized select statement
* (in case that there is no 1:1 relation between InfoSource fields
* and database table fields this may be far from beeing trivial)
APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.
DELETE S_S_IF-T_FIELDS WHERE FIELDNM EQ 'WAERS'.
ELSE. "Initialization mode or data extraction ?
************************************************************************
* Data transfer: First Call OPEN CURSOR + FETCH
* Following Calls FETCH only
************************************************************************
* First data package -> OPEN CURSOR
IF S_COUNTER_DATAPAKID = 0.
* Fill range tables BW will only pass down simple selection criteria
* of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'JZDATE'.
MOVE-CORRESPONDING L_S_SELECT TO S_JZDATE.
APPEND S_JZDATE.
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 = '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 = 'LGORT'.
MOVE-CORRESPONDING L_S_SELECT TO S_LGORT .
APPEND S_LGORT .
ENDLOOP.
* Determine number of database records to be read per FETCH statement
* from input parameter I_MAXSIZE. If there is a one to one relation
* between DataSource table lines and database entries, this is trivial.
* In other cases, it may be impossible and some estimated value has to
* be determined.
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT (S_S_IF-T_FIELDS) FROM ZMMR0015_LOG
WHERE JZDATE IN S_JZDATE AND
WERKS IN S_WERKS AND
MATNR IN S_MATNR AND
LGORT IN S_LGORT.
ENDIF. "First data package ?
* Fetch records into interface table.
* named E_T_'Name of extract structure'.
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.
3.进入RSO2创建数据源,选择事务数据,输入数据源名称,点击创建,如下图:
然后输入所属组,及名称描述,点击【按财务管理提取】,如下图:
点击保存之后,进入字段定义
4进入RSA3进行模拟提取,如下图:
事务代码:RSA6中激活数据源
到BW中找到数据源复制元数据
选中自己新建的数据源
这篇关于BW数据源创建之从函数模块+提取结构的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!