BW中的变量增强

BW的query的变量需要进行增强才能正确地满足实际需要,如query中需要查询本年年初的关键值,你必须指定到今年的000期间才行,这时候就需要用到增强功能。

要点:

1、只有放在BWquery中的自由特性的对象才能够进行即时分析。

2、由于BW的数据一般无法进行当天的数据查询,所以经常需要在当前日期上-1.

3、会计年度的值采用了一种约定:10日以前认为是查询上月的数据。当然这是在step=1时采用的。选择后的值是不一样的。

4、 l_s_range-sign     = 'I'.I代表包含在内,而E的意义相反。

      l_s_range-opt      = 'BT'. 是关系运算式。BT=between,EQ = equal,其他略。

5、文本变量的方式是采用搜索数据表来得到的。如何才能查到需要的文本值,顾问的意思是st02等跟踪工具来跟踪得到。

6、许多的变量是依附于其他的选择变量的,所以在query中一定要把你依附的变量放在其中才能采用。

     WHEN 'ZI_LNDSN'."这个变量就是依附于变量zs_calday的。

     IF i_step = 2 .

       READ TABLE i_t_var_range INTO loc_var_range

          WITH KEY vnam ='ZS_CALDAY'.

       IF sy-subrc EQ 0 .

7、主要财务的会计期间与正常的日期之间的差别。如"2008001"与“20080101”的区别。在运算中大量用到转换。

8、典型的日期变量:

     WHEN 'ZI_BNLJ12'.

     IF i_step = 2 .

       READ TABLE i_t_var_range INTO loc_var_range

          WITH KEY vnam ='ZI_FISCPERJG_NEW'.

       IF sy-subrc EQ 0 .

         CLEAR l_s_range.

         l_year = loc_var_range-high(4).

 

 

         l_s_range-high+0(4) = l_year.

         l_s_range-high+4(3) = '012'.

 

         l_s_range-low+0(4) = l_year.

         l_s_range-low+4(3) = '000'.

 

         l_s_range-sign     = 'I'.

         l_s_range-opt      = 'BT'.

         INSERT l_s_range INTO TABLE e_t_range.

       ENDIF.

     ENDIF.

9、典型的文本变量:

     WHEN 'ZT_COMPCODE'.

     IF i_step = 2.

*BREAK-POINT.

       READ TABLE i_t_var_range INTO loc_var_range

       WITH KEY vnam = 'ZH_COMPCODE'.

       IF sy-subrc EQ 0 .

         IF sy-sysid = 'DB1'.

           SELECT SINGLE txtmd INTO i_txtmd

           FROM rsthiernode

           WHERE nodename = loc_var_range-low

           AND   hieid = 'D3Z0Q0YD326Y3R99FPLZTWQ7J'

           AND   objvers = 'A'

           AND   langu = sy-langu.

           IF sy-subrc NE 0 .

             SELECT SINGLE txtmd INTO i_txtmd

             FROM /bi0/tcomp_code

             WHERE comp_code = loc_var_range-low+0(4)

                 AND langu = sy-langu.

             .

           ENDIF.

         ELSE.

           SELECT SINGLE txtmd INTO i_txtmd

                  FROM rsthiernode

                  WHERE nodename = loc_var_range-low

                  AND   hieid = 'D48Z1PEX0M4J4MTDKBKKEBPNK'

                  AND   objvers = 'A'

                  AND   langu = sy-langu.

           IF sy-subrc NE 0 .

             SELECT SINGLE txtmd INTO i_txtmd

             FROM /bi0/tcomp_code

             WHERE comp_code = loc_var_range-low+0(4)

               AND langu = sy-langu

            .

           ENDIF.

         ENDIF.

         l_s_range-low = i_txtmd.

       ENDIF.

       l_s_range-sign     = 'I'.

       l_s_range-opt      = 'EQ'.

       INSERT l_s_range INTO TABLE e_t_range.

     ENDIF.

 

 

 

 

 

The enhancement RSR00001 (BW: Enhancements for Global Variables in Reporting) is called up several times during execution of the report. Here, the parameter I_STEP specifies when the enhancement is called. 

 

I_STEP = 1 

Call takes place directly before variable entry. Can be used to pre populate selection variables 

 

I_STEP = 2 

Call takes place directly after variable entry. This step is only started up when the same variable is not input ready and could not be filled at I_STEP=1. 

 

I_STEP = 3 

In this call, you can check the values of the variables. Triggering an exception (RAISE) causes the variable screen to appear once more. Afterwards, I_STEP=2 is also called again. 

 

I_STEP = 0 

The enhancement is not called from the variable screen. The call can come from the authorization check or from the Monitor. This is where you want to put the mod for populating the authorization object.

 

 

 

 

 

 

 

 

 

变量增强实例代码说明:

 

case i_vnam.
  WHEN 'ZGMGRANT'.  "Query field name
    if i_step = 0.
      BREAK-POINT.
      clear wa_ETRANGE.

*     Gets all grants a user is able to see from ZTable,
*     which is populated elsewhere 
      select grant_nbr
        from ZGMUSERGRANTS
        into corresponding fields of table it_ZGMUSERGRANTS
       where UNAME eq sy-uname.

*     Populate Authorisation Object. In i_step 0
*     E_T_RANGE is used to populate the authorisation object
      loop at it_ZGMUSERGRANTS into wa_ZGMUSERGRANTS.
        wa_ETRANGE-sign = 'I'.
        wa_ETRANGE-opt = 'EQ'.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT         = wa_ZGMUSERGRANTS-grant_nbr
         IMPORTING
           OUTPUT        = wa_ZGMUSERGRANTS-grant_nbr.
        wa_ETRANGE-low  = wa_ZGMUSERGRANTS-grant_nbr.
        append wa_ETRANGE to E_T_RANGE.
      endloop.
    endif.
  ENDCASE.

posted @ 2012-07-18 18:59  hanmos  阅读(1791)  评论(0编辑  收藏  举报