cancel
Showing results for 
Search instead for 
Did you mean: 

unable to lock btorder entity with quote opened in display mode

Former Member
0 Kudos

Hi,

I have a scenario where when a button is clicked on Quote header page, it will direct to a non sap page where user will add configuration details and click on SEND TO QUOTE button. Once this button is clicked, those config details should be updated as line items in Quote

I have written RFC to update the line items in Quote.

Now the problem here is when config details are added, it is not updating the line items ( P.S this scenario used to work before few days now it suddenly stopped working). When i debugged, i see that btorder entiy is not being locked and when i am trying to create

      lr_create ?= lr_btitems->create_related_entity( iv_relation_name = 'BTOrderItemAll' ).

it returns initial and unable to update line items.

         lr_bol_core = cl_crm_bol_core=>get_instance( ).

        TRY .

            CALL METHOD lr_bol_core->load_component_set(

              EXPORTING

                iv_component_set_name = 'ONEORDER' ).

          CATCH cx_crm_genil_general_error cx_sy_ref_is_initial.

        ENDTRY.

        lr_dquery = cl_crm_bol_dquery_service=>get_instance( iv_query_name =  'BTQ1Order' ).

        IF lr_dquery IS BOUND.

          lr_dquery->add_selection_param( iv_attr_name = 'OBJECT_ID'

                                          iv_sign      = 'I'

                                          iv_option    = 'EQ'

                                          iv_low       = v_trans_id ).

          lr_result ?= lr_dquery->get_query_result( ).

          IF lr_result IS BOUND.

            lr_pr_entity ?= lr_result->if_bol_bo_col~get_current( ).

            lr_btorder ?= lr_pr_entity->get_related_entity( iv_relation_name = 'BTADVS1Ord' ).

            CHECK lr_btorder->is_locked( ) EQ abap_false.

            lr_btorder->switch_to_change_mode( ).

            lr_btorder->lock( ).

            IF lr_btorder->lock( ) EQ abap_true.

            IF lr_btorder IS BOUND.

              lr_btadminh ?= lr_btorder->get_related_entity( iv_relation_name = 'BTOrderHeader' ).

  IF lr_btadminh IS BOUND.

                lr_btitems ?= lr_btadminh->get_related_entity( iv_relation_name = 'BTHeaderItemsExt' ).

                IF lr_btitems IS BOUND.

*                  lr_btitems->lock( ).

                  lr_btitems_all ?= lr_btitems->get_related_entities( iv_relation_name = 'BTOrderItemAll' ).

                  IF lr_btitems_all IS BOUND.

                    lr_btitems1 ?= lr_btitems_all->get_first( )." IF lr_btitems->lock( ) EQ abap_true .

                    IF lr_btitems1 IS NOT BOUND.

                      lr_create ?= lr_btitems->create_related_entity( iv_relation_name = 'BTOrderItemAll' ).

when i manually execute the same fm (without opening quote in webui) giving the quote id and config details in variant, line item details are being updated.

Please let me know why the entity is not getting locked though the quote is in display mode.

Thanks in advance,

Regards,

Prathyusha VJ.

Accepted Solutions (0)

Answers (2)

Answers (2)

deepika_chandrasekar
Active Contributor
0 Kudos

Hi,

Dont lock BTOrder try to lock BTAdminh entity

Dont lock two times below one line is enough to lock the entity.

  IF lr_btadminh->lock( ) EQ abap_true.

  Endif.

Regards,

Deepika.

former_member190077
Participant
0 Kudos

HI Deepika,

Thanks for yoy response,

I'll explain a little of my background, I'm in component / vista: "IUICMD / DetailAccount"

This opens after performing a search for contract account:

I wanted to change some custom data fields to place, but the only fastened to change them I have found is in the method

*********************

Method  DO_PREPARE_OUTPUT.

.

.

.

DATA: lr_ent         TYPE REF TO cl_crm_bol_entity.

lr_ent ?= me->Typed_Context->detail->collection_wrapper->get_current( ).

lr_ent->switch_to_change_mode( ).

      lr_ent->set_property( iv_attr_name = 'ZZFLD000011'

                                iv_value = 'H10' ).

******************************

But after modifying the field, I can not find how to change the view to readonly, Fields are enabled.

You could tell me the best way to return the readonly view again in the same method?

Thank you very much for the help ....

Best regards,

deepika_chandrasekar
Active Contributor
0 Kudos

Hi,

Did you try below code.

lr_tx type ref to IF_BOL_TRANSACTION_CONTEXT.

lr_tr ?= lr_byadminh->get_transaction( ).
Lr_tr->commit( ).

lr_tr->save( ).

Regards,

Deepika.

former_member190077
Participant
0 Kudos

Thank´s  Deepika,

This does not work!

Where I put that code? DO_PREPARE_OUTPUT in method?

  lr_byadminh-> get_transaction ().

From consists lr_byadminh? What type is it?

As the full data?

Sorry, if my question is stupid !!

I'm Newbie in CRM Web UI.

Best regards,

JMP

deepika_chandrasekar
Active Contributor
0 Kudos

Hi Jose,

Sorry that is not lr_byadminh it is lr_btadminh.

lr_tx type ref to IF_BOL_TRANSACTION_CONTEXT.

lr_core->modify( ).

lr_tr ?= lr_btadminh->get_transaction( ).
Lr_tr->commit( ).

lr_tr->save( ).

This code you have to put after you do creation and modify

AFtre you do all changes in that method put this code in the end.

Regards,

Deepika.

former_member190077
Participant
0 Kudos

Thank You,

Excellent for clarification now if it works !!

I explain briefly what I did ...

*************************************

Method DO_PREPARE_OUTPUT

.

.

.

.

lr_ent         TYPE REF TO cl_crm_bol_entity.



lr_ent ?= me->typed_Context->detail->collection_wrapper->get_current( ).

DATA: lr_tx type ref to IF_BOL_TRANSACTION_CONTEXT,

         lr_bol_core type ref to cl_crm_bol_core.

   lr_bol_core = cl_crm_bol_core => get_instance ().

   lr_ent-> switch_to_change_mode (). "Switch to edit mode.

       lr_ent-> SET_PROPERTY (iv_attr_name = 'ZZFLD000011'

                                  iv_value = 'H19').

lr_bol_core-> modify ().

lr_tx? = lr_ent-> get_transaction ().

lr_tx-> commit ().

lr_tx-> save ().

lr_tx-> commit ().

lr_tx-> ROLLBACK ().

Endmethod.

*************************************

As you can see, I made a "Commit", I  "save" to do "Commit" then did a ROLLBACK statement to leave the locked context but already with the saved data,

Makes take the changes I wanted to display the data.

Thank you very much for the help,

Best regards,

JMP

deepika_chandrasekar
Active Contributor
0 Kudos

HI JMP,

Close this thread if the issue is solved.

Regards,

Deepika.

former_member190077
Participant
0 Kudos

HI Deepika Chandrasekar,

I can not close this thread, I'm not who created the discussion, Sorry

if there is any other way to shut me you indicate?

Best Regarts,

JMP

former_member190077
Participant
0 Kudos

Hello I presented the same problem, I have tried to block the view after editing it with

lr_ent-> switch_to_change_mode ().

and I want to put in display mode and does not like it, if you could solve your problem you could help me.