cancel
Showing results for 
Search instead for 
Did you mean: 

lr_entity ?= lr_coll->get_next( ) is not working

Former Member

Hi,

for me lr_entity ?= lr_coll->get_next( ). is not working. When the code reaches to lr_entity ?= lr_coll->get_next( )., the lr_entity becomes initial and comes out of the while loop. Please have a look into the following piece of code. I am extracting and manupulating opportunity serach result data.

DATA: lv_page_id TYPE string,

lr_view_controller TYPE REF TO cl_bsp_wd_view_controller,

lr_cuco TYPE REF TO cl_bt111s_o_cucosearch_impl,

lr_entity TYPE REF TO cl_crm_bol_entity,

lr_coll TYPE REF TO if_bol_bo_col,

lr_collection TYPE REF TO cl_bsp_wd_collection_wrapper.

CALL METHOD server->request->get_form_data

EXPORTING

name = 'page_id'

CHANGING

data = lv_page_id.

lr_view_controller ?= cl_chtmlb_config_tab_excel_exp=>controller_get( iv_id = lv_page_id ).

lr_cuco ?= lr_view_controller->get_custom_controller( 'BT111S_OPPT/CucoSearch' ).

lr_collection ?= lr_cuco->typed_context->result->get_collection_wrapper( ).

lr_coll ?= lr_collection.

lr_entity ?= lr_coll->get_first( ).

WHILE lr_entity IS NOT INITIAL.

lr_entity->get_properties( IMPORTING es_attributes = ls_opp_btil ).

-

-

-

-

-

-

-

lr_entity ?= lr_coll->get_next( ).

ENDWHILE.

But at lr_entity ?= lr_coll->get_next( ), it is not picking the 2nd record whereas the data is available in lr_coll. Please help me!

Accepted Solutions (1)

Accepted Solutions (1)

former_member214667
Contributor

Hi Ginger,

The call to GET_FIRST() directly on a collection does not return the first entity of the collection sometimes. It might be the case for you. Using an iterator might help you here. You can get an iterator on your collection and use it to iterate as follows:


DATA lr_col_iterator TYPE REF TO if_bol_bo_col_iterator.
DATA lr_entity TYPE REF TO cl_crm_bol_entity,

lr_col_iterator ?= lr_cuco->typed_context->result->collection_wrapper->get_iterator( ).
lr_entity ?= lr_col_iterator->get_first( ).
WHILE lr_entity IS BOUND.
..
..
..
..
  lr_entity ?= lr_col_iterator->get_next( ).
ENDWHILE.

Regards,

Shiromani

Former Member
0 Kudos

Hi Shoromani,

thank u thank u thank u....sooooooooo much...it worked

Answers (0)