Hi,
Welcome, I will not take much time of yours
-------------------------------------
I have come across the scenario, where we need to check mandatory attributes of alv in Web dynpro abap.
In complex applications we may have many views with alv table data and we need to check mandatory attributes of alv tables accordingly.
We all know that,..... we can not perform the mandatory checks as we do for normal view fields by using methd CHECK_MANDATORY_ATTR_ON_VIEW of class CL_WD_DYNAMIC_TOOL,
instead, we need to use method CHECK_MANDATORY_ATTRIBUTES.
Problem:
The method CHECK_MANDATORY_ATTRIBUTES requires the attributes list, for which the mandatory check has to happen .
Oh, then
how to get the mandatory attributes from alv table by using VIEW reference?.
Then, isn't it a good idea,
if we have a method which does the trick i.e. getting alv table mandatory attribute list by using VIEW reference.
Every alv table is embedded into an internal view called VIEW_TABLE and it contains all the columns details of alv during runtime.
Now, how to reach/get reference of VIEW_TABLE element from view ?
We do get the reference of VIEW_TABLE by using recursive call of our method.
Okay, we got some idea of how we are going to get the columns of alv table using VIEW reference.
Now, its time to get into some coding part
Create a method GET_ALV_MANDATORY_ATTR as below
Parameters
GET_ALV_MANDATORY_ATTR |
---|
METHOD get_alv_mandatory_attr .
"Define Data
"Get the delegating view reference and view elements lt_children = lo_wdr_view->children.
"loop over to the view elements till the actual ALV table
"Get the view object with table entries IF ls_children-view_object->get_id( ) EQ 'VIEW_TABLE'.
lt_view_elements = lo_wdr_view->get_elements( ).
"if the element is an UI element proceed further to property
IF ( <fs_view_element>-view_element->_definition_name
lo_input_field ?= <fs_view_element>-view_element.
IF lo_input_field->get_state( ) EQ 1.
lo_wdr_component ?=
"Get external mapping details of interface controller lt_ext_mapping = lo_wdr_component->get_external_mappings( ).
CLEAR ls_attr. APPEND ls_attr TO ct_attr_list.
ENDIF. ENDLOOP.
ELSE.
get_alv_mandatory_attr(
ENDIF.
|
Note: The below statement
<fs_view_element>-view_element->_definition_name
EQ 'INPUT_FIELD'
I have given an example of check for a column editor of type input field.
You can also check for CHECKBOX, TEXT_EDIT,DROPDOWN_BY_KEY, DROPDOWN_BY_IDX, etc
Hope this blog is helpful for those looking for getting mandatory columns of ALV table in Webdynpro ABAP using VIEW reference.
I appreciate your comments/suggestions/feedback.