Page 1 of 1

Line 'entity ?= current' is failing [RESOLVED]

PostPosted: Fri Jan 08, 2016 4:27 am
by DrSidewalk
Guys,

We have some code in a get_i_formul method (entity ?= current) which is failing, in that the entity remains INITIAL altough current does have a value.

Code: Select all
   
DATA: current TYPE REF TO if_bol_bo_property_access.

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

  TRY.

  DATA: coll   TYPE REF TO if_bol_entity_col.
  DATA: entity TYPE REF TO cl_crm_bol_entity.
 
    entity ?= current.

.....


I'm aware there are not many details here, but in general what can be the cause of this. I ahve seen this issue before but for life of me can't work out what it can be. Bad day I think. I assume it can only be a few things that can cause this?.
What should I be checking to rectify the issue. In theory the field should be set to editable, but at the moment it remains read-on

Dr Sidewalk

Re: Line 'entity ?= current' is failing

PostPosted: Fri Jan 08, 2016 5:47 am
by Gothmog
Well, the casting will fail if current is not a ref to cl_crm_bol_entity (or one of its sub-classes).
What is current's actual type ?

Re: Line 'entity ?= current' is failing

PostPosted: Fri Jan 08, 2016 8:19 am
by DrSidewalk
Looks like the user had used the wizard to add new fields, but, the wizard had inserted new code into the INIT method, and it was this that was causing grief. Once remarked out all was then okay.