Vous êtes sur la page 1sur 6

RSANWB Transaction code

RSAN_WB_ROUTINE_TEMP_REPORT DATA: L_S_RANGE TYPE RSR_S_RANGESID, LOC_VAR_RANGE LIKE RRRANGEEXIT, zbuper LIKE t009b-poper, zbdatj LIKE t009b-bdatj, ZDT1 TYPE SY-DATUM, ZFDT TYPE SY-DATUM, ZLDT TYPE SY-DATUM. ********************End of Data Type Declaration************************************ ****************************************Begin*************************************** ********To get the Financial Year From and To dates based on System/Current Date**** ********************Surendra Kumar Reddy Koduru***23-10-2009************************ CASE i_vnam. WHEN 'ZC_FYFD'. IF i_step = 1. ZDT1 = SY-DATUM. CALL FUNCTION 'DATE_TO_PERIOD_CONVERT' EXPORTING I_DATE = ZDT1 * I_MONMIT = 00 I_PERIV = 'V3' IMPORTING E_BUPER = zbuper E_GJAHR = zbdatj EXCEPTIONS INPUT_FALSE = 1 T009_NOTFOUND = 2 T009B_NOTFOUND = 3 OTHERS = 4 . IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET' EXPORTING I_GJAHR = zbdatj I_PERIV = 'V3' IMPORTING E_FIRST_DAY = ZFDT E_LAST_DAY = ZLDT EXCEPTIONS INPUT_FALSE = 1 T009_NOTFOUND = 2 T009B_NOTFOUND = 3 OTHERS = 4 . IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. l_s_range-low = ZFDT. l_s_range-high = ZLDT. l_s_range-sign = 'I'. l_s_range-opt = 'BT'.

APPEND l_s_range TO e_t_range. ENDIF. ENDCASE.

SAP BW Customer Enhancement (CMOD)


When I started to 'play' around with SAP Business Warehouse (BW aka BI), I thought that I would forever leave the role as a "programmer" behind. I thought, finally, I can concentrate more on "configuration" and "designing". Well today proves that inevitably, it all boils down to good ol' hacks. You see, I want to create this report which includes a Quarter-to-date (QTD) columns. But, instead of creating a variable where the user enters which quarter the month resides in, I want to be able to use the existing 0FISCPER variable already created previously. So, what I need to do is create a customer Exit variable which will take the value of 0FISCPER variable, and find the appropriate QTD range. Unfortunately, this customer Exit, can only be created using ABAP codes, and not just a simple Formula thingy. So here's what I did:

Went into SAP enhancement screen (T-code: CMOD) and create a new project. Add the following enhancement assignment: RSR00001 (Enhancements for global variables in reporting) Adopt the existing include sample functions and start changing the include file 'ZXRSRU01'.

Here's some descriptive info on what you need to do in the function: I_VNAM: The variable name. i_t_var_range: contains all the information about the other query variables available in BW. l_s_range_low: Is the low limit value of the variable. For non-interval variable, this is the value. l_s_range_high: Is the high limit value of the variable. Make sense only for interval type variables.

l_s_range-sign: denotes whether it's 'I' inclusive, or 'E' exclusive. Again, make sense for interval type only. l_s_range-opt: what type of variable, either 'EQ' equal-type, or 'BT' between-type (interval). Another lesson that I learn in ABAP is that: some_variable = A + B not equal to: concatenate A B into some_variable In other words, string not the same as add operation. I assumed it's like Java fixed string, which is not.

project in the CMOD transaction, select the SAP enhancement RSR00001 and assign it to the enhancement project. Activate the project. 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. code for this is as follows: 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.

Please note this article has been written from an ABAPers point of view and some knowledge of creating BW queries will be required. When using an authorisation object to restrict a query report it determines if the user can see everything in a range. If they cant see them all then an authorisation error will be displayed. You may have a requirement to still allow the user to see the report but to remove values they are not authorised to see. This would be done by having 2 variables on the report selection screen, one for the user to enter their selection and a hidden one which will do the actual report restriction. The code for this will look something like this, where 'ZGMGTNOI' is the hidden field and '0S_GRANT' is the visible user input field. **** ZGMGTNOI variable derives input from variable OS_GRANT WHEN 'ZGMGTNOI'. if i_step = 2. * gets selection values entered by user (0S_GRANT) loop at I_T_VAR_RANGE into wa_range where VNAM eq '0S_GRANT' and IOBJNM eq '0GRANT_NBR'. wa_grant-low = wa_range-low. wa_grant-high = wa_range-high. wa_grant-option = wa_range-opt. wa_grant-sign = wa_range-sign. append wa_grant to r_grant. endloop. selects all grants user is authorised to see within entered selection values select grant_nbr from ZGMUSERGRANTS into corresponding fields of table it_ZGMUSERGRANTS where UNAME eq sy-uname and grant_nbr in r_grant. If no values are found! Populates hidden restriction variable with user input if sy-subrc ne 0. loop at r_grant into wa_grant.

* *

* *

* *

move-corresponding wa_grant to wa_ETRANGE. wa_ETRANGE-opt = wa_grant-option. append wa_ETRANGE to E_T_RANGE. endloop. If values are found! Populates hidden restriction variable with all values user is authorised to see else. clear: wa_range. loop at it_ZGMUSERGRANTS into wa_ZGMUSERGRANTS. wa_ETRANGE-sign = 'I'. wa_ETRANGE-opt = 'EQ'. wa_ETRANGE-low = wa_ZGMUSERGRANTS-grant_nbr. append wa_ETRANGE to E_T_RANGE. endloop. endif. endif.

http://wenku.baidu.com/view/8ddd61a1284ac850ad02421f.html

Vous aimerez peut-être aussi