on 03-27-2015 3:27 PM
this code write onaction method
* get message manager
data lo_api_controller type ref to if_wd_controller.
data lo_message_manager type ref to if_wd_message_manager.
DATA: it_emp_gt1 TYPE TABLE OF YTMS_GT_EMP_DETA,
wa_emp_gt1 TYPE YTMS_GT_EMP_DETA.
DATA: it_emp_gt2 TYPE TABLE OF YTMS_GT_EMP_DETA,
wa_emp_gt2 TYPE YTMS_GT_EMP_DETA.
DATA lv_value TYPE string.
lo_api_controller ?= wd_This->Wd_Get_Api( ).
it_emp_gt1 = lt_emp_group_travel.
SORT it_emp_gt1 by emp_id.
it_emp_gt2 = it_emp_gt1.
LOOP AT it_emp_gt1 INTO wa_emp_gt1.
lv_value = sy-tabix.
lv_value = lv_value + 1.
READ TABLE it_emp_gt2 INTO wa_emp_gt2 INDEX lv_value.
if sy-subrc = 0.
if wa_emp_gt1-emp_id = wa_emp_gt2-emp_id.
*
CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = lo_message_manager
.
* report message
CALL METHOD lo_message_manager->RAISE_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = 'Duplicate Employee Number are not allowed'.
CLEAR : wa_emp_gt2,wa_emp_gt1.
ENDIF.
endif.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
To achieve your requirement proceed as below
Sample: write this in wddobeforeaction( ) method
DATA lo_api_controller TYPE REF TO if_wd_view_controller.
DATA lo_action TYPE REF TO if_wd_action.
lo_api_controller = wd_this->wd_get_api( ).
lo_action = lo_api_controller->get_current_action( ).
IF lo_action IS BOUND.
CASE lo_action->name.
WHEN 'ON_ENTER' OR 'SAVE'.
"Here read your table entries and check if any duplicate entries in table
" if duplicates found, then raise error message using method report
lo_message_manager = wd_this->wd_get_api( )->get_message_manager( ).
" report message
CALL METHOD lo_message_manager->report_attribute_error_message
EXPORTING
message_text = 'Duplicate entries are not allowed'
element = lo_element
attribute_name = 'PERNR'. " Attribute Name
ENDCASE.
ENDIF.
Hope this helps you.
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
1. It is always better to handle your validation in WDDOBEFOREACTION method.
2. Now get your Employee ID(lv_empid) from your context.
3.Now check whether the lv_empid exist in your table ZTABLE_EMP. Follow the below query.
Select single EMP_ID
into lv_compare_emp_id
from ZTABLE_EMP
where EMP_ID = lv_empid.
4. Now if your sy-subrc fails, write an error message.
Try it out.
BR,
RAM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.