on 03-16-2010 3:28 PM
Hi experts!
I'm try to reach the field quantity in one row of service order item table, the goal is fill this field and other with a button.
I can get the others fields with no problems but, the column quantity is not in the attribute structure of the component node itself in runtime mode ( i can see it in the attributes of the context node of the BOL BTAdminI from tx BSP_WD_CMPWB )
I try with the follow code
TYPES: BEGIN OF ltype_attr_struct,
quantity TYPE crmt_schedlin_quan,z
END OF ltype_attr_struct.
DATA:
lr_admini TYPE REF TO if_bol_bo_property_access,
lr_ordpro TYPE REF TO crmt_ordered_prod,
lr_cw TYPE REF TO cl_bsp_wd_collection_wrapper,
lr_col TYPE REF TO if_bol_bo_col,
lr_msg_srv TYPE REF TO cl_bsp_wd_message_service,
lr_mixed_wrapper TYPE REF TO cl_bsp_wd_2collection_wrapper,
lr_mixed_node TYPE REF TO cl_bsp_wd_mixed_node,
lr_model_node TYPE REF TO cl_crm_bol_entity,
ls_mixed_node_attr TYPE ltype_attr_struct,
lr_mixed_node_attr_ref TYPE REF TO ltype_attr_struct,
lv_quantity TYPE crmt_schedlin_quan,
lcn_btschedlin TYPE REF TO cl_bsp_wd_context_node
.
TRY.
CHECK me->is_entity_changeable( ) = abap_true.
* copy current selected item
lr_cw = get_collection_wrapper( gc_context_node_admini ).
lr_cw_items = get_collection_wrapper( gc_context_node_items ).
CHECK lr_cw IS BOUND AND lr_cw_items IS BOUND.
lr_col = lr_cw->get_marked( ).
CHECK lr_col IS BOUND.
lr_admini ?= lr_col->get_first( ).
WHILE lr_admini IS BOUND.
*** create mixed node to save additional information
CREATE OBJECT lr_mixed_node
EXPORTING
iv_struct = ls_mixed_node_attr
iv_model_node = lr_admini.
lr_mixed_node->IF_BOL_BO_PROPERTY_ACCESS~set_property_as_string( iv_attr_name = 'ORDERED_PROD'
iv_value = '320'
).
lr_mixed_node->if_bol_bo_property_access~set_property( iv_attr_name = 'QUANTITY'
iv_value = lv_quantity
).
* create collection wrapper
CREATE OBJECT lr_mixed_wrapper TYPE cl_bsp_wd_2collection_wrapper.
* set value attribute structure
CREATE DATA lr_mixed_node_attr_ref.
lr_mixed_wrapper->set_value_struct( lr_mixed_node_attr_ref ).
* set mixed node to wrapper
CALL METHOD lr_mixed_wrapper->add
EXPORTING
iv_entity = lr_mixed_node.
lr_admini ?= lr_col->get_next( ).
ENDWHILE.
but when i debugg it, the property is not reached.... in the col entity i can find the attibute in this path into lr_cw ( context node BTAdminI )
lr_cw = get_collection_wrapper( gc_context_node_admini ).
-ENTITY_LIST
-ENTITY_LIST[1]-BO
-OBJECT_MODEL
-PROPERTIES_TAB
-PROPERTIES_TAB[344]-PROPERTIES
-ATTRIBUTES
QUANTITY CRMT_SCHEDLIN_QUAN 10
Someone can tell me how to set this value ?
Best Regards
Martin Aguirre
Edited by: Martin Aguirre on Mar 16, 2010 4:28 PM
Edited by: Martin Aguirre on Mar 16, 2010 4:37 PM
Hi Martin,
You can see the quantity field under the BTAdminI context node because, a model node allows adding attributes that belongs to "Relations". Quantity comes from a BOL relation. This attribute does not belong to the BTAdminI strcture. As to your problem, you should access the quantity entity via relations. Look at the SET_QUANTITY method in the BTAdminI context node class to find out how to set item quantity.
With that away, I'm not sure what these mixed nodes are for. As far as I see, all your needs can be taken care of using bol entity types(cl_crm_bol_entiy).
Regards,
Arun Prakash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Martin,
I have a similar requirement like you that I have to set Product, Quanity and Unit in the table view BT116IT_SRVO/GenericItem of the component BT116IT_SRVO. i tried to follow the value node method for populating this table view but i am getting an error in the runtime Exception Class CX_SY_MOVE_CAST_ERROR - Source type \CLASS=CL_BSP_WD_VALUE_NODE is not compatible, for the purposes of assignment, with target type \CLASS=CL_CRM_BOL_ENTITY Method: CL_CRM_UIU_BT_ITEMEOV_CN=>GET_QUANTITY
Please let me know why u have used mixed node in ur problem instead of the value node.
Please help .
HI Aishuman
In my case the quantity is not reachable directly because is not a property for this BOL. Try to look up in the get method for quantity in the view that your try to modify for .
this is the code that works for me, maybe can help you
Best regards
METHOD eh_onit_tsb.
Added by wizard: Handler for event 'IT_TSB'
DATA:
lr_admini TYPE REF TO if_bol_bo_property_access,
lr_cw TYPE REF TO cl_bsp_wd_collection_wrapper,
lr_col TYPE REF TO if_bol_bo_col,
lr_msg_srv TYPE REF TO cl_bsp_wd_message_service,
lv_quantity TYPE crmt_schedlin_quan,
dref TYPE REF TO data,
lr_collection TYPE REF TO if_bol_bo_col,
lr_entity TYPE REF TO cl_crm_bol_entity.
TRY.
CHECK me->is_entity_changeable( ) = abap_true.
copy current selected item
lr_cw = get_collection_wrapper( gc_context_node_admini ).
CHECK lr_cw IS BOUND .
obtengo las lineas marcadas
lr_col = lr_cw->get_marked( ).
CHECK lr_col IS BOUND.
Obtengo el indice de la ultima linea marcada
lr_admini ?= lr_col->get_first( ).
WHILE lr_admini IS BOUND.
lr_admini->set_property_as_string( iv_attr_name = 'ORDERED_PROD'
iv_value = '320'
).
*get related entity BTSchedlinFirst
TRY.
lr_entity ?= lr_admini.
lr_collection = lr_entity->get_related_entities(
iv_relation_name = 'BTItemSchedlinExt' ).
lr_admini = lr_collection->get_current( ).
lr_entity ?= lr_admini.
lr_collection = lr_entity->get_related_entities(
iv_relation_name = 'BTSchedlinFirst' ).
lr_admini = lr_collection->get_current( ).
CATCH cx_sy_ref_is_initial cx_crm_genil_model_error .
ENDTRY.
get old value and dataref to appropriate type
TRY.
TRY.
dref = lr_admini->get_property( 'QUANTITY' ). "#EC NOTEXT
CATCH cx_crm_cic_parameter_error.
ENDTRY.
CATCH cx_sy_ref_is_initial cx_sy_move_cast_error
cx_crm_genil_model_error.
RETURN.
ENDTRY.
assure that attribue exists
CHECK dref IS BOUND.
lr_admini->set_property(
iv_attr_name = 'QUANTITY' "#EC NOTEXT
iv_value = 22 ).
lr_admini ?= lr_col->get_next( ).
ENDWHILE.
CALL METHOD refresh_items( ).
CATCH cx_crm_genil_model_error cx_crm_bol_meth_exec_failed
cx_crm_genil_general_error cx_sy_move_cast_error.
lr_msg_srv = me->view_manager->get_message_service( ).
CHECK lr_msg_srv IS BOUND.
lr_msg_srv->add_message( iv_msg_type = 'E'
iv_msg_id = 'CRM_UIU_BT'
iv_msg_number = '005'
iv_msg_level = '1'
iv_important_info = abap_true ).
RETURN.
ENDTRY.
ENDMETHOD.
User | Count |
---|---|
7 | |
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.