QUERY虛擬特性與關鍵值的使用

QUERY虛擬特性與關鍵值的使用
1.Se19實現一個BADI(RSR_OLAP_BADI), ZBW_RSR_OLAP_BADI
2.操做實例:
DEFINE程序代碼以下:
method IF_EX_RSR_OLAP_BADI~DEFINE.
"BREAK-POINT.
DATA: l_s_chanm TYPE rrke_s_chanm,
       l_keyfnm  
TYPE rsd_kyfnm.
if FLT_VAL = 'ZHR_C09'. " 員工薪資情況
READTABLE I_TH_CHANM_USED TRANSPORTINGNOFIELDSWITHKEY table_line = 'ZHR_NEKH'."'0HAP_AR_TYP'.
IF sy-subrc = 0 .
"l_s_chanm-chanm = '0HAP_AR_TYP'.
   l_s_chanm-chanm =
'ZHR_NEKH' .
   l_s_chanm-
mode  = rrke_c_mode-chng_w_sel.
APPEND l_s_chanm to C_T_CHANM.
ENDIF .
elseif FLT_VAL = 'ZHR_C12'. " 員工花名冊
READTABLE I_TH_CHANM_USED TRANSPORTINGNOFIELDSWITHKEY table_line = 'ZLTEXT10'." 畢業院校
IF sy-subrc = 0 .
"l_s_chanm-chanm = '0HAP_AR_TYP'.
     l_s_chanm-chanm =
'ZLTEXT10' .
     l_s_chanm-
mode  = rrke_c_mode-chng_w_sel.
APPEND l_s_chanm to C_T_CHANM.
ENDIF .
endif .
*  READ TABLE c_t_kyfnm TRANSPORTING NO FIELDS WITH KEY table_line = 'ZMT_V02'.*
*  IF sy-subrc <> 0.
*    l_keyfnm = 'ZMT_V02'.
*    APPEND l_keyfnm to c_t_kyfnm.
*  ENDIF.
*  READ TABLE c_t_kyfnm INTO l_keyfnm TRANSPORTING NO FIELDS.
endmethod.
INITIALIZE程序代碼以下:
method IF_EX_RSR_OLAP_BADI~INITIALIZE.
"把結構字段傳輸到全局變量中。
DATA: field(30) TYPEC .
TYPES: BEGINOF TW_TH_SFK,
       KYFNM
TYPE  RSKYFNM,
       VALUE_RETURNNM
TYPE  RSALIAS,
ENDOF TW_TH_SFK.
TYPES: BEGINOF TW_TH_SFC,
         CHANM
TYPE  RSCHANM,
   SIDRETURNNM
TYPE  RSALIAS,
   KEYRETURNNM
TYPE  RSALIAS,
ENDOF TW_TH_SFC.
DATA: GW_SFK LIKELINEOF I_TH_SFK,
       GW_SFC
LIKELINEOF I_TH_SFC,
       GW_TH_SFK
TYPE TW_TH_SFK,
       GW_TH_SFC
TYPE TW_TH_SFC.
FIELD-SYMBOLS: <l_global> TYPEANYTABLE ,
                <FS>
TYPE TW_TH_SFK.
"BREAK-POINT.
 UNASSIGN <l_global>.
field = '(SAPLXRSR)GI_TH_SFK' .
ASSIGN (field) TO <l_global>.
LOOPAT I_TH_SFK INTO GW_SFK.
   GW_TH_SFK-KYFNM = GW_SFK-KYFNM.
   GW_TH_SFK-VALUE_RETURNNM = GW_SFK-VALUE_RETURNNM.
INSERT GW_TH_SFK INTOTABLE <l_global>.
ENDLOOP .
 UNASSIGN <l_global>.
field = '(SAPLXRSR)GI_TH_SFC' .
ASSIGN (field) TO <l_global>.
LOOPAT I_TH_SFC INTO GW_SFC.
*    IF GW_SFC-USER_EXIT IS NOT INITIAL.
     GW_TH_SFC-CHANM = GW_SFC-CHANM.
     GW_TH_SFC-SIDRETURNNM = GW_SFC-SIDRETURNNM.
     GW_TH_SFC-KEYRETURNNM = GW_SFC-KEYRETURNNM.
INSERT GW_TH_SFC INTOTABLE <l_global>.
*    ENDIF.
ENDLOOP .
 UNASSIGN <l_global>.
endmethod.
COMPUTE程序代碼以下
method IF_EX_RSR_OLAP_BADI~COMPUTE .
DATA: field(30) TYPEC .
TYPES: BEGINOF TW_TH_SFK,
       KYFNM
TYPE  RSKYFNM,
       VALUE_RETURNNM
TYPE  RSALIAS,
ENDOF TW_TH_SFK.
TYPES: BEGINOF TW_TH_SFC,
         CHANM
TYPE  RSCHANM,
   SIDRETURNNM
TYPE  RSALIAS,
   KEYRETURNNM
TYPE  RSALIAS,
ENDOF TW_TH_SFC.
DATA: GW_TH_SFK TYPE TW_TH_SFK,
       GW_TH_SFC
TYPE TW_TH_SFC,
       Gw_Th_RANGE
TYPE RRRANGEEXIT.
FIELD-SYMBOLS: <l_global_K> TYPEANYTABLE ,
                <l_global_C>
TYPEANYTABLE ,
                <l_RANGE_C>
TYPEANYTABLE ,
                <FS_K>
TYPEANY ,
                <FS_C_MATNR>
TYPEANY ,
                <FS_C_EMPLOYEE>
TYPEANY ,
                <FS_C_HAP_AR_TYP>
TYPEANY .
data: v_DATETO type sy-datum,
       V_0P_REPD1
type sy-datum,
       v_HAP_AR_TYP
type /BI0/OIHAP_AR_TYP.
"BREAK-POINT.
field = '(SAPLXRSR)GI_TH_SFK'. " 獲取KEY
ASSIGN (field) TO <l_global_K>.
FIELD = '(SAPLXRSR)GI_TH_SFC'. " 獲取特性
ASSIGN (field) TO <l_global_c>.
IF FLT_VAL = 'ZHR_C09' .
FIELD = '(SAPLXRSR)GI_T_RANGE'. " 獲取報表輸入的日期
ASSIGN (field) TO <l_RANGE_C>.
獲取關鍵值
*    LOOP AT <l_global_k> INTO GW_TH_SFK.
*      IF GW_TH_SFK-KYFNM = 'ZMT_V02'.
*        ASSIGN COMPONENT GW_TH_SFK-VALUE_RETURNNM OF STRUCTURE C_S_DATA TO <FS_K>.
*        EXIT.
*      ENDIF.
*    ENDLOOP.
獲取特性
LOOPAT <l_global_C> INTO GW_TH_SFC .
IF GW_TH_SFC-CHANM = '0EMPLOYEE' .
ASSIGNCOMPONENT GW_TH_SFC-SIDRETURNNM OFSTRUCTURE C_S_DATA TO <FS_C_EMPLOYEE>.
CONTINUE .
ENDIF .
" IF GW_TH_SFC-CHANM = '0HAP_AR_TYP'.
IF GW_TH_SFC-CHANM = 'ZHR_NEKH' .
ASSIGNCOMPONENT GW_TH_SFC-KEYRETURNNM OFSTRUCTURE C_S_DATA TO <FS_C_HAP_AR_TYP>.
CONTINUE .
ENDIF .
ENDLOOP .
loopat <l_RANGE_C> into Gw_Th_RANGE.
IF Gw_Th_RANGE-VNAM = '0P_REPD1' .
       V_0P_REPD1 = Gw_Th_RANGE-LOW .
clear :Gw_Th_RANGE.
CONTINUE .
ENDIF .
endloop .
IF <FS_C_EMPLOYEE> ISNOTASSIGNED .
RETURN .
ELSE .
"獲取員工最近一次考績
selectmax( DATETO ) into v_DATETO
from /bic/aZHR_O1500
where EMPLOYEE = <FS_C_EMPLOYEE>
and DATETO <= V_0P_REPD1.
selectSINGLE HAP_AR_TYP into v_HAP_AR_TYP
from /bic/aZHR_O1500
where EMPLOYEE = <FS_C_EMPLOYEE>
and DATETO = v_DATETO .
if v_HAP_AR_TYP isnotINITIAL .
       <FS_C_HAP_AR_TYP> = v_HAP_AR_TYP.
else .
       <FS_C_HAP_AR_TYP> =  
'' .」 用全角空格來代替 #
endif .
    UNASSIGN: <FS_C_EMPLOYEE>,<FS_C_HAP_AR_TYP>,<FS_K>,<l_global_C>.
ENDIF .
ENDIF .
*  IF FLT_VAL = 'ZSD_MC02'.*
*    field = '(SAPLXRSR)GI_TH_SFK'.
*    ASSIGN (field) TO <l_global_K>.*
*    FIELD = '(SAPLXRSR)GI_TH_SFC'.
*    ASSIGN (field) TO <l_global_c>.*
*    LOOP AT <l_global_k> INTO GW_TH_SFK.
*      IF GW_TH_SFK-KYFNM = 'ZMT_V02'.
*        ASSIGN COMPONENT GW_TH_SFK-VALUE_RETURNNM OF STRUCTURE C_S_DATA TO <FS_K>.
*        EXIT.
*      ENDIF.
*    ENDLOOP.*
*    LOOP AT <l_global_C> INTO GW_TH_SFC.
*      IF GW_TH_SFC-CHANM = '0SALESORG'.
*        ASSIGN COMPONENT GW_TH_SFC-SIDRETURNNM OF STRUCTURE C_S_DATA TO <FS_C_VKORG>.
*        CONTINUE.
*      ELSEIF GW_TH_SFC-CHANM = '0MATERIAL'.
*        ASSIGN COMPONENT GW_TH_SFC-SIDRETURNNM OF STRUCTURE C_S_DATA TO <FS_C_MATNR>.
*      ENDIF.
*    ENDLOOP.*
*    IF <FS_C_VKORG> IS NOT ASSIGNED or <FS_C_MATNR> IS NOT ASSIGNED or <FS_K> IS NOT ASSIGNED.
*      RETURN.
*    ELSE.
*      SELECT SINGLE A~PLND_DELRY INTO <FS_K> FROM /BI0/MMAT_PLANT AS A
*                                   INNER JOIN /BI0/SSALESORG AS B ON A~PLANT = B~SALESORG
*                                   INNER JOIN /BI0/SMATERIAL AS C ON A~MAT_PLANT = C~MATERIAL
*                   WHERE B~SID = <FS_C_VKORG>
*                     AND C~SID = <FS_C_MATNR>
*                     AND A~OBJVERS   = 'A' .*
*      UNASSIGN: <FS_C_VKORG>,<FS_C_MATNR>,<FS_K>,<l_global_K>.
*    ENDIF.*
*  ENDIF.
endmethod.
相關文章
相關標籤/搜索