on 09-30-2008 6:25 AM
Hi All,
I am using this code to check the mandatory fields in my view.
DATA:lo_view_controller type ref to if_wd_view_controller,
msg_tab type cl_wd_dynamic_tool=>t_check_result_message_tab.
lo_view_controller = wd_this->wd_get_api( ).
cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
Exporting
view_controller = lo_view_controller
Importing
messages = msg_tab ).
Now i want to check if mandatory fields are not filled it should not do any furthur action. Please tell how can i achieve this.
Thanks in advance.
Regards Pranav
Hi,
depending on the messages in the msgtab wecan use the method of IF_WD_MESSAGE_MANAGER.
REPORT_ERROR_MESSAGE
Please check out this sample code -
Get the attribute value of the field for wihich you are validating using the GET_ATTRIBUTE method.
We can write this code in the event hanlder or modifyview
if item_carrid is not initial.
l_current_controller ?= wd_this->wd_get_api( ).
l_message_manager = l_current_controller->get_message_manager( ).
if item_carrid is initial.
l_str = 'Please Enter The Carrier Id'.
report message
l_message_manager->report_error_message(
message_text = l_str
PARAMS = PARAMS
MSG_USER_DATA = MSG_USER_DATA
view = 'MESG'
show_as_popup = 'X'
IS_PERMANENT = IS_PERMANENT
SCOPE_PERMANENT_MSG = SCOPE_PERMANENT_MSG
CONTROLLER_PERMANENT_MSG = CONTROLLER_PERMANENT_MSG
MSG_INDEX = MSG_INDEX
).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please see this code below
if MSG_TAB-T100_MESSAGE CO 'E'.
else.
DATA lo_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER .
lo_COMPONENTCONTROLLER = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->methupdate(
).
endif.
I tried the above code but it is returning an error message that since msg_tab is not a table with header line no component with name T100_MESSAGE exist.
Also i tried if msg_tab-msgty EQ 'E'. it is returning same error message.
Can you please tell what to write in IF condition.
Thanks
I have 21 fields to validate and requirement is not that big its just that if mandatory fields are not filled just display an error message and dont update data in database.
So if instead of getting all 21 attribute and thn checking for initial condition i thought if i can use this static method provided by SAP. But what it is doing is it is returning an error message but it is not stoping the data from getting updated in database.
Can you please suggest something??
Thanks.
Hi,
I have done like this -
In the View's Attributes tab I have declared the variable with TEXT as STRING.
Based on this I validated the code -
method onactionenter .
wd_this->text = 'YES'.
endmthod.
In the Modify View I have coded like this -
if wd_this->text = 'YES'.
if item_connid is initial.
item_text1 = 'Please enter value'.
" this is a attribute in the Context node
use the report_error_message
else.
item_text = ' '.
lr_text->bind_text( path = 'TEXT' ).
endif.
wd_this->text = ' '.
elem_context1->set_attribute(
value = item_text
name = 'TEXT'
).
endif.
Regards
Lekha
Hi,
Please check the notes on this -
Note 1026272 - WDA: Mandatory check on view of multiple context nodes
Note 1091460 - WDA: CHECK_MANDATORY_ATTR_ON_VIEW checks only LeadSelection
1228965
Or
This method is only returning the type of error the IMPORTING paramter (HAS_ERRORS) is of type Boolean right. We can only only the errors occured but not the exact error.
'X' == True '' == False for this WD_BOOLEAN.
IF msgtab EQ 'X'. "If error occured
IF item_carrid NE 'AA'.
use this REPORT_ERROR_MESSAGE.
ENDIF.
ELSE.
write your code here.
ENDIF.
Or
When ever the mandatory fields are not filled usually the system itself will hanlde the errors right.
Regards
Lekha
Pranav, you just have to call this method in WDDOBEFOREACTION method, with no parameters but the view controller API reference (assuming you got it previously with wd_this->wd_get_api( 😞
cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
EXPORTING
view_controller = wd_this->view_controller_api
).
This will issue a generic message for each uncompleted Required field.
If the event handler (ONACTION*) is still executing, you can stop it by adding the following code at the top of it:
DATA: lr_msg_man TYPE REF TO if_wd_message_manager.
lr_msg_man = wd_this->view_controller_api->get_message_manager( ).
CHECK lr_msg_man->is_empty( ) = abap_true.
Hope this helps.
Regards
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
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.