Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8445

Use of Iterator in BOL programming

$
0
0

Hi,

 

Can someone please explain where exactly the iterator is useful?

 

I've two pieces of BOL code snippets, one is with iterator and the other is without iterator.

 

 

data: lr_iterator typerefto if_bol_entity_col_iterator,

        lr_entity typerefto cl_crm_bol_entity,

        lr_result type ref to if_bol_entity_col.

 

lr_entity = lr_result->get_first( ).

 

while lr_entity isBOUND.

   lv_object_id = lr_entity->get_property_as_string( iv_attr_name = 'OBJECT_ID' ).

   lv_descr =  lr_entity->get_property_as_string( iv_attr_name = 'DESCRIPTION' ).

   write:/ cnt, lv_object_id, lv_descr.

   lr_entity = lr_result->get_next( ) .

ENDWHILE.

 

 

---------------------------------------------------------------------------------

lr_iterator = lr_result->get_iterator( ).

lr_entity = lr_iterator->get_first( ).

 

while lr_entity isbound.

   lv_object_id = lr_entity->get_property_as_string( iv_attr_name = 'OBJECT_ID' ).

   lv_descr =  lr_entity->get_property_as_string( iv_attr_name = 'DESCRIPTION' ).

   write:/ cnt, lv_object_id, lv_descr.

  lr_entity = lr_iterator->get_next( ) .

ENDWHILE.

 

Both the code will give the same result. I would like to know where the iterator would be useful.

 

Thank you.


Viewing all articles
Browse latest Browse all 8445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>