on 05-11-2011 4:57 PM
Hi,
I have a requirement to calculate some values and display them in web ui.
I enhanced component BT_CUSTOMER_I and displayed fields which I am using for calculation and enhanced view CustomerI.
In order to calculate fields i created value attribute CALCVALUE under context node BTCUSTOMERI.
When I created the attribute CALCVALUE system automatically added methods:
GET_CALCVALUE
SET_CALCVALUE
GET_M_CALCVALUE
GET_I_CALCVALUE
I displayed the attribute in customer configuration.
In web ui I am getting exception for automatically generated code in GET_CALCVALUE
TRY.
dref = current->get_property( 'CALCVALUE' )."#EC NOTEXT
CATCH cx_sy_ref_is_initial.
RETURN.
ENDTRY.
If I comment that part everything looks fine...
Can anyone tell me where should I set value for the attribute and how to do that?
Were I should do the calculation?
I tried in view class in DO_INIT_CONTEXT but I am getting null exception...
Thank you in advance
Hi Tanja,
I answered a similar question in below thread, it should resolve your query as well:
[New field Within Contact Search Result List|]
Basically, you need to populate the fields otherwise you will get exception or it will be displayed as not bound.
As your current bol entity that is BTCustomerI does not hold that attribute - it will give exception in the GET_<attr> code.
1. Either you need to do append structure to its corresponding structure : CRMST_CUSTOMERI_BTIL, then write code anywhere such as in DO_INIT_CONTEXT or DO_PREPARE_OUTPUT
you can set value in any method of IMPL class as suitable by calling code similar to below:
lr_entity ?= typed_context->BTCUSTOMERI->collection_wrapper->get_current( ).
lr_entity->set_property( iv_attr_name = '<name>'
value = ... ).
2. OR, simpler way (but not good on performance) -- in GET method where you are getting exception - let the code remain commented - write your logic here directly to read value you want, do calculations as required and then finally write:
VALUE = lv_calculated_value.
A little better way would be do all calculations in IMPL class method, then put value in new IMPL class attribute that you can create. then in get method put value:
VALUE = owner->class_attr_name.
IF this doesn't work - create static attribute in IMPL class, populate value in DO_INIT_CONTEXT, then write code in GET method:
VALUE = classname=>attr_name.
I hope it resolves the query.
Thanks,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rohit,
Thank you very much for prompt response.
I tried already with first approach and I was getting null reference error in do_init_context methor... I also tried from event handler but somehow bol attribute had value but it wasn't displayed in web ui
I will try second approach and let you know what is the result
Kind regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Thank you all and sorry for late reply/
I implemented it in do init context metod in the way that Rohit suggested as 1 option.
The part which was giving error in get method i solved by creating a value context node and attributes in that context node didnt have error in get method.
Thanks again
User | Count |
---|---|
2 | |
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.