cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the value of a field belonging to a different context node in GET_I method during runtime

Former Member
0 Kudos

I want the read the value of a field,'LCSTATUS' belonging to context node 'BTADMINH' in the GET_I method of the field, 'ZZFLD000008' belonging to context node,'ZBTACTIVITYH'.

In the context node class of context node 'ZBTACTIVITYH',I have created an instance attribute,GR_OWNER type ref to context class.

I get the following error in the line - lv_act_status = Lr_entity->if_bol_bo_property_access~GET_PROPERTY_AS_STRING( 'LCSTATUS' ).

'An exception (CX_CRM_CIC_PARAMETER_ERROR) occurred Message no. TPDA430'

I have used the below code.

method GET_I_ZZFLD000008.
     DATA: current TYPE REF TO if_bol_bo_property_access,
           lv_act_status TYPE string.


     DATA:lr_entity TYPE REF TO cl_crm_bol_entity,
           lr_current TYPE REF TO if_bol_bo_property_access,
          lr_parent TYPE REF TO cl_crm_bol_entity.
        

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

CHECK gr_owner IS BOUND.
lr_entity ?= gr_owner->btadminh->collection_wrapper->get_current( ).
CHECK  lr_entity  IS BOUND.
lv_act_status = Lr_entity->if_bol_bo_property_access~GET_PROPERTY_AS_STRING( 'LCSTATUS' ). "error states that lcstatus can't be used here.



   TRY.

         IF current->is_property_readonly(
                       'ZZFLD000008' ) = abap_false. "#EC NOTEXT
           rv_disabled = 'FALSE'.
         ENDIF.

     CATCH cx_sy_ref_is_initial cx_sy_move_cast_error
           cx_crm_genil_model_error.
       RETURN.
   ENDTRY.



endmethod.

Accepted Solutions (0)

Answers (1)

Answers (1)

kutjohn
Active Participant
0 Kudos

Hi

You get parameter exception usually if the attribute name is wrong.Check if there is any problem with the attribute name. Try to get all the properties using the method get_properties.

Regards JP

Former Member
0 Kudos

Hi John,

            Attribute name is 'LCSTATUS'.Please elaborate.

Do you mean the syntax below,"Try to get all the properties using the method get_properties."

lv_act_status = Lr_entity->if_bol_bo_property_access~GET_PROPERTIES( 'LCSTATUS' ).

kutjohn
Active Participant
0 Kudos

Hi,

LCSTATUS is not an attribute of the BTADMINH structure. It is read using the relation to the status object

BTADMINH-> BTHeaderStatusSet-> BTStatusHCurrent-> ACT_STATUS.

Try reading the ACT_STATUS of object BTStatus as given below.

        data: coll   type ref to if_bol_entity_col.

       data: entity type ref to cl_crm_bol_entity,

                     lv_act_status TYPE string.

       entity ?= current.                                                               "BTADMINH entity.

       coll = entity->get_related_entities(

                iv_relation_name = 'BTHeaderStatusSet' ).    "#EC NOTEXT

       current = coll->get_current( ).

        entity ?= current.

       coll = entity->get_related_entities(

                iv_relation_name = 'BTStatusHCurrent' ).     "#EC NOTEXT

       current = coll->get_current( ).

        try.

       lv_act_status = current->if_bol_bo_property_access~GET_PROPERTY_AS_STRING(  'ACT_STATUS' ).

         catch cx_crm_cic_parameter_error.

       endtry.




Regards JP

former_member193634
Active Participant
0 Kudos

Hello,

In this kind of cases, I like to use BPATH, for it makes the code way simpler.

DATA : lv_status TYPE REF TO crm_j_status.
lv_status ?= entity->get_properties_by_bpath( `BTHeaderStatusSet/BTStatusHCurrent/@ACT_STATUS` ).


Thank you BPATH

Best regards,

Sylvain AGUETTAZ