on 09-14-2016 5:31 AM
Hi Team,
I have a requirement that i need to display default value say 'LOW' in dropdown when ever the button in the overview screen is clicked.
When i click that button it is triggerring Event handler.
Please guide me the code to be written in event handler to display 'LOW value in dropdown.
Please reply..
Hi Sneha,
It is very simple. You have to write code only in event handler of that button, nowhere else.
You have the header entity in the event handler. Just use get_related_entity method (or get_related_entities once or multiple time) to get that entity on which you want to set some value. Use SET_PROPERTY method to set the value (LOW). And do not forget to trigger MODIFY of CL_CRM_BOL_CORE after SET_PROPERTY.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sneha,
for exact code, you have to tell me the component and the view name where you have placed the event handler and the view and the context node which has the attribute which you need to set.
Without knowing these details, i can only provide you following snippet of code. Header of the transaction is in lr_header.
data: lr_core type ref to cl_crm_bol_core,
LR_ENTITY TYPE REF TO cl_crm_bol_entity.
* Get the BOL Core instance
lr_core = cl_Crm_bol_core=>get_instance( ).
* read entity to be updated
lr_entity = lr_header->get_related_entity( iv_relation_name = '<relation name>' ).
* Lock entity for changes
if LR_ENTITY->lock( ) = if_genil_Boolean=>true.
*Change the fields
LR_ENTITY->set_property( iv_attr_name = 'ZZRISK' iv_value = '<key for value LOW>' ).
* update core
LR_CORE->modify( ).
endif.
Hi Sagar,
Component Name: AIC_CMCR_H
Custom Controller: ZAIC_CMCR_H/ZCustom
Views
1. AIC_CMCR_H/AICCMCRHeaderEF
View controller class: Implementation Class ZL_AIC_CMCR_AICCMCRHEADER_IMPL
Context class: Implementation Class ZL_AIC_CMCR_AICCMCRHEADER_CTXT
Context nodes: BTCUSTOMERH
Implementation Class ZL_AIC_CMCR_AICCMCRHEADER_CN05
Attribute: EXT.ZZFN_AI_RISK
2. AIC_CMCR_H/AICCMCROverview
View controller class: Implementation Class ZL_AIC_CMCR_AICCMCROVERVI_IMPL
Context class: Implementation Class ZL_AIC_CMCR_AICCMCROVERVI_CTXT
Event handler: EH_ONEH_ONCLICK
There is not context nodes or attributes in overview.
Only event handler is present here.
I have done this coding in event handler.
But i am getting below dump
Entry parameter of method CL_CRM_BOL_ENTITY->SET_PROPERTY contains value ZZFN_COMPL_RISK, which is not allowed.
DATA: LR_CTX TYPE REF to CL_SRQM_RFC_BSPWDCOMPONEN_CTXT,
LR_CUCO1 TYPE REF TO CL_AIC_CMCR_BSPWDCOMPONEN_IMPL,
lr_entity1 TYPE REF TO IF_BOL_BO_PROPERTY_ACCESS,
lv_guid TYPE crmt_object_guid.
LR_CUCO1 ?= me->comp_controller.
IF LR_CUCO1 is bound.
LR_CTX = lr_cuco1->typed_context.
LR_ENTITY1 = LR_CTX->btorder->collection_wrapper->get_current( ).
lv_guid = LR_ENTITY1->get_property_as_string( IV_ATTR_NAME = 'CRM_GUID' ).
ENDIF.
LR_ENTITY1->SET_PROPERTY( IV_ATTR_NAME = 'ZZFN_COMPL_RISK'
IV_VALUE = 'L' ).
Please help by providing solution.
I guess data declaration is wrong.
May be lr_entity is of wrong data type.
But i am not getting the data type to declare for that.
try this.
DATA: LR_CTX TYPE REF to CL_SRQM_RFC_BSPWDCOMPONEN_CTXT,
LR_CUCO1 TYPE REF TO CL_AIC_CMCR_BSPWDCOMPONEN_IMPL,
lr_core type ref to cl_crm_bol_core,
LR_ENTITY TYPE REF TO cl_crm_bol_entity.
* Get the BOL Core instance
lr_core = cl_Crm_bol_core=>get_instance( ).
* read entity to be updated
LR_CUCO1 ?= me->comp_controller.
check LR_CUCO1 is bound.
LR_CTX = lr_cuco1->typed_context.
LR_ENTITY ?= LR_CTX->btorder->collection_wrapper->get_current( ).
check LR_ENTITY is bound.
lr_entity ?= lr_entity->get_related_entity( iv_relation_name = 'BTOrderHeader' ).
check LR_ENTITY is bound.
lr_entity ?= lr_entity->get_related_entity( iv_relation_name = 'BTHeaderCustExt' ).
* Lock entity for changes
check LR_ENTITY is bound.
if LR_ENTITY->lock( ) = if_genil_Boolean=>true.
*Change the fields
LR_ENTITY->set_property( iv_attr_name = 'ZZFN_COMPL_RISK' iv_value = 'L' ).
* update core
LR_CORE->modify( ).
endif.
Hi Sneha,
you can also use the GDC Attributes to access the instance in the overview method.
Below i am trying to access and set the attibutes of a service request when the one of the buttons of the overview page is clicked.
using the below sample code:
DATA: LR_GDC TYPE REF TO IF_CRM_UI_DATA_CONTEXT.
DATA: LR_SERV_REQ TYPE REF TO CL_CRM_BOL_ENTITY.
LR_STATUS_SET TYPE REF TO CL_CRM_BOL_ENTITY,
LR_STATUS_CUR TYPE REF TO CL_CRM_BOL_ENTITY.
LR_GDC = CL_CRM_UI_DATA_CONTEXT_SRV=>GET_INSTANCE( ).
IF LR_GDC IS BOUND.
LR_SERV_REQ ?= LR_GDC->GET_ENTITY( IF_ICCMP_GLOBAL_DATA_CONT_CON=>GDC_CURRENTREFBT ).
ENDIF.
IF LR_SERV_REQ IS NOT BOUND.
LR_SERV_REQ ?= LR_GDC->GET_ENTITY( IF_ICCMP_GLOBAL_DATA_CONT_CON=>GDC_CURRENTSERVICEREQUEST ).
ENDIF.
LR_ORDER_H = LR_SERV_REQ->GET_RELATED_ENTITY( IV_RELATION_NAME = 'BTOrderHeader' ).
IF LR_ORDER_H IS BOUND.
LR_ACTIVITY = LR_ORDER_H->GET_RELATED_ENTITY( IV_RELATION_NAME = 'BTHeaderActivityExt' ).
ENDIF.
you need to navigate to the correct relation of the service request in this case its status.
lr_status_set = lr_order_h->get_related_entity( 'BTHeaderStatusSet' ).
IF lr_status_set IS BOUND.
lr_status_cur = lr_status_set->get_related_entity( 'BTStatusHCurrent' ).
IF lr_status_cur IS BOUND.
lr_status_cur->get_property_as_value( EXPORTING iv_attr_name = 'ACT_STATUS'
IMPORTING ev_result = CUR_STATUS ).
here you can set the attribute value to what you want.
lr_status_cur->switch_to_change_mode( ).
lr_status_cur->set_property( EXPORTING iv_attr_name = 'ACT_STATUS'
iv_value = LS_ZCONFIG-STATUS ).
Regards
Vineet
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In the event handler read the context to which that field belongs.
Then use the method SET_PROPERTY of your entity to set "LOW".
Lets say my context is CONTEXT_A
LR_ENTITY ?= ME->TYPED_CONTEXT->CONTEXT_A->COLLECTION_WRAPPER->GET_CRRENT( ).
IF LR_ENTITY is bound.
LR_ENTITY->SET_PROPERTY
EXPORTING
IV_ATTR_NAME = "FIELD_A"
IV_VALUE = "LOW".
ENDIF.
Note: Provide the KEY of dropdown as value and not description.
Thanks
Deepak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deepak,
Thanx for your information.
But i have 2 views one header view and another Overview.
The field name which has to be set to LOW is ZZRISK.
This field present in header view ->context node->attribute->zzrisk.
But my event handler is in overview.
So when i call get property its showing an error as class is not defined.
Please guide me how to resolve it.
Hi,
My problem got resolved now. Values LOW is getting displayed when the particular field is empty.
But now i am struck with another problem.
I have done coding to display the value LOW in header view atribute but event handler is in overview.
Now Value LOW is getting filled everytime when it is initial.
But my requirement is that value should get filled only when button is clicked.
Please tell me how to find whether button is clicked or not.
Please help.
HI,
You can do as below:
1. Enhance the Custom Controller and Create same context nodes as HEADER and Overview.
2. Bind them to the HEADER and OVERVIEW views.
Now in EVENT handler of your button , first read the CUSTOM CONTROLLER:
LR_CUCO ?= me->get_custom_controller( ' Name of your custom controller' ).
if LR_CUCO is bound.
lR_ENTITY = lr_cuco->typed_context->header_view->collection_wrapper->get_current( ).
CALL METHOD LR_ENTITY->if_bol_bo_property_access~set_property
IV_ATTR_NAME = 'ZZRISK'
IV_VALUE = 'LOW'.
ENDIF.
Thanks
Hi Deepak,
Thanx for your Suggestion.
But can you please tell me in the set method of context node attribute, how to identify whether event handler is triggerrred or not .
Because event handler is triggerring after this set method execution.
I am setting the values in Set method so i need to differentiate whether button is clicked or not.
If button is clicked event handler will trigger.
So please let me know any code to be written in set method to identify button is clicked and event handler is triggered.
Thankx in advance.
You don't need to use the set method of field .
Since you have bind the nodes to custom controller , so on event handler of your button now you should have the HEADER and overview entities.(By reading from Custom controller , as mentioned in previous post).
There you read the applicable node and then set the corresponding field.
Thanks
Hi Deepak,
i have created the custom controller with name zcustom and i have binded with the header view context attributes to which i need to set the values.
i do not have any context node in overview so i have not binded.
now lr_cuco is bound.
But when i write below statement i am getting error saying, typed_context is not defined as DATA.
So i tried to declare it in the IMPL class of overview.
But it is showing that already typed_context is present.
So can you please tell me the solution for this.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.