on 03-31-2015 7:04 AM
Hi Experts,
We have standard SRM webdynpro component where in we have a Table UI element about 26 columns,
Here one of the Column is a check-box. Based on the Login user this check box column should be in read only mode.
for instance if any users log-in he should have the previlage to check or uncheck the check box, But whenever an approvers sees the same page the check-box column should be in a dis-abled mode. i tried the below code... but unfortunately it is not behaving as expected.
"Get table reference
lo_table ?= view->get_element('ITEMS_TABLE').
"Get Columns of table
lt_cols = lo_table->get_columns( ).
"Check if no columns found
IF lt_cols[] IS INITIAL.
"get grouped columns list
lt_grp_cols = lo_table->get_grouped_columns( ).
"collect into columns table
LOOP AT lt_grp_cols INTO ls_grp_cols.
ls_cols ?= ls_grp_cols.
APPEND ls_cols TO lt_cols.
ENDLOOP.
ENDIF.
"For each column and its editor, set the read only property
LOOP AT lt_cols INTO ls_cols.
" get the cell editor,
lo_inp ?= ls_cols->get_table_cell_editor( ).
IF ls_cols->id = 'ITEMS_TABLE_ACPT_IND'.
IF lo_inp IS BOUND.
lv_path = lo_inp->bound__primary_property( ).
CONCATENATE lv_path 'READ_ONLY' INTO lv_path SEPARATED BY ':'.
"bind the read_only property to the attributes property
lo_inp->bind_read_only( path = lv_path ).
ENDIF.
endif.
ENDLOOP.
Hi Balajisha,
in modifyview, you bound to READ_ONLY property of attribute and it looks fine.
But you are not setting the value for READ_ONLY property of context attribute.
Refer below code:
METHOD onactionlock .
DATA lv_btn_name TYPE string.
DATA lv_lock TYPE wdy_boolean.
DATA lo_node TYPE REF TO if_wd_context_node.
DATA lt_elements TYPE wdr_context_element_set.
DATA ls_elements LIKE LINE OF lt_elements.
DATA lt_attr_names TYPE string_table.
DATA lv_attr_name LIKE LINE OF lt_attr_names.
DATA ls_data TYPE wd_this->element_data.
"get button name
wdevent->get_data(
EXPORTING name = 'ID'
IMPORTING value = lv_btn_name ).
" Prepare the locking/unlocking value based on button
CASE lv_btn_name.
WHEN 'BTN_LOCK'.
lv_lock = abap_true.
WHEN 'BTN_UNLOCK'.
lv_lock = abap_false.
WHEN OTHERS.
lv_lock = abap_false.
ENDCASE.
"=================================
" Read node data and set the read only properties of cells
"=================================
FIELD-SYMBOLS: <fs_value> TYPE any.
lo_node = wd_context->get_child_node( name = wd_this->wdctx_data ).
lt_elements = lo_node->get_elements(
).
"get the attributes list
lt_attr_names =
lo_node->get_node_info( )->get_attribute_names( ).
LOOP AT lt_elements INTO ls_elements.
ls_elements->get_static_attributes(
IMPORTING
static_attributes = ls_data
).
LOOP AT lt_attr_names INTO lv_attr_name.
UNASSIGN <fs_value>.
ASSIGN COMPONENT lv_attr_name OF STRUCTURE ls_data TO <fs_value>.
IF <fs_value> IS NOT INITIAL.
ls_elements->set_attribute_property(
EXPORTING
attribute_name = lv_attr_name
property = if_wd_context_element=>e_property-read_only
value = lv_lock
).
ENDIF.
ENDLOOP.
ENDLOOP.
ENDMETHOD.
Hope this helps you.
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rama,
I am now trying with the above mentioned sample, and i have query related to "wd_this->wdctx_data".
instead of WDCTX_DATA i have given WDCTX_ITEMS and i am getting a dump.
"
Exception 'CX_WD_CONTEXT' was raised, but it was not caught anywhere along the
call hierarchy.
"
I believe wd_this refers to the view itself and WDCTX_DATA referes to the node in the view context(DATA).
In my requirement the node(ITEMS) which is binded to the table is a sub-node of COMP_CONTEXT in that case how it should be.
Please let me know on this
Hi Balajisha,
If you are trying to get the sub node, then you use the method PATH_GET_NODE( ) and pass the path like 'COMP_CONTEXT.1.ITEMS'
Please refer the below link for more info.
Reference Path to Deeper Context Nodes - Web Dynpro for ABAP - SAP Library
Regards,
Rama
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.