on 05-11-2011 8:24 PM
Hi Experts,
I have created a BOL class to insert values into a ZTable.
I have created a custom component/views for the BOL. Now how will the create method in the BOL will be called. In which method of the component controller or view controller do I create the BOL root..
I want to use the following code.
CALL METHOD SUPER->WD_CREATE_CONTEXT
.
DATA:
lref_substitute TYPE REF TO if_bol_bo_property_access,
lv_index TYPE i,
lref_bol_entity TYPE REF TO cl_crm_bol_entity,
lrf_cuco TYPE REF TO cl_gs_mcat_mcat_impl,
lref_bol_core TYPE REF TO cl_crm_bol_core,
lv_object_name TYPE crmt_ext_obj_name VALUE cl_crm_catego_genil=>gc_ob_schema,
lv_create_param TYPE crmt_name_value_pair_tab,
lv_number TYPE int4 VALUE 1,
lref_new_substitute TYPE REF TO if_bol_entity_col,
lr_tx TYPE REF TO if_bol_transaction_context
.
lref_bol_core = cl_crm_bol_core=>Get_instance( abap_true ).
lv_object_name = 'ZHRUS_D2'.
TRY.
CALL METHOD lref_bol_core->root_create
EXPORTING
iv_object_name = lv_object_name
iv_create_param = lv_create_param
iv_number = lv_number
RECEIVING
rv_result = lref_new_substitute.
CATCH cx_crm_unsupported_object .
ENDTRY.
CHECK lref_new_substitute IS BOUND.
lref_substitute ?= lref_new_substitute->get_first( ).
CHECK lref_substitute IS BOUND.
me->typed_context->zhrus->collection_wrapper->clear( ).
me->typed_context->zhrus->collection_wrapper->add( iv_entity = lref_substitute ).
I give the code in various methods and it all works fine. But what is the best way to create the root node.
Regards,
Abdullah Ismail
Hi Abdullah,
I use something like this to create a root entity in the BOL Core. In this case, a standard entity: BTOrder.
*- Data dictionary
DATA lr_core TYPE REF TO cl_crm_bol_core.
DATA lr_fac TYPE REF TO cl_crm_bol_entity_factory.
DATA lt_params TYPE crmt_name_value_pair_tab.
DATA lr_ent TYPE REF TO cl_crm_bol_entity.
FIELD-SYMBOLS <line> TYPE crmt_name_value_pair.
*- Get the core instance and factory
lr_core = cl_crm_bol_core=>get_instance( ).
lr_fac = lr_core->get_entity_factory( 'BTOrder' ).
*- get supported parameters for this object
lt_params = lr_fac->get_parameter_table( ).
*- Set the process Type
READ TABLE lt_params ASSIGNING <line> WITH KEY name = 'PROCESS_TYPE'.
<line>-value = '0010'.
*- Create the BOL entity, based on parameters
lr_ent = lr_fac->create( lt_params ).
lr_ent = lr_ent->get_related_entity( 'BTOrderHeader' ).
*- Lock order
CHECK lr_ent->lock( ) = abap_true.
It is an alternative way. Check if it helps you creating your Z-Object in the BOL root
Kind regards,
Garcia
Edited by: Bruno Garcia on May 12, 2011 12:15 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Experts,
I am trying to create entity using given approach but there is no entity created.
Here is the code I am using
data:
lv_bol_core TYPE REF TO cl_crm_bol_core,
lv_call_list_factory TYPE REF TO cl_crm_bol_entity_factory,
lr_call_list_entity TYPE REF TO cl_crm_bol_entity,
lt_params_tab type crmt_name_value_pair_tab,
ls_params type crmt_name_value_pair.
lv_bol_core = cl_crm_bol_core=>get_instance( ).
lv_call_list_factory = lv_bol_core->get_entity_factory( 'ClmCallList' ).
clear: ls_params.
ls_params-name = 'ID'.
ls_params-name = ' '.
append ls_params to lt_params_tab.
clear: ls_params.
ls_params-name = 'NAME'.
ls_params-name = ' '.
append ls_params to lt_params_tab.
lr_call_list_entity = lv_call_list_factory->create( lt_params_tab ).
Do we need to pass some value? Can we not create entity without blank attributes?
Kindly advise what is wrong in above code.
Thanks and Regards,
User | Count |
---|---|
5 | |
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.