BEx Query Designer中的變量及其增強【轉自 SAP BW筆記】

寫在前面的話:有人問起過我關於報表變量的內容,由於沒接觸過,當時有點懵;特轉載此文章,以備學習只用。 
 
About Variable:
1.Variable 是和InfoObject綁定的,可用於任何含有該IO的query中。
2.Variable有以下幾種類型:
  • Characteristic:用於限制Char。
  • Text:用於在報表動態顯示文本。
  • Hierarchy:用於限制Hierarchy。
  • Hieararchy Node:用於限制Hierarchy Node。
  • Formula: 可以在公式中使用變量,讓用戶輸入一個數,讀取某個Char.的屬性(例如Prduct的price屬性)等來用於計算。
Offset的應用:設置偏移量
SAP BI Content內置了很多標準變量。當其無法滿足需求時,有時僅僅需要設置下偏移量就可以滿足需求了。
例如系統已經有了當前月份的變量,通過偏移就可以獲得上N個月和下N個月的變量,無需增強。
 
定義Customer Exit Variables(BW 3.x ,BI7 類似)
客戶出口變量可以通過程序來處理變量邏輯。定義過程如下:
1.在query designer中,右鍵單擊要建立變量的characteristic,選擇New variable.
2.設置爲customer exit類型
3.進入CMOD,修改:Enhancement   Exp  RSR00001 BI: Enhancements for Global Variables in Reporting-->Function exit    EXIT_SAPLRRS0_001-->INCLUDE ZXRSRU01 。該Function Module 將在query運行時被調用多次。
3-1:調用前,系統將其他變量的當前值保存在內表 I_T_VAR_RANGE中。The table type is RRS0_T_VAR_RANGE, and row type RRS0_S_VAR_RANGE references structure RRRANGEEXIT.This structure has the following fields:

 

Field

Description

VNAM

Variable name

IOBJNM

InfoObject name

SIGN

(I)ncluding [ ] or (E)xcluding [ ]

OPT

Operators: EQ =, BT [ ], LE <=, LT <, GE >=, GT >, CP, and so on

LOW

Characteristic value

HIGH

Characteristic value of upper limit for intervals or node InfoObject for hierarchy nodes

 

 3-2:每次調用時,系統會傳遞參數值給Function Module。其中,比較重要的參數如下:

I_STEP 標識了該調用發生的時機:

  •  I_STEP = 1: Call is made directly before variable entry.
  • I_STEP = 2: Call is made directly after variable entry. This step is only _executed if the same variable is not input-ready and could not be filled for I_STEP = 1.
  • I_STEP = 3: In this call, you can check the values of the variables. When an exception (RAISE) is triggered, the variable screen appears again. I_STEP = 2 is then also called again.
  •  I_STEP = 0: The enhancement is not called from the variable screen. The call can originate from the authorization check or from the monitor.

I_VNAM標識了當前要處理的變量。

3-3:完成變量的處理之後,應將變量的值寫入E_T_RANGE

Sample Code:

DATA: L_S_RANGE TYPE RSR_S_RANGESID.
DATA: L_S_VAR_RANGE TYPE RRRANGEEXIT. 
CASE I_VNAM.  
     WHEN 'CUMMONTH'.
        IF I_STEP = 2. "after the popup
            READ TABLE I_T_VAR_RANGE INTO L_S_VAR_RANGE WITH KEY VNAM = 'MONTH'.
            IF SY-SUBRC = 0.
                    CLEAR L_S_RANGE.
                    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(4)."low value, for example, 200601
                    L_S_RANGE-LOW+4(2) = '01'.
                    L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
                    L_S_RANGE-SIGN = 'I'.
                    L_S_RANGE-OPT = 'BT'.
                   APPEND L_S_RANGE TO E_T_RANGE.
                ENDIF.
        ENDIF.
ENDCASE.
 

查看SAP Exit變量

SAP Exit變量爲我們編寫customer exit變量提供了很好的參考。
1. SE16 查看錶 RSZGLOBV 可以得到系統全部變量的列表,選擇process type=SAP Exit,即可獲得所有的SAP Exit變量列表
2. SE37 查看 RREX_VARIABLE_EXITRSVAREXIT_ * 可以找到SAP Exit變量的代碼
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章