on 06-29-2014 5:36 PM
Hi,
By default it is taking 0.00 when I make it blank .so in the if....else condition it also taking 0.00 when the user leave it blank .So how to validate the field before submit.
Hi Debo,
FYI,
As of Release 7.0, EhP2, the use of data type CURR is no longer recommended. For currencies, use one of the data types fordecimal floating point numbers instead. The correct currency formatting is supported on screens by output styles and in ABAP programs by appropriate formatting for the MONETARYand EXTENDED_MONETARY options. This always records amounts in the main unit of the currency, unlike the data type CURR (or DEC, or the ABAP type p).
So for your currency field you can use attribute of type : decfloat34
PFB the validation example in my test component
My layout design
OnEnter( ) action, I've written following code.
METHOD onactiontet .
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_curr TYPE wd_this->element_context-curr.
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute( EXPORTING name = `CURR` IMPORTING value = lv_curr ).
IF lv_curr IS INITIAL.
* report message
CALL METHOD lo_message_manager->raise_error_message
EXPORTING
message_text = 'Provide Currecny'.
ENDIF.
ENDMETHOD.
Output:
1)My initial screen is as follows
2)On press of enter on input currecnt field without providing any currecny , following is the error.
Hope this helps you.
Thanks
KH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
By default, amount type will be 0. Just read that attribute using get_attribute( ) method and check if it is initial. if lv_amount is initial.
Or, After reading, are you assigning it to a local variable of type string.? Use the same amount type and check if it is initial or not.
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.