Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8332

Re: How to validate an amount field in an input form in webdynpro?

$
0
0

Hi Debo,

 

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

 

Capture.JPG

 

My layout design

Capture.JPG

 

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_attributeEXPORTING   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

Capture.JPG

2)On press of enter on input currecnt field without providing any currecny , following is the error.

 

Capture.JPG

 

Hope this helps you.

 

 

Thanks

KH


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>