cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to read updated values using 'get_related_entities'

Former Member
0 Kudos

Hi Friends

I have a drop down field say 'Status1' on the WebUI screen along with a normal field say 'Status'.

When we are selecting a status value from the drop down field it should be copied to the other (normal field) field 'Status'.

This is working sometimes and not working sometimes, that means whenever we create a new transaction and save and then try to change the status by selecting the value from the drop down then the value is not getting copied however if we reset the session and come back to this screen then it is working.

I have debugged the code and found that in the method 'ON_NEW_FOCUS' we have the following code...

   DATA: lv_collection TYPE REF TO if_bol_bo_col,
        entity        TYPE REF TO cl_crm_bol_entity.

*   get collection of dependent nodes

  entity ?= focus_bo.

  TRY.

      lv_collection = entity->get_related_entities(
             iv_relation_name = 'PDPStatusRel' ).

    CATCH cx_crm_genil_model_error.
*       should never happen
      EXIT.
    CATCH cx_sy_ref_is_initial.
  ENDTRY.
  me->collection_wrapper->set_collection( lv_collection ).

We have ideally two types of status i.e., 1. Created and other is 'Released'.

When we select the 'Released' status from the drop down field then it should be copied to the other field called 'Status'.

If we check the above code 'lv_collection' sometime getting one entity which is having the status 'Created' and sometimes 2 entries with both the status.

When this is having two entries then we are able to set the status 'Released'  but it is not always having this entry.

Can you guide me why the relation 'PDPStatusRel' is not haivng the updated values ? is this a memory issue ?

Thank you.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Please try with reread entity

Former Member
0 Kudos

Hi Mani

Could you please elaborate more ?

Regards

Anil

Former Member
0 Kudos

This message was moderated.

praveen_kumar194
Active Contributor
0 Kudos

hi try to use the modify method of core class before using the get related entities method in the on new focus method.

can i know what is the transaction you are using and UI component name.

Former Member
0 Kudos

Hi Praveen

It is a custom component.

By the way can you please elaborate ?

Regards

praveen_kumar194
Active Contributor
0 Kudos

what i meant is, just call the modify method of core class.  before using the get related entities method in the on new focus method.

lr_core type ref to cl_crm_bol_core.

lr_core = cl_crm_bol_core =>get_instance( ).

lr_core->modify( ).

then call your get related entities.

       lv_collection = parent_entity->get_related_entities(

               iv_relation_name = 'PDPStatusRel' ).

Former Member
0 Kudos

Hi praveen

I have already tried MODIFY piece of coding but still

the issue presents.

Regards

Anil

Former Member
0 Kudos

Hi Anil,

I had similar kind of error, you can use cl_crm_bol_entity->save() to solve this.

It should be written after modify.

Regards,

Pratheek

Former Member
0 Kudos

Hello Anil,

               Once you have saved the bol entities then all the attributes will be set to read only mode at genil level so , you can not change the value once you click on save.I think , to change the values after save you need to handle the editability explicitly.

                You have said that some times you are getting one entry and some times two entries in lv_collection. Can you explain when it is having one entry and when two entries?

Regards,

Santosh

Former Member
0 Kudos

Hi Santosh

Thanks for responding.

If I refresh the screen and re open the transaction then I'm able to see the entries properly in the collection. If I create the record and save n then try to open the same record without refreshing then I could see only one entry in the collection i.e., 'Created' status from the above mentioned relation 'PDPStatusRel' and hence obviously we will not able to read the required status 'Released'.

Pl let me know if you need any further info.

Regards

Anil

Former Member
0 Kudos

Hello Anil,

                  It might be taking values from the buffer only .so, try to use the option bypassing buffer while getting the related entities and try.

lv_collection = entity->get_related_entities(

             iv_relation_name = 'PDPStatusRel'

             iv_mode              = bypassing_buffer).

Regards,

Santosh

Former Member
0 Kudos

HI Santosh

I have used this already however still it was not working.

Regards

Anil

Former Member
0 Kudos

Hello Anil,

                  Please clear one thing that after you have saved the transaction then the drop down field is coming as read only or editable?

Regards,

Santosh

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Santosh

These two fields are in another screen which you can see after clicking on the EDIT  button in the header screen. Once you select the value from the drop down it will immediately populates to the feild called 'Status' and then you need to press BACK button so that it will go to the main screen where we can see a field called 'Current status'. This 'Current status' field will be populated with the previous and current  values of the field 'Status' that means 'Created,Released' like below

Please check the below flow, it may gives you a clear view :

Main screen :

Click on 'Edit' button and it will take you to below screen where you can see below 2 fields


Select 'Released' now and the value should go to above field as shown below :

However having said that this is not happening always, most of the times 'Released' values is not being set to the above field instead it is 'Created' though we have selected 'Released' from drop down.

what I found was that I could see sometimes only one entry in the collection reference( the code written in ON_NEW_FOCUS  method ) and so it is not able to read the value 'Released'.

Regards

Anil

Former Member
0 Kudos

Hi Anil,

Can you tell me when your on_new_focus is getting called? Are you trying to do On_new_focus on changing of Dropdown? Excuse me if i'm wrong, but I didnt understand exactly when you expect this method to be executed in your case.

If you are trying to execute this along with drop down change, then it is wrong. This method will be called when you change focus from an entity,

Consider a simple scenario, you have 2 Context Node College and Students, Now we have a relation between these 2 entities, and College is the Higher level node.

When a College entity is Filled in College Node the Student Node should automatically be filled with the Student entities related to that college,

on_new_focus is used for this purpose,

So each time you change entity in College Node, on_new_focus will be called and Related Entities will be filled into Student.

Again Excuse me if this was not your question, Please explain your doubt in detail

Thanks and Regards,

Pratheek

Former Member
0 Kudos

Hi Pratheek

The flow is as follows :

We have method 'CREATE_STATUS' in the _CTXT class and it has the following code..

    owner->do_context_node_binding(

            iv_controller_type = cl_bsp_wd_controller=>co_type_custom

            iv_name =

            '/CFCRMX2/CM_PDPCMP/CuCoPDP'                     "#EC NOTEXT

            iv_target_node_name = 'STATUS'

            iv_node_2_bind = status ).

DATA lr_node TYPE REF TO cl_crm_bol_entity.

   lr_node ?= pdp->collection_wrapper->get_current( ).

   status->set_pdp_node( lr_node ).

* initial setting for depandant model node

   coll_wrapper =

     pdp->get_collection_wrapper( ).

   TRY.

       entity ?= coll_wrapper->get_current( ).

     CATCH cx_sy_move_cast_error.

   ENDTRY.

   IF entity IS BOUND.

     status->on_new_focus(

                  focus_bo = entity ).

   ENDIF.

so from here it will call ON_NEW_FOCUS method and this method has the following code...

parent_entity ?= focus_bo.

* get collection of dependent nodes

   TRY.

       lv_collection = parent_entity->get_related_entities(

               iv_relation_name = 'PDPStatusRel' ).

 

     CATCH cx_crm_genil_model_error.

*     should never happen

       EXIT.

     CATCH cx_sy_ref_is_initial.

   ENDTRY.

   me->collection_wrapper->set_collection( lv_collection ).

Here, 'lv_collection'  will have all the entities sometimes and not all the times.

I mean to say whenever we select the status 'Released' from drop down it should have two entries one for the status 'Created' and another for 'Released' however sometimes it is having one entry which is for 'Created' and sometimes it is having both the entries( Created & Released).

if you see the below method 'GET_TXT30' we have the code as follows

CALL METHOD cl_mkt_cpgmpl_util=>get_status_text

     EXPORTING

       ir_status_coll = collection_wrapper

     RECEIVING

       rv_status      = value.

This 'Collection_wrapper' is not getting both the status all the times and hence the result is wrong but whenever it gets the both the entries( Created & Released ) then the result is correct.

So i guess something wrong with the method 'set_collection' of ON_NEW_FOCUS method.

Pl let me know if you are not clear still. Thank you.

Regards


Former Member
0 Kudos

Hello Anil,

                 In the on_new_focus method after reading the entities using get _related _entites method if the respected entity is not found then try to create using create_relate_entities with a proper bol relation. It might solve your problem.

Regards,

Santosh

Former Member
0 Kudos

Hi Santosh

I guess we can use create_relate_entities when nothing is able to read however here we are able to see the entries when we are trying to read using 'get _related _entites'.

Please check the below..

Here we can see the status 'I1001'  i.e., 'Created' however we need one more entry 'I1004' i.e., 'Released'.

If we see the first screen shot we can see only 1 entry in the entity list however it has to be 2 entries.

These screen shots are taken in the debug after selecting the value 'Released' from drop down box.

Regards

Anil

Former Member
0 Kudos

Hi Santosh

Any clue on this ?

Regards

Anil

Former Member
0 Kudos

Hello Anil,

                Sorry for the late replay I am a bit busy in other things.The problem is at the UI level or at the genil level?Can you debug till genil and confirm the entities are coming in get_objects method or not?

Regards,

Santosh