cancel
Showing results for 
Search instead for 
Did you mean: 

AET Field Value is not being saved at first time and second time onward it's saving on the database

Former Member
0 Kudos

Hi Gurus,

I have created couple of AET fields and pulled on service request (SR) overview page. The object type is selected as CUSTOMER_H. when I create new SR, provide values on AET fields and save - transaction is saved but the AET field values are not saved.

When I edit the same transaction again and fill the AET field value and save-  transaction is saved with AET field values .

While debugging in setter method I found that the relationship 'BTHeaderCustExt' doesnot exist for the first time and second time onwards its showing the relationship. Due to which 'Current' is empty in line no 28 and hence not able to save values.

\

Has any one faced similar issue earlier and what's the way to resolved the issue?

Thanks,

Anand

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Faisal, Dharmakasi,

I followed the same steps mentioned by you but still on_new_focus is not triggered.

Regards,

Anand

dharmakasi
Active Contributor
0 Kudos

Hi Anandh,

The on_new_focus method will help you fetch the buffer using the parent node, For business transaction document BTAdminH would be the root node and the BTCustomerH is dependent on BTAdminh.

By adding code in ctxt class system will set the correct buffer data while creating instance for BTCustomerH context node class.

In you case since there is no on_new_focus method system is not creating instance for the customer h first time.

Why are you adding in BTAdminH context node class, you have added the field from customer_h context node right..

You have to add on_new_focus method for customer_h context node class. The code i have provided in my earlier post will help to retrieve customer_h data.

Apart from creating on_new_focus method in customer_h context node class, you have add below in view context class( ends with ctxt) create_btcustomerh context node.

* initial setting for depandant model node

     coll_wrapper =

       BTADMINH->get_collection_wrapper( ).

     TRY.

         entity ?= coll_wrapper->get_current( ).

       CATCH cx_sy_move_cast_error.

     ENDTRY.

     IF entity IS BOUND.

       BTCustomerH->on_new_focus(

                    focus_bo = entity ).

     ENDIF.


Best Regards,

Dharmakasi.

faisal_pc
Active Contributor
0 Kudos

Hi Anand,

Please don't add the on_new_focus to btadminh. Add to customer_h as your field is there.

Thanks,

Faisal

Answers (4)

Answers (4)

Former Member
0 Kudos

Thanks Dharmakashi and Faisal.

My issue is resolved

Previously I had added created attibutes in Context node BTAdminH and did the binding using relationship BTHeaderCustExt.Though fields were appearing on the webUI screen,I was facing the issue with saving the field values.

Now, I have created new Context node BTCustomerH as a dependent node of BTAdminH. After creation of Context node, all the methods are generated successfully. Nothing to change/enhance.

Regards,

Anand

Former Member
0 Kudos

Thanks Dharmakashi and Faisal for your input.

When I right click on method 'on_new_focus', redefine option is not present. While clicking it prompts a message 'ZL_SRQM_H_BTADMINH_CN ON_NEW_FOCUS does not exist'.

I created a method 'on_new_focus' on CN class and put above code but its not triggering while debug.


I think its not generated properly (showing diamond icon).

Regards,

Anand

faisal_pc
Active Contributor
0 Kudos

Hi Anand,

Was this context node added by you manually in this view?. If on_new_focus is not available, you can create a method on_new_focus and set the following parameter. Then it will trigger.

Thanks,

Faisal

dharmakasi
Active Contributor
0 Kudos

Hi Anand,

Yes, The on new focus method did not create properly. You have added on_new_focus method directly in context node class. You have to add the properties for the method as shown in below screen capture.

Best Regards,
Dharmakasi.

faisal_pc
Active Contributor
0 Kudos

Hi Anand,

I had faced the same problem while creating an AET field for accounts in address part. The problem was, I created the field with object HEADER as there was none for address. If I keep the field in address part, I had the same issue as yours. But if I move it to the account header part, it would work fine.

So in your case, you can either create the relationship in on_new_focus as suggested by Dharmakasi or move the field to a different part and see.

Thanks,

Faisal

dharmakasi
Active Contributor
0 Kudos

Hi Anand,

Can you check ON_NEW_FOCUS method has any code in your details view. Please add below code and try adding below code in on_new_focus method in context node class

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 = 'BTHeaderCustExt' ).

         IF lv_collection IS NOT BOUND or lv_collection->size( ) = 0.

           IF entity->is_changeable( ) = ABAP_TRUE.

             TRY.

                 entity = entity->create_related_entity(

                  iv_relation_name = 'BTHeaderCustExt' ).

               CATCH cx_crm_genil_model_error cx_crm_genil_duplicate_rel.

*               should never happen

             ENDTRY.

             IF entity IS BOUND.

               CREATE OBJECT lv_collection TYPE cl_crm_bol_bo_col.

               lv_collection->add( entity ).

             ENDIF.

           ENDIF.

         ENDIF.

       CATCH cx_crm_genil_model_error.

*       should never happen

         EXIT.

       CATCH cx_sy_ref_is_initial.

     ENDTRY.

     me->set_collection( lv_collection ).



Best Regards,

Dharmakasi.