Quantcast
Channel: SCN : Blog List - Web Dynpro ABAP
Viewing all articles
Browse latest Browse all 107

How to check if fields are required in ABAP

$
0
0

Hello everyone,

 

in my first post I would like to present a way to check if required fields are filled. Below you will find data declaration, that will be used:

 

   DATA: l_node TYPE REF TO if_wd_context_node,
              l_attr_list TYPE cl_wd_dynamic_tool=>t_check_mandattr_tab,
              l_attr TYPE cl_wd_dynamic_tool=>t_check_mandattr_struct,
              l_has_errors TYPE wdy_boolean.

 

Reference to node (l_node) which attributes will be checked, list of attributes (l_attr_list) and a flag (l_has_errors) to indicate if check was with errors.

 

The next step is to fill list with attribute name(s):

 

  l_attr-node_path = wd_this->wdctx_pmb_md_edit.
  l_attr-element_index = -1.
  l_attr-attribute_name = 'KTEXT'.
  APPEND l_attr TO l_attr_list.

 

*here more attributes can be filled if needed

*check for required fields

 


   l_has_errors = cl_wd_dynamic_tool=>check_mandatory_attributes(
      attribute_list   = l_attr_list
      display_messages = abap_true
      context_root     = wd_context ).

 

  IF l_has_errors EQ 'X'.
    EXIT.
  ENDIF.

 

 

 

I hope you will find it useful.

 

Best regards,

Paul


Viewing all articles
Browse latest Browse all 107

Trending Articles



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