Skip to Content
avatar image
Former Member

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


  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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jun 29, 2014 at 05:27 PM


    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.



    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 30, 2014 at 04:46 AM

    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

    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


          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


            message_text = 'Provide Currecny'.




    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.



    Add comment
    10|10000 characters needed characters exceeded