on 04-30-2012 9:03 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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!
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!
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
Hi
Try to use BBP_PD_CTR_STATUS_CHANGE.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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?
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.