cancel
Showing results for 
Search instead for 
Did you mean: 

Collection is empty in custom component

Former Member
0 Kudos

Hi Experts,

I created a custom BOL object and implemented a custom genil class for this. I am using this object in my custom BSP component.

Now, in the overview page i created using this custom BOL object as context node, when i give an input in one of the attributes and press enter, the value disappears. When i checked, in the get and set methods of this attribute, the collection wrapper - collection does not have any value.

  

    if iterator is bound.
      current = iterator->get_current( ).
    else.
      current = collection_wrapper->get_current( ).
    endif.

current returns empty value.

Can anyone please help me with this issue?

Regards,

Heera

Accepted Solutions (1)

Accepted Solutions (1)

sumeet_gehlot
Contributor
0 Kudos

Hi,

If you are using a custom bol objects and created a custom genil class, then first you have to laod that bol object and a component set , you can use this code in Do_init_context so that initially when you run crm_ui , it will initailizes the  component set and bol objects.

DATA : lr_entity TYPE REF TO cl_crm_bol_entity,

         lv_collection TYPE REF TO if_bol_bo_col,

         lr_comp TYPE REF TO "Name of comp_controll class".

  DATA : lr_core     TYPE REF TO cl_crm_bol_core,

         lr_fac      TYPE REF TO cl_crm_bol_entity_factory,

         lt_params   TYPE        crmt_name_value_pair_tab,

         ls_params   TYPE        crmt_name_value_pair,

         lr_ent      TYPE REF TO cl_crm_bol_entity.

  lr_comp ?= me->comp_controller.

  CHECK lr_comp IS BOUND.

  lr_entity ?= lr_comp->typed_context->"name of context node"->collection_wrapper->get_current( ).

  TRY.

      lr_core = cl_crm_bol_core=>get_instance( ).

      lr_core->start_up( ' Name of component set' ).

    CATCH cx_crm_genil_general_error.

      EXIT.

  ENDTRY.

  lr_fac = lr_core->get_entity_factory( 'Name of the root object you created' ).

  lt_params = lr_fac->get_parameter_table( ).

  TRY.

      lr_ent = lr_fac->create( lt_params ).

      IF lr_ent IS BOUND.

        me->typed_context->"name of context  node"->collection_wrapper->add( iv_entity = lr_ent ).

        CHECK lr_ent->lock( ) = abap_true.

      ENDIF.

    CATCH cx_crm_genil_model_error.

      EXIT.

    CATCH cx_sy_ref_is_initial.

  ENDTRY.

if you face any issue , pls let me know

Regards,

Sumeet

Former Member
0 Kudos

Hi Sumeet,

Can you please tell me in which class should i write this code? Is it in the window impl class, component contorller or custom controller?

regards,

heera

sumeet_gehlot
Contributor
0 Kudos

Hi Heena,

You can use this code in a view, either you create a new button "Create"  in a view and add this code.

or you can initalize in Do_init_context of that view.

Regards,

Sumeet

Answers (0)