cancel
Showing results for 
Search instead for 
Did you mean: 

How to Close Contract using BAPI or FM in SRM 7

Former Member
0 Kudos

Hi experts,

I am trying to close existing released contract through BAPI or Function Module so that status of contract becomes completed. We are using purchasing Contract in SRM 7. I am unable to find out any BAPI or FM for this. I am able to create Contract using BAPI    'BBP_PD_CTR_CREATE' and also update contract using BAPI 'BBP_PD_CTR_UPDATE' but not able to find out any BAPI for closing the contract.

Best Regards,

Kunal Sanghavi

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Kunal& Karthick,

Can anyone please kindly let us know the solution to this issue. it will be helpful for us.

Thanks in advance,

Regards,

Praveen

former_member183819
Active Contributor
0 Kudos

Hi

Above i mentioned steps , you can use for close contract in ECC system.

As per rule, you have to close the contract via SRM so that ECC contracts set as deletion.

Thanks

Muthu

Former Member
0 Kudos

Hi Muthu,

The issue we are discussing is a bit different, can you please take a look at our previous messages.

The description is a bit confusing though :-).......

Actually we are trying to update the contract data in SRM and also update the status of the contract to 'RELEASED'.

Thanks&Regards,

Praveen

Former Member
0 Kudos

Hi Praveen

I think that you should already solve your problem, but anyway, I found a solution for this.

You can get this 'RELEASED' status through the interface /sapsrm/if_pdo_bo_ctr, method release.

Try this sample code:

lo_msg_consumer = NEW /sapsrm/cl_pdo_msg( ).

lo_pdo_ctr = /sapsrm/cl_pdo_factory_ctr_adv=>get_instance( iv_header_guid = lv_guid

                                                            iv_mode        = lv_mode ).

lo_pdo_ctr->/sapsrm/if_pdo_bo_ctr~release( CHANGING co_message_handler = lo_msg_consumer ).

CALL FUNCTION 'BBP_PROCDOC_RESET_BUFFER'.

COMMIT WORK.




Regards

Former Member
0 Kudos

Hi,

Thank you for this response, I am facing the ssame problem ( Contract is geting updated, but the contract statut is not " release") .

Should we create message handler ?:

    lo_message_handler TYPE REF TO   /sapsrm/cl_pdo_msg

   CREATE OBJECT lo_message_handler.

and then :

     data :
  l_msg_consumer TYPE REF TO /SAPSRM/IF_PDO_MSG_CONSUMER.
l_msg_consumer =   lo_message_handler.

-In this instruction "

lo_pdo_ctr = /sapsrm/cl_pdo_factory_ctr_adv=>get_instance( iv_header_guid = lv_guid

                                                            iv_mode        = lv_mode ).

" What shoud be the value of iv_mode, because I'am geting a dump.

Best regards

Former Member
0 Kudos

Hi Mou Merou!

This is the code that works for me:

TRY.

*    Instance of ctr to release

      lv_o_pdo_ctr = /sapsrm/cl_pdo_factory_ctr_adv=>get_instance( iv_header_guid = iv_guid

                                                                                                  iv_mode        = lc_mode ).

*    release ctr

      lv_o_msg_consumer = NEW /sapsrm/cl_pdo_msg( ).

      lv_o_pdo_ctr->/sapsrm/if_pdo_bo_ctr~release( CHANGING co_message_handler = lv_o_msg_consumer ).

*    Read messages

      CLEAR lt_messages.

      lv_o_msg_consumer->get_messages( IMPORTING et_messages = lt_messages ).

    CATCH cx_root.

*     ERROR!

  ENDTRY.


Where, lc_mode is define like this:


CONSTANTS: lc_mode TYPE /sapsrm/pdo_inst_mode VALUE 'DISPLAY'.


And iv_guid is a parameter, type BBP_GUID, populated with the value of the contract GUID.


good luck!


Former Member
0 Kudos

Thank you,

I'am wondring, what is the type of lv_o_msg_consumer ??

I am geting error in this instruction :

lv_o_msg_consumer = NEW /sapsrm/cl_pdo_msg( ).

Regards

Former Member
0 Kudos

Oh, that instruction is to create a new instance of the class /sapsrm/cl_pdo_msg. I think that it only works in new versions of SRM.

Try it like in the old way:

DATA: lv_o_msg_consumer TYPE REF TO /sapsrm/if_pdo_msg_consumer.

CREATE OBJECT lv_o_msg_consumer TYPE /sapsrm/cl_pdo_msg.

I hope this works!

Former Member
0 Kudos

Hi,

I'am still getting the wrong statut of contract, I think that is because of lc_mode value, or because of the order of yhe instruction. I do the following :


   * Lock contract
    CALL FUNCTION 'BBP_PD_CTR_LOCK'
      EXPORTING
        i_header_guid = l_header_updated-guid.

*Update

    CALL FUNCTION 'BBP_PD_CTR_UPDATE'
      EXPORTING
        i_park                  = 'X'
        i_header                = l_header_updated
        iv_with_change_approval = ' '
        it_conditions           = lt_conditionsu
      TABLES
        i_item                  = wt_item2
        e_messages              = lt_message.

    CALL FUNCTION 'BBP_PD_CTR_SAVE'
      EXPORTING
        iv_header_guid = l_header_updated-guid.

    " Unlock contract
    CALL FUNCTION 'BBP_PD_CTR_UNLOCK'
      EXPORTING
        i_header_guid = l_header_updated-guid.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'


And then then the piece of code that you mentied. Is that what you did In your case ??


Thank you

former_member207661
Active Participant
0 Kudos

Thanks! it worked

dipak_khatavkar
Participant
0 Kudos

COde is working fine,...its helpful

Thanks a lot

Dipak

Former Member
0 Kudos

Hi

Try to use  BBP_PD_CTR_STATUS_CHANGE.

Regards.

Former Member
0 Kudos

Hi,

I found out breakpoint is going through this standard FM. Thanks for that. But If I run this FM with GUID of released Contract, I_ACTIVITY = 'CTCL', I_SAVE_DB = 'X', this is not creating Contract in completed status. Do I need to try with writing code only. this FM can not be run directly with Object GUID and other parameters ?

Best Regards,

Kunal Sanghavi

Former Member
0 Kudos

Hello

Did you commit the transaction ? you can use BAPI_TRANSACTION_COMMIT.

Regards.

Former Member
0 Kudos

Hi,

Thanks for the solution. Its working now, actually I was trying first directly by running function Module. In Code after using BAPI_TRANSACTION_COMMIT, its working correctly. I have one more problem now, If you can help me, I will be really thankful to you.

I am trying to update Contract which is in released status by using Function Module 'BBP_PD_CTR_UPDATE' and in such a way that after updation Contract should be again in released status. I wrote the following code.

   CALL FUNCTION 'BBP_PD_CTR_UPDATE'                         " Contract Updation BAPI
    EXPORTING
       I_PARK              = 'X'
       i_save               = 'X'
      i_header             = lw_header1
        IMPORTING
      es_header          = es_header
       TABLES
      i_item                  = lt_item
      i_partner             = lt_partner
      i_longtext             = lt_longtext
      i_orgdata             = lt_org
     e_messages         = lt_messages.
     .

  IF lt_messages IS NOT INITIAL.
    LOOP AT lt_messages INTO lw_messages WHERE msgty = 'A' OR msgty = 'E'.
      APPEND lw_messages TO et_messages.
    ENDLOOP.
  ENDIF.

  IF et_messages[] IS INITIAL.             

    CALL FUNCTION 'BBP_PD_CTR_SAVE'
     EXPORTING
      IV_HEADER_GUID  = es_header-guid.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  ENDIF.

Here, Change version is created as I  am updating Contract after Update status, I am able to see updated value in BBP_PD in changed version but not in active version also in Portal, If I view the contract, updated values are present but status of the contract remains awaiting approval instead of Released. Also, some PDO LAYER ERROR is displayed like "Cannot get process info; function BBP_PDH_WFL_APPROVAL_SIMULATE throws exception Workflow Not Found" .  Workflow setting is Auto Approval and it is working fine If I release contract through Portal.

If I dont need changed version, I found out 1 solution as I am passing

  IV_WITH_CHANGE_APPROVAL = ' ' in 'BBP_PD_CTR_UPDATE' FM. This is working fine and I am getting released Contract with changed values but without any change version created in BBP_PD.

But If I need change version to be created in system, If you can help me with the solution, I will be great thankful to you.

Best Regards,

Kunal Sanghavi

Former Member
0 Kudos

Hello

Try the below solution.

Call BBP_PD_CTR_UPDATE without passing IV_WITH_CHANGE_APPROVAL =  ' '.

and then call BBP_PD_CTR_SAVE with importing parameter IV_CREATE_HIST_VERSION =  'X'.

Regards.

Former Member
0 Kudos

Hi,

Still the same error, it seems Change version is created but not getting closed and Activ document is not getting updated with Changed values .

Best Regards,

Kunal Sanghavi

Former Member
0 Kudos

Hello

Do you mean to say that the active version of the document does not have the values that you have changed ?

despite it has created a new version( which is not active) which has the changed values ?

What is the current status of the active document ?

Do you have a CTR change approval workflow active or it is auto approved?

Former Member
0 Kudos

Hi,

Yes, active version of the document does not have the values that I have changed, In Portal it is showing changed value from changed version with awaiting approval status and PDO error. New Change version is created with changed values but it is not closed. Workflow is auto Approval only.

If I change released Contract from Portal and release it again with change value, everything works fine, I am getting released status in portal. In this, change version got created with changed value but that got closed which is not happening through code and active document also contains changed value if I do it through portal.

Best Regards,

Kunal Sanghavi

Former Member
0 Kudos

Kunal, Did you find a solution to this? I am also facing the same problem.

Karthick.

former_member183819
Active Contributor
0 Kudos
  1. 1. Create a test sequence in SE37 to run BAPI_CONTRACT_CHANGE and BAPI_TRANSACTION_COMMIT.
  2. . Execute the same and give the parameter Purchasing document.
  3. Filling Item, Itemx with Item number and Deletion Indicator.
  4. Then executing the Test sequence to run both BAPIs

Now we can see that deletion indicator is updated on EKPO table as S.

Always create new thread - so some one will get points.

and now  check ME33K

Muthu

Former Member
0 Kudos

Hi Muthu,

This works for the contracts in ECC, but we need a way to update the contract in SRM.

We tried to update the contract using bbp_pd_ctr_update and bbp_pd_ctr_save, the document in SRM was updated with held status, is there any way to release the contract after the updating the data.

Thanks&Regards,

Praveen