Technical Articles
Equipment Partners – Deletion
Purpose
The purpose of this blog post is to share an approach to deleting equipment partners from customer developed ABAP programs. And a big thanks to Mr Murphy for asking and therefore prompting this post.
This is a follow-on post from https://blogs.sap.com/2020/09/15/equipment-partners/ in which I introduced several function modules of the function group ALM_ME_PARTNER .
Recap
The function group ALM_ME_PARTNER contains several functions which together provide a means for working with partners of technical objects. e.g equipment and functional locations.
In particular, I mentioned ALM_ME_PARTNER_MAINTAIN for maintaining partner assignments but noted that deletion of partner assignments wasn’t possible.
FUNCTION GROUP ALM_ME_PARTNER
FUNCTION ALM_ME_PARTNER_MAINTAIN
Whilst the body of the function module ALM_ME_PARTNER_MAINTAIN contains coding to support deletion, a revision to the function module sees the introduction of the lines below. This addition effectively means that maintenance of existing assignments is no longer possible.
*--- get partners for the technical object and
* delete the partners which are not present.
CALL FUNCTION 'PM_PARTNER_GET'
EXPORTING
objnr = CS_ITOB-OBJNR
TABLES
ihpa_tab = lt_ihpa.
LOOP AT IT_BAPI_IHPA INTO LS_BAPI_IHPA.
READ TABLE lt_ihpa INTO ls_ihpa WITH KEY
PARVW = LS_BAPI_IHPA-PARTN_ROLE
PARNR = LS_BAPI_IHPA-PARTNER.
IF sy-subrc = 0.
DELETE TABLE IT_BAPI_IHPA FROM LS_BAPI_IHPA.
ENDIF.
ENDLOOP.
As an aside: Did anyone else note the dissonance between the comment “delete the partners which are not present” and what the code actually does? Anyway – moving right along to the core topic.
Deletion of Partner Assignments
Approach 1
It seems that the restriction in ALM_ME_PARTNER_MAINTAIN was noticed by another group of developers. They decided to copy ALM_ME_PARTNER_MAINTAIN to come up with their own similar but different implementation. And so function CRM_IHPA_CHANGE_OS is born.
FUNCTION CRM_IHPA_CHANGE_OS
This function allows existing partner assignments of equipment to be deleted. Please re-read the last sentence. Unlike ALM_ME_PARTNER_MAINTAIN, the function is restricted to equipment only and does not support functional locations.
Then follow with
FUNCTION PM_PARTNER_CALL_VB
COMMIT WORK.
Approach 2
I’d like to introduce a second approach which can be equally applied to either equipment or functional locations i.e. Technical Objects. Another aside: Technical Objects aka TOB => TOB in the name of the function ALM_ME_TOB_PARTNERS.
This second approach extracts the approach to the deletion of existing partners from ALM_ME_PARTNER_MAINTAIN and/or CRM_IHPA_CHANGE_OS.
The first step: Initialize the PM Partner processing with a call to function PM_PARTNER_INIT.
FUNCTION 'PM_PARTNER_INIT'
The second step: Mark the partner assignment for deletion with a call to function PM_PARTNER_DELETE_UDKZ. This doesn’t delete the partner assignment from the database immediately. The function merely sets an indicator on the partner assignment that comes into play during the saving process. At that point the assignment is physically deleted from the database.
FUNCTION 'PM_PARTNER_DELETE_UDKZ'
Then proceed with the calls to following as per the prior blog post.
FUNCTION ALM_ME_PARTNER_MAINTAIN
FUNCTION PM_PARTNER_CALL_VB
COMMIT WORK.
Recommendation
So which approach? I prefer the second, because CRM_IHPA_CHANGE_OS isn’t widely used and therefore more likely to be changed underneath your feet. Over the years, I’ve noticed that the higher the usage within SAP code, the less likely a change of behaviour is introduced. Of course all re-use of non-released function modules comes with the inherent risk that it may change or cease to exist without notice.
To maintain the equipment partners, I’d recommend that the above steps be combined into a class and then wrapped in a function module if needed for remote access.
Don’t forget that changing the equipment partners is part of changing a piece of equipment – so you are advised to ensure you have exclusive use of the equipment. Locking etc.
Write unit tests first! Don’t forget your can run them during support packages and when notes are applied to ensure your code still works!
Test thoroughly!
Thanks for sharing this.
Hello Andrew,
Thanks for sharing this.
But let me highlight one point here.... I followed the second approach and I'm successfully able to clear partners from euipments. When I see in IE03 I can see No partners for an equipment but when I go to change mode, IE02, I can see all the partners.
I think this is because, by second approach we are just putting deletion mark to the partner, but due to the entries which are there in EQUI and EQUZ table, in IE02 partners are again showing.
I don't want them in IE02 too.
Hi Andrew,
very interesting and helpful post to get to know the different FMs.
My interest is actually the other way around. When I post the goods receipt of a return delivery, the system status of the equipment gets updated correctly, but in the same action the partner function gets deleted without any change document, which is to be stopped.
So I checked the "where-use-list" of the FM you mentioned, but it seems they are not used in any customer-code.
so I guess there are also other tricks on how to delete a partner function from the equipment.
So, if I may ask the question if you have any hint on where to check, it would be highly appreciated.
Thanks a lot
Matthias
small update on 2022-12-22: deletion of partners is SAP standard behavior, they said we can refer to note 734348