How To... Verify The Variable Input
How To... Verify The Variable Input
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.
This example is based on the InfoCube 0D_SD_C03 from the Demo Business Content.
3. Double-click on
EXIT_SAPLRRS0_001.
4 Appendix
*----------------------------------------------------------------------*
* INCLUDE ZXRSRU01 *
*----------------------------------------------------------------------*
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.
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.
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.
RAISE x_message.
ENDCASE.
ENDLOOP.
ENDMETHOD.