cancel
Showing results for 
Search instead for 
Did you mean: 

iterate

Former Member
0 Kudos

Hi Experts,

I want to iterate through the Nodes from a special BOL Object, for example a special Opportunity with Object ID x.

I have a special Object with an Object ID (e.g. a Nummer of a special Opportunity) and I want to iterate through all the nodes, in that case through all the nodes of BT. From the Root-Node BTOrder through all related Entities BTQResCuHist an BTAdminH. From BTAdminH to all related entities BTHeaderAcAssignSet.... and so on.

Is there a chance to do so?

I couldn't find any Method in the classes cl_crm_bol_core, cr_crm_bol_entity, cr_crm_bol_query_service,...

Can sb help me please.

Thanks.

Sebastian

Accepted Solutions (0)

Answers (1)

Answers (1)

yevgen_trukhin
Advisor
Advisor
0 Kudos

Hello Sebastian,

Of course you should be able to do it. Get_related_entitities is returning you collections of data. IF_BOL_BO_COL interface implemented by collections have necessary methods to iterate over objects (GET_FIRST, GET_NEXT and so on)...

If you dont want the focus of collection moved, you can use iterator object to move through objects in the collection.

lr_iterator = me->typed_context->context_node->collection_wrapper->get_iterator( ).
        lr__item ?= lr_iterator->get_first( ).
        WHILE lr_item IS BOUND.
     ....

          lr_item ?= lr_iterator->get_next( ).
        ENDWHILE.

Best Regards,

Yevgen

Former Member
0 Kudos

Thank you for your answer, but what is me? the instance of the if_bol_bo_col

e.g.

lr_entity_col type ref to if_bol_bo_col

lr_entity = lr_entity_col->typed_context...

but typed_context is not an attribute or method from if_bol_bo_col so I get an error.

Do you mean with ...context_node... I have to write context_node or do I have to write the name of the context node

e.g. typed_context->BTAdminH->... because I want to create a function module where I can iterate through all Nodes from the BTOrder and I want to get all Information of the attributes. I don't want to enter the names of all context nodes, just "give me all the attributes of a component set for a special object" (importing an object id and the name of the component set). Start with the Root-Entity BTOrder and iterate through all related entities.

e.g.

data: lr_bol_core type ref to cl_crm_bol_core,

lr_query type ref to cl_crm_bol_query_service,

lr_result type ref to f_bol_entity_col,

lr_child_set type ref to if_bol_bo_col,

lr_iterator type ref to if_bol_entity_col_iterator,

lr_entity type ref to cl_crm_bol_entity,

  • Create a BOL Instance

lr_bol_core = cl_crm_bol_core=>get_instance( ).

lr_bol_core->start_up( 'BT' ).

  • Create a Runtime-Instanz of the Query-Service.

lr_query = cl_crm_bol_query_service=>get_instance( 'BTQuery1O' ).

lr_query->set_property( iv_attr_name = 'OBJECT_ID' iv_value = iv_obj_id ).

lr_result = lr_query->get_query_result( ).

  • Iterate through the result set

lr_iterator_1 = lr_result->get_iterator( ).

lr_entity = lr_iterator_1->get_first( ).

while lr_entity is bound.

"give me the attributes of the entity"

"collection of entities" = "give me all related entities of the current entity"

"iterate through the collection of entities an giv me the attributes of each entity an all related entities of each

entity"

endwhile.

Sorry but I don't get it. Can you help me.

Thanks,

Sebastian

Edited by: Sebastian Wilhelm on Sep 23, 2008 11:23 AM