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

Re: Mandatory field check in WebDynpro for input field with type TIMS

$
0
0

Hi everybody,

 

I found the solution myself by looking what happens in cl_wd_dynamic_tool=>check_mandatory_attr_on_view.

 

Basically, the code below does what I need. Creating an error message for the attribute 'TIME' in my context element.

 

Cheers,

Steven

 

CODE:

 

METHOD check_time .

  DATA lo_nd  TYPE REF TO if_wd_context_node.
  DATA lo_el TYPE REF TO if_wd_context_element.
  DATA lv_time TYPE TIMS.
  DATA lo_api_controller     TYPE REF TO if_wd_controller.
  DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
  DATA lv_message_id         TYPE string.
  DATA lv_message_type       TYPE i.
  DATA ls_message            TYPE symsg.


*Get the time field from context
  lo_nd = wd_context->get_child_node( name = 'NODE').
  CHECK lo_nd IS BOUND.

  lo_el = lo_nd->get_element( ).
  CHECK  lo_el IS BOUND.

  lo_el->get_attribute(
    EXPORTING  name `TIME`
    IMPORTING value = lv_time ).


*If TIME field is initial
  IF lv_time IS INITIAL.

*Get message manager
    lo_api_controller ?= wd_this->wd_get_api( ).
    lo_message_manager ?= lo_api_controller->get_message_manager( ).

* Create standard SAP message for mandatory field
    ls_message-msgty = 'E'.
    ls_message-msgid = 'WEBDYNPRO_RT'.
    ls_message-msgno = '014'.


    IF lo_message_manager IS BOUND.
      lo_message_manager->report_attribute_t100_message(
        EXPORTING
          msg                       =   ls_message
          element                   =   lo_el
          attribute_name            =   'TIME' ).

    ENDIF.
  ENDIF.
ENDMETHOD.


Viewing all articles
Browse latest Browse all 9238

Trending Articles