on 11-30-2011 8:47 AM
Hii Team
sample code for fetching the input value from search view which is connected to btq1order contextnode
DATA : lr_qs TYPE REF TO cl_crm_bol_dquery_service,
lr_qr TYPE REF TO if_bol_bo_col,
lr_qs ?= me->typed_context->btq1order->collection_wrapper->get_current( ).
lr_qr = lr_qs->get_query_result( ).
I am new to SAP CRM .while understanding the code i got stuck in one problem that ,
1.what is the main purpose behind
TYPE CASTING ie; '?='
2.what happens if we write ?= becoz if we write '=' instead of '?=' the system thows an error.
3.when to use this operator ?= and when we cannot use ?
It is used almost every where in BOL coding .please help me by giving complete explaination with an example if possible.
Thanks in Advance
Hi Abhishek,
The main purpose of using ?= symbol is explained below.
data : lr_entity type ref to cl_crm_bol_entity,
lr_entity1 type ref to if_crm_bol_property_access.
lr_entity ?= me->typed_context->btadminh->collection_wrapper->get_current().
lr_entity1 = me->typed_context->btadminh->collection_wrapper->get_current().
If you observe both these statements lr_enity refers to a class whereas lr_enity1 refers to an interface. So if we use '?' symbol we should refer it to a class.
Hope this helps.
Regards,
Ruby.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Ruby for replying
But this idea behind using type casting is incorrect.
see this sample of code (below) which is used to clear the search criteria in the user interface.
data : qs type ref to cl_crm_bol_dquery_service.
qs = me->get_current_dquery().
if qs is bound.
data lr_adjustments type ref to crmt_regex_conversion_tab.
lr_adjustments = me->get_adjustments().
qs->clear_selection_param_values(lr_adjustments).
endif.
In the above sample code they have created object qs type ref to class but not used the ?= operator.
Regards,
Abhishek
Edited by: Abhishek Nandy on Nov 30, 2011 12:26 PM
Hi Abhishek,
Please check returning parameter type for get_current_dquery() method. In case returning type is mutually convertible then you don't have to use type casting.
But in case where you are taking results in some other type where results are compatible but with different structure then you use type casting.
best example would be cl_crm_bol_entity and if_bol_bo_property_access. Here property access is an interface to class and hence we use type casting.
Please refer to:
You can find more documentation on internet if you search for type casting.
Regards,
BJ
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.