on 08-18-2009 7:11 AM
Hi,
I have two select option fields(Date,Number) in a viewcontainer .
Now i need to disable one of the select-option field(Date) in the view container based on the condition.If I give Enability for the view container then both the select options will get diasbled.Is there any way to disable only Date select-option field in the view container.
Thanks in Advance.
Regards,
bala.
Hi,
I have considered one View container element for Select options and set the read only attribute.
When you use the GET_SELECTION_FIELD method of IF_WD_SELECT_OPTIONS there is an attribute for READONLY.
When you use the ADD_SELECTION_FIELD try to use the same parameter.
There is also a method UPD_SELECTION_FIELD to update the selection field settings.
DATA: LT_RANGE_TABLE TYPE REF TO DATA,
RT_RANGE_TABLE TYPE REF TO DATA,
READ_ONLY TYPE ABAP_BOOL,
TYPENAME TYPE STRING.
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_so( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
DATA lo_interfacecontroller TYPE REF TO iwci_wdr_select_options .
lo_interfacecontroller = wd_this->wd_cpifc_so( ).
DATA lv_r_helper_class TYPE REF TO if_wd_select_options.
lv_r_helper_class = lo_interfacecontroller->init_selection_screen(
).
lv_r_helper_class->SET_GLOBAL_OPTIONS(
I_DISPLAY_BTN_CANCEL = ABAP_FALSE
I_DISPLAY_BTN_CHECK = ABAP_FALSE
I_DISPLAY_BTN_RESET = ABAP_FALSE
I_DISPLAY_BTN_EXECUTE = ABAP_FALSE ).
LT_RANGE_TABLE = lv_r_helper_class->CREATE_RANGE_TABLE( I_TYPENAME = 'BEGDA' ).
* add a new field to the selection
read_only = abap_false "Enable
lv_r_helper_class->ADD_SELECTION_FIELD( I_ID = 'BEGDA' I_DESCRIPTION = 'From Date'
IT_RESULT = LT_RANGE_TABLE I_READ_ONLY = READ_ONLY )."i_no_intervals = 'X' ).
LT_RANGE_TABLE = lv_r_helper_class->CREATE_RANGE_TABLE( I_TYPENAME = 'PERNR_D' ).
* add a new field to the selection
read_only = abap_true. "Disable
lv_r_helper_class->ADD_SELECTION_FIELD( I_ID = 'PERNR_D' I_DESCRIPTION = 'Emp Id'
IT_RESULT = LT_RANGE_TABLE I_READ_ONLY = READ_ONLY ). " I_NO_INTERVALS = 'X' ).
Regards,
Lekha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Intially the select option field should be enable. Its working fine.I used the method add_selection_field only
I need to change the select-option field(Date) to disable mode when i check the checkbox.
for that in the action of check box i wrote the below code to update the select-option (i.e to disable the date field)
IF check IS NOT INITIAL.
read_only = abap_true .
wd_this->m_handler->upd_selection_field( i_id = 'EBDAT'
i_read_only = read_only ).
Endif.
But its not working, the select-option for Date field is still enable.Is the above code is correct?
Is there any other way to do this?
Thanks in Advance.
Regards ,
Bala.
Hi,
You need to use the Memory ID concept here.
When you create the Select options -
data: lv_char1 type abap_bool.
IMPORT lv_Char1 TO LV_Char1 FROM MEMORY ID 'CH_EBDAT'.
IF LV_Char11 IS NOT INITIAL.
lv_char11 = abap_FALSE.
ELSE.
lv_char1 = abap_TRUE.
ENDIF.
*Also create the range table
CALL METHOD WD_THIS->M_HANDLER->ADD_SELECTION_FIELD
EXPORTING
I_ID = 'EBDAT'
IT_RESULT = lt_range_table
I_NO_INTERVALS = ABAP_True
I_READ_ONLY = LV_CHAR1 .
When you create a checkbox Implemnet the event for that checkbox onToggle -
Inthis event, get the checkbox context attribute into lv_checkbox
DATA:
LV_CHAR1 = lv_checkbox.
EXPORT LV_CHAR1 FROM LV_CHAR1 TO MEMORY ID 'CH_EBDAT'.
In the WDDOMIODIFYVIEW-
* Get the conetx attribute for checkbox into lv_checkbox
if lv_checkbox is not initial.
CALL METHOD WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD
EXPORTING
I_ID = 'EBDAT'
RECEIVING
RT_RANGE_TABLE = lt_data.
CALL METHOD WD_THIS->M_HANDLER->upd_SELECTION_FIELD
EXPORTING
I_ID ='EBDAT'
IT_RESULT = lt_data
I_READ_ONLY = abap_false "editable
endif.
Regards,
Lekha.
Although the EXPORT to memory id would work, it seems a little extreme and harder to maintain logic wise over time (since it is somewhat hidden in the code). Why not just use a View or Component Controller attribute that you can access via WD_THIS-> or WD_COMP_CONTROLLER->. That is what is already being done with the M_HANDLER object to make it easily accessible in multiple methods.
Hi,
I think as per Thomas' reply, We need to create a context attribute of boolean type and then after we get the data from IMPORT statement then bind this to the context attribute directly.
Then we donot require the EXPORT.
In the Modifyview, we can use the GET_ATTRIBUTE method for this context attribute and pass the value to the UPD_SELECTION_FIELD.
Regards,
Lekha.
You don't have to create context attributes and use the context APIs. You can just create view or component attributes. Go to the Attributes tab, not the Context tab in the designer. You can add any variable you want there. If the data doesn't have to be bound to a UI element, this is a more efficient way of accessing and storing data than in the context. You can access these attributes in code via the WD_THIS (for a View attribute or Component Controller attribute within one of its own methods) or WD_COMP_CONTROLLER (for a component controller attribute accessed from the view).
Hi,
I just tested this solution and it is working for me....Following on Thomas's suggestion...I did the following....
I just had one select-option on my scr...but it can be done with two too...
step1:
created three attributes at component level under the attribute tab ( as suggested by Thomas )
ENABLE_PRI_SELECTOPTION type WDY_BOOLEAN
M_HANDLER type ref to IF_WD_SELECT_OPTIONS
M_WD_SELECT_OPTIONS type ref to IWCI_WDR_SELECT_OPTIONS
Note: all are with public check box checked....so that all your views can see these attributes
I created a method at componenet controller leverl: create_select_option....in this method i have following code:
DATA:
lt_range_table TYPE REF TO data,
* rt_range_table TYPE REF TO data,
read_only TYPE abap_bool,
typename TYPE string.
DATA:
lr_componentcontroller TYPE REF TO ig_componentcontroller,
l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
* create the used component
l_ref_cmp_usage = wd_this->wd_cpuse_select_options( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
* get a pointer to the interface controller of the select options
*component
wd_this->m_wd_select_options = wd_this->wd_cpifc_select_options( ).
* init the select screen
wd_this->m_handler = wd_this->m_wd_select_options->init_selection_screen( ).
* create a range table that consists of this new data element
lt_range_table = wd_this->m_handler->create_range_table(
i_typename = 'PERSNO' ).
* add a new field to the selection
wd_this->m_handler->add_selection_field(
i_id = 'PERSNO'
I_VALUE_HELP_TYPE = if_wd_value_help_handler=>CO_PREFIX_SEARCHHELP
I_VALUE_HELP_ID = 'ZHELP_WDA_PERNR'
I_NO_INTERVALS = abap_true
it_result = lt_range_table
i_read_only = wd_this->ENABLE_PRI_SELECTOPTION ). <-----pls see here how i am controlling the read only property
I assume you know this much...already....but i am just putting everything down....
step2:
in my view where i want to display the select-options....i added this code under my wddoinit method
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->ENABLE_PRI_SELECTOPTION = abap_false. <--pls see initially we want this field to be open
lo_componentcontroller->create_select_option(
).
step3:
i did not have much logic to control the select option field so i added a button which if user presses the field become disable...
under that button action method i added the following code:
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->ENABLE_PRI_SELECTOPTION = abap_true.
"<---pls see here how i am changing the global *attribute which Thomas has suggested for controlling the "read only" attibute for the select-option field....you can put this under *your "if" statement....
"this step is very important if you do not remove the field you will get the dump...since it will try to add the same field again
"which produces dump from system....
lo_componentcontroller->m_handler->REMOVE_SELECTION_SCREEN_ITEM(
i_id = 'PERSNO' ).
"now call the same method which we created at component level to create the select_options...
lo_componentcontroller->create_select_option(
).
that is all....it works great for me.....let us know if still have any questions....
Thanks...
AS...
Hi,
The reply you have given works fine. but that will work if you have one field or two fields and want to delete and recreate both. suppose i have 10 select options on the screen and i need to disable the 3rd one. problem with your approach is. when i delete the element get deleted and when i try to create it then my third element become my last element. That is from 3rd position it comes and get created at 10th position but i need to create it at 3rd position
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.