You are on page 1of 9

How to

Verify the Variable Input


BUSINESS INFORMATION WAREHOUSE

ASAP How to Paper

Applicable Releases: BW 2.0B, 2.1C


May 2001

SAP (SAP America, Inc. and SAP AG) assumes no responsibility for errors or omissions in these materials.
These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the
implied warranties of merchantability, fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages
that may result from the use of these materials.
SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within
these materials. SAP has no control over the information that you may access through the use of hot links contained in these
materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party
web pages.
HOW TO VERIFY THE VARIABLE INPUT

1 Business Scenario
You would like to verify the value of a single variable or the combination of variable values. In the case
of an invalid value or value combination a message should be shown to the user.

2 The Result
The variable value(s) is (are) checked in a customer exit. Every variable type (manual input, SAP-exit,
customer exit, automatic replacement) can be checked in the exit.

The customer exit for variables is called three times maximally. These three steps are called I_STEP.
The first step (I_STEP = 1) is before the processing of the variable pop-up and gets called for every
variable of the processing type customer exit. You can use this step to fill your variable with default
values.
The second step (I_STEP = 2) is called after the processing of the variable pop-up. This step is called
only for those variables that are not marked as ready for input and are set to mandatory variable
entry.
The third step (I_STEP = 3) is called after all variable processing and gets called only once and not
per variable. Here you can validate the user entries.
Please note that you cannot overwrite the user input values into a variable with this customer exit. You
can only derive values for other variables or validate the user entries.

In our scenario here we use I_STEP = 3.

2001 SAP AMERICA, INC. AND SAP AG 1


HOW TO VERIFY THE VARIABLE INPUT

3 The Step By Step Solution

This example is based on the InfoCube 0D_SD_C03 from the Demo Business Content.

1. Create an input variable. The


variable is based on the InfoObject
0CALMONTH. Set the following
attributes:
q Single value
q Ready for input
q Mandatory variable entry

2. Call Transaction CMOD for the


definition of the customer exit.
Create a new project, maintain the
short text, and assign a development
class.

Goto Enhancements Assignments


and assign RSR00001. Press the
button components to continue.

3. Double-click on
EXIT_SAPLRRS0_001.

For documentation place the cursor


on RSR00001 and use the menu Goto
-> Display documentation.

2001 SAP AMERICA, INC. AND SAP AG 2


HOW TO VERIFY THE VARIABLE INPUT

4. Then double-click on ZXRSRU01.

If the include doesnt exist you have


to create it; assign a development
class and a transport request.

5. Enter the coding (see also


Appendix). Save and activate the
coding.

Please note: You can ignore the


Warning "NO_REPLACEMENT" is
not defined as an exception in the
function module.

6. Activate the project. This is very


important.

2001 SAP AMERICA, INC. AND SAP AG 3


HOW TO VERIFY THE VARIABLE INPUT

7. Define a query. Use the variable


defined in Step 1.

8. Save your query, embed the query in


a workbook and execute the query.

9. You will get the error message and


the system jumps back to the
variable screen.

In the Web you will see the error


message on top of the screen for the
variables.

2001 SAP AMERICA, INC. AND SAP AG 4


HOW TO VERIFY THE VARIABLE INPUT

4 Appendix

*----------------------------------------------------------------------*
* INCLUDE ZXRSRU01 *
*----------------------------------------------------------------------*

DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.

IF I_STEP = 3.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'MONTH'.
IF LOC_VAR_RANGE-LOW(4) LE 1998.
CALL FUNCTION 'RRMS_MESSAGE_HANDLING'
EXPORTING
I_CLASS = 'RSBBS'
I_TYPE = 'I'
I_NUMBER = '000'
I_MSGV1 = 'Year <= 1998 not allowed'.
RAISE no_replacement.
ENDIF.
ENDLOOP.
ENDIF.

Prior to Support package 16 for BW 2.0B / 8 for 2.1C you have to replace the method
send_abap_dynpro in the class CL_RSR_QUERY_VARIABLES.

METHOD send_abap_dynpro.

DATA: l_s_zeitf TYPE rri3_s_zeitf,


l_r_var TYPE REF TO cl_rsr_single_variable,
l_subrc TYPE sy-subrc.
FIELD-SYMBOLS:
<l_sx_var> TYPE rro01_sx_var.

CALL METHOD me->_init


EXCEPTIONS
bad_value_combination = 1
x_message = 2.
CASE sy-subrc.
WHEN 0.
WHEN 1.
RAISE bad_value_combination.
WHEN 2.
RAISE screen_canceled.
ENDCASE.

CHECK p_screenflag EQ rs_c_true.

* process variables screen


DO.

CALL FUNCTION 'RRS_VARIABLES_SCREEN_CALL'


EXPORTING

2001 SAP AMERICA, INC. AND SAP AG 5


HOW TO VERIFY THE VARIABLE INPUT

i_s_rkb1d = p_s_rkb1d
i_s_zeitf = l_s_zeitf
i_th_texte = p_sx_instance-texte
CHANGING
c_sx_report = p_sx_instance-report
EXCEPTIONS
bad_value_combination = 1
screen_canceled = 2
x_message = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 0.
WHEN 1.
RAISE bad_value_combination.
WHEN 2.
RAISE screen_canceled.
WHEN 3.
RAISE x_message.
WHEN OTHERS.
CALL FUNCTION 'RRMS_X_MESSAGE'
EXPORTING
i_program = 'CL_RSR_SINGLE_VARIABLE'
i_text = 'SEND_ABAP_DYNPRO-01-'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0. RAISE x_message. ENDIF.
ENDCASE.

p_sx_instance-report-rkb1f-periv = periv_get( p_sx_instance-report ).

CALL FUNCTION 'RRS_VAR_VALUES_EXIT_AFTER'


EXPORTING
i_s_rkb1d = p_s_rkb1d
i_s_rkb1f = p_sx_instance-report-rkb1f
i_s_rkb1x = p_sx_instance-report-rkb1x
i_t_vnam_after_input = p_t_vnam_after_input
CHANGING
c_thx_var = p_sx_instance-report-var
EXCEPTIONS
no_input_given = 1 " A-message ...
x_message = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 0.
WHEN 1 OR 2.
RAISE x_message.
WHEN OTHERS.
CALL FUNCTION 'RRMS_X_MESSAGE'
EXPORTING
i_program = 'CL_RSR_SINGLE_VARIABLE'
i_text = 'SEND_ABAP_DYNPRO-02-'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0. RAISE x_message. ENDIF.
ENDCASE.

CALL FUNCTION 'RRS_VAR_VALUES_EXIT_CHECK'


EXPORTING
i_s_rkb1d = p_s_rkb1d
i_s_rkb1f = p_sx_instance-report-rkb1f
i_s_rkb1x = p_sx_instance-report-rkb1x
CHANGING

2001 SAP AMERICA, INC. AND SAP AG 6


HOW TO VERIFY THE VARIABLE INPUT

c_thx_var = p_sx_instance-report-var
EXCEPTIONS
again = 1
x_message = 2
OTHERS = 3.
l_subrc = sy-subrc.

CASE l_subrc.
WHEN 0.
EXIT.
WHEN 1.
CALL FUNCTION 'RRMS_MESSAGE_HANDLING'
EXPORTING
i_class = 'BRAIN'
i_type = 'E'
i_number = '633'.
CALL FUNCTION 'RRMS_MESSAGES_SHOW'
EXPORTING
i_handle = n_handle.
CALL FUNCTION 'RRMS_MESSAGES_DELETE'
EXPORTING
i_handle = n_handle.
WHEN 2.
RAISE x_message.
WHEN OTHERS.
CALL FUNCTION 'RRMS_X_MESSAGE'
EXPORTING
i_program = 'CL_RSR_SINGLE_VARIABLE'
i_text = 'SEND_ABAP_DYNPRO-03-'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0. RAISE x_message. ENDIF.
ENDCASE.

ENDDO.

LOOP AT p_th_variable INTO l_r_var.

READ TABLE p_sx_instance-report-var


ASSIGNING <l_sx_var>
WITH TABLE KEY vnam = l_r_var->n_sx_var-vnam.
IF sy-subrc NE 0.
CALL FUNCTION 'RRMS_X_MESSAGE'
EXPORTING
i_program = 'CL_RSR_SINGLE_VARIABLE'
i_text = 'SEND_ABAP_DYNPRO-02-'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0. RAISE x_message. ENDIF.
ENDIF.

CALL METHOD l_r_var->set_values_internal


EXPORTING
i_t_range = <l_sx_var>-range
EXCEPTIONS
invalid_hierarchy = 1
x_message = 2.
CASE sy-subrc.
WHEN 0.
WHEN 1.
RAISE bad_value_combination.
WHEN 2.

2001 SAP AMERICA, INC. AND SAP AG 7


HOW TO VERIFY THE VARIABLE INPUT

RAISE x_message.
ENDCASE.
ENDLOOP.

CALL METHOD me->submit


EXCEPTIONS
bad_value_combination = 1
x_message = 2.
CASE sy-subrc.
WHEN 0.
WHEN 1.
RAISE bad_value_combination.
WHEN 2.
RAISE x_message.
ENDCASE.

ENDMETHOD.

2001 SAP AMERICA, INC. AND SAP AG 8

You might also like