SAP BW/4HANA 听课笔记
BW/4HANA听课笔记
1.本地SQL,BW/4HANA对象和HANA VIEW互相访问;
2.高级分析功能数据分析预测;
3.InfoOjbect:Characteristics(维度),Key figures(度量)
Characteristics支持时间,层级,多语言支持;
Key figures不可累积库存,金额单位的度量;
aDSO:高级存储物件;
创建类似数据库表。构建模型。
没有复杂结构,星形结构。
CompositeProviders:虚拟混合数据集市
做数据union,join
Analytic queries:报表层面
filter,
calculation
Data Source
ROOSOURCE表,数据源信息。
ABR类型识别删除增量;
ADD类型支持聚合数据源;
AIE类型after image, FI-AR/AR多用这种数据源表;
RODELTAM表详细说明各种类型特征表;
ERP系统T-Code:
RSA1 BW Admin Console
RSO2 Maintain DataSource(ERP CRM BW)
RSA6 DataSource Hierarchy(ERP CRM BW)
RSPC BW Process Chain
CMOD BW Query Enhancement
RSRT BW Query Monitor
RSA5 - 激活数据源
RSA6 - 查看已经激活的数据源
RSA3 - 检查抽取器是否可以正常抽数
RSA2 - 查看标准数据源
RSO2 - 开发数据源
LBWE - 激活后勤数据源、设置collective run作业、数据更新方式
LBWG - 删除后勤数据源Setup Table数据
SBIW - 填充后勤数据源Setup
BW4创建数据源
BW4后不能在GUI使用Tcode新建数据源。需要使用BWT在Eclipse或HANA Studio创建数据源。
选择Source System->右键New DataSource。
选择Copy DataSource或者配置Data Source。
选择数据库表创建数据源。
设置数据源名字,描述信息,点击Finish。
保存激活数据源。
根据数据源创建ADSO
设置Data Tiering Properties,划分数据热冷区。
数据字段,数据分区。
添加一个Filed,FLAG_SEATS CHAR 1。
选择ADSO,右键创建Transformation。
通过End Routine设置FLAG_SEATS值
编写HANA Script:
outTab = SELECT
CARRID,
CONNID,
FLDATE,
RECORDMODE ,
CASE WHEN SEATSOCC > 130 THEN 'X' ELSE '' END AS FLAG_SEATS,
PRICE,
CURRENCY,
PLANETYPE,
SEATSMAX,
SEATSOCC,
PAYMENTSUM,
SEATSMAX_B,
SEATSOCC_B,
SEATSMAX_F,
SEATSOCC_F,
RECORD,
SQL__PROCEDURE__SOURCE__RECORD
FROM :inTab;
选择ADSO,右键创建DTP
设置DTP,Background Processing 并行执行数量。
Excute in Background,BW Cockpit看到Request;
Simulate in Dialog,这个不会有Request;
选择Request,激活。
选择ADSO,查看数据
修改Partition,点击链接Remodeling
执行更新冷热分区。
创建本地文件数据源
选择None类型
设置DataSource名字,描述信息。
创建数据源增强
原始方式创建数据源:
Tcode:RSO2创建数据源
自动创建ExtractStruct:ZOXB000191,
指定Selection,Hide field。
Tcode:RSA6增强结构
创建字段Flag
Tcode:RSA3,输入DataSource名,点击执行。
点击ALV GRID,查看抓取数据。
Tcode:CMOD
设置attributes,创建enhancement
Enhancement:RSAP0001
这种方式只能一个Project中。
方式2:BADI
创建BAdI实现,RSU5_SAPI_BADI.
实现名:ZTDS_SFLIGHT_BADI
点击激活,实现Interface类:ZCL_IM_TDS_SFLIGHT_BADI
DATA_TRANSFORM 用于一般数据的增强(事务数据,主数据和文本)
HIER_TRANSFORM 用于层次数据的增强
新建method,参数和方法data_transform一致,少了I_DATASOURCE
method M_SFLIGHT. FIELD-SYMBOLS:<fs_source> TYPE ZOXB000191. DATA:lv_rate TYPE P DECIMALS 2. LOOP AT C_T_DATA ASSIGNING <fs_source>. lv_rate = <fs_source>-seatsocc / <fs_source>-seatsmax. IF lv_rate > '0.5'. <fs_source>-flag = 'X'. ENDIF. ENDLOOP. endmethod.
data transform方法中调用根据数据源调用method:
DATA: LV_METHOD TYPE SEOCMPNAME. * check if any data is extracted CHECK C_T_DATA IS NOT INITIAL. * get method name for datasource * add one character as methods can't start with a number IF I_DATASOURCE = 'ZTDS_SFLIGHT'. CONCATENATE 'M_' 'SFLIGHT' INTO LV_METHOD. ENDIF. * check whether method exist SELECT SINGLE CMPNAME INTO LV_METHOD FROM SEOCOMPO WHERE CLSNAME = 'ZCL_IM_TDS_SFLIGHT_BADI' AND CMPNAME = LV_METHOD. CHECK SY-SUBRC EQ 0. * check method is implemented CALL METHOD (LV_METHOD) EXPORTING I_UPDMODE = I_UPDMODE I_T_SELECT = I_T_SELECT I_T_FIELDS = I_T_FIELDS CHANGING C_T_DATA = C_T_DATA C_T_MESSAGES = C_T_MESSAGES.
再次Tcode:RSA3,抓取数据,调用增强赋值Flag
创建DataSource
Tcode:RSO2
方式1:
Application Component:Datasource的所在层级结构;
Extraction fromView:数据来源数据库中表,View;
方式2:
也可以使用Function Module,需要創建Extrac. Struct.。
點擊Extraction by FM
創建對應data source結構的Sturcture;
創建獲取數據的Function Module;
參考Function:RSAX_BIW_GET_DATA_SIMPLE;
選擇copy參考Function;
E_T_DATA是Function最終返回結果表,需要我們修改為自己需要返回的數據結構。
Copy對應代碼,修改E_T_DATA返回的數據。
修改點1:Tables:SFLIGHT,修改我們需要查詢數據表,這裡我們不變
修改點2:修改我們需要的作為Selection的欄位,這裡我們不變,就查SFLIGHT;
RANGES: L_R_CARRID FOR SFLIGHT-CARRID, L_R_CONNID FOR SFLIGHT-CONNID.
修改點3:將I_DSOURCE,WHEN條件,換成我們的DATASOUCE名字,然後注釋掉Other條件下代碼,我們創建DataSource為ZTOM_DS,修改為這個;
CASE I_DSOURCE. WHEN 'ZTOM_DS'.
修改點4:循環創建Selection條件;
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CARRID'. MOVE-CORRESPONDING L_S_SELECT TO L_R_CARRID. APPEND L_R_CARRID. ENDLOOP.
修改點5:將我們修改的條件加入查詢;
OPEN CURSOR WITH HOLD S_CURSOR FOR SELECT (S_S_IF-T_FIELDS) FROM SFLIGHT WHERE CARRID IN L_R_CARRID AND CONNID IN L_R_CONNID.
Function源碼:
FUNCTION RSAX_BIW_GET_DATA_SIMPLE. *"---------------------------------------------------------------------- *"*"Lokale Schnittstelle: *" 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 SFLIGHT OPTIONAL *" EXCEPTIONS *" NO_MORE_DATA *" ERROR_PASSED_TO_MESS_HANDLER *"---------------------------------------------------------------------- * Example: DataSource for table SFLIGHT TABLES: SFLIGHT. * 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: L_R_CARRID FOR SFLIGHT-CARRID, L_R_CONNID FOR SFLIGHT-CONNID. * 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 '0SAPI_SFLIGHT_SIMPLE'. 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. 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 = 'CARRID'. MOVE-CORRESPONDING L_S_SELECT TO L_R_CARRID. APPEND L_R_CARRID. ENDLOOP. LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CONNID'. MOVE-CORRESPONDING L_S_SELECT TO L_R_CONNID. APPEND L_R_CONNID. 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 SFLIGHT WHERE CARRID IN L_R_CARRID AND CONNID IN L_R_CONNID. 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. "Initialization mode or data extraction ? ENDFUNCTION.
點擊保存,選擇我們需要作為Selection的欄位;
Tcode:RSA6,這裡可以看到我們選擇的作為Selection的欄位,但是只有CARRID,CONNID有效;
點擊Extraction,可以看到結果ALV Grid;
创建Composite Provider
右键->New->CompositeProvider
创建Query
Customer Exit方式创建Variable
Tcode:SE18,
BADI增强Variable
RSROA_VARIABLES_EXIT
右键创建Implementations。ZCL_VAR_CALLAST6YEAR,描述
点击激活
创建Filter,监控OCALYEAR这个Character。
双击查看我们创建的Implementations.
实现ZCL_VAR_CALLAST6YEAR的process方法。
示例代码:
DATA:ls_range LIKE LINE OF c_t_range. DATA:ls_var_range LIKE LINE OF i_t_var_range. IF i_step = 2. CASE i_vnam. WHEN 'ZV_LAST6YEAR'. CLEAR ls_range. READ TABLE i_t_var_range INTO ls_var_range WITH KEY vnam = 'ZV_YEAR'. IF sy-subrc = 0. ls_range-high = ls_var_range-low. ls_range-low = ls_var_range-low - 6. ls_range-sign = 'I'. ls_range-opt = 'BT'. APPEND ls_range TO c_t_range. ENDIF. WHEN OTHERS. ENDCASE. ENDIF.
Offset方式,创建Selection
右键->Change Offset Value。
Tcode:RSRT,执行Query查看效果。
Query权限控制
创建分析权限
User Roles:
https://help.sap.com/viewer/107a6e8a38b74ede94c833ca3b7b6f51/2.0.9/en-US/4c6a9fd7a53f08c0e10000000a42189c.html?q=User%20Role
Tcode:RSECADMIN,创建分析权限。Ind. Maint.创建权限。
创建权限。
1.生成标准权限对象;
2.添加新的COUNTRY;
3.Intervals点击添加筛选权限值;
设定完成保存,然后Activate Authorization。
Role权限设置:
S_RS_ADSO:设置ADSO权限;
S_RS_AUTH:设置分析权限;
S_RS_COMP:设置Infocube,设置query;
插入ZAUCOUNTRY。
查看Query
Tcode:RSRT
New of SAPHANA2.0
SDA:smart data access,远程访问数据
SDI:数据抽取到BW,实时,分批。
SLT:数据传输,实时,分批。DS:抽取本地活页夹文件。
显示SQL Visualize Plan
数据大表提升效能:创建分区,超过billion数据。使用常用where条件列作为分区条件。
Calculation View:Static Cache.
将部分数据临时存储到Cache中。
计算引擎:HEX引擎替换:JOIN,OLAP;
ESX引擎替换:ROW;
DTO
DTO :Data Tiering Technology
数据冷热:‘Hot’:In-memory Store;‘Warm’:reduce In-memory Store,‘Cold’:Disk;
Object Level:按照表划分;
Partition Level:按照不同数据部分;
Tcode: RSOADSODTO
选择Temperature设置温度,Execute
点击Execute
Housekeeping
Housekeeping:清除不需要数据。
RSBATCH生成的数据,表RSBATCHDATA*等。
Process chain log数据
BALDAT,DBTABLOG,等表数据。
Tcode:RSDDSTAT
清除Log记录:
Report:RSPC_LOG_DELETE
Tcode:SLG2
SM58:清理RFC等执行Log;
Report:RSPM_NEW_ERRORLOG_DELETE
Processing Chain
全量更新,先删除在load数据;
增量更新,可以识别删除数据操作;
BW4 SP04开始支持Data flow “generate process chain automatically”
You can find all the API function modules for process chain in function group RSPC_API:
Tcode:RSPC,Process Chain
混合建模路径
HANA View ->Open ODS View->Composite Provider
数据落地到BW
Composite Provider->ADSO
本文来自博客园,作者:渔歌晚唱,转载请注明原文链接:https://www.cnblogs.com/tangToms/p/17008550.html