Challenge yourself (HR-PD Appraisal BADIs)
This blog (series… I believe it will become a series sooner or later) is for people that are curious and have this stupid custom of trying something new, outside of their everyday box. It is for people that accept challenges and feel this warm feeling when they crack the problem after a fair duel.
I once had a colleague (for just very short time), who spent two months working on a program that was quite short and was only calling BAPI_SALESORDER_CREATEFROMDAT2. I don`t say I would do better at that time, but I can imagine the pain of the newcomers. But over the years I learnt something that would help me or him at that time. I learnt two things. Not to be afraid, that`s crucial.
If you`re afraid, you tell your boss something like “It cannot be done” or “It would take a week” or similar nonsense. Some bosses might even go to a customer and pass that nonsense to the customer (it`s often because they`re good bosses when It comes to people, they trust their colleagues etc.). And that damages the business, the customer and you too.
The second thing is to USE the SAP standard. It might sound obvious. It is. But after that gentleman above got fired and started talking, I learnt that he had no idea how to benefit from the fact that the aforementioned BAPI is called all over the place (I think so, don`t make me to go and look in my system… Ok, I checked and in my system and it is called from at least 3 times from SAP standard code + some demos and stuff). He didn`t get the idea of finding a transaction which create s sales orders, going to the BAPI source text, putting in the breakpoint, running the transactions and checking what are the arguments. So he spent a week trying to call the BAPI for the first time.
So that`s the background why I write this blog, why I accept challenges and the story. Howgh!
Now here is the problem: I want to sell nice and cool SAP standard performance dialog solution. No custom development, just elegant, simple customizing + some BADIs maybe to make the thing even cooler. I must also mention that the problem is not mine. It`s a friends problem. My job is not to do BADI implementations in HR or appraisals. I do ABAP and Java authorizations and security. So that`s quite a challenge for me.
I know how to debug, how BADIs work, I was shown the transaction where one can create an appraisal form and I was show the PHAP_CREATE transaction where one can create an instance of that appraisal. In that PHAP_CREATE transaction there is a button “Additional data” which opens up a popup which lists some more data about the appraisee. The challenges is to put some more data into that popup without having to change a standard SAP code or do custom development (my BADI development will start with Z of course, but it will spoil the customer`s system much less than rebuilding half of the appraisals system, right).
Side-note: if you`re an HR person, a developer or a consultant, this blog must be a bore for you. I know. Then try to replace the HR BADI problem with any other and try it yourself.
The cracking process
So what we need to do is to find the name of the BADI first. One can go to SDN and start searching, but there must be dozens of BADIs in HR and appraisal system, so I rather start debugging. I am a developer after all. So I go PHAP_CREATE, put the magic spell “/h” to the OK_CODE box (or how do you guys call it?) and start debugging.
Interesting parts were:
* Call subscreens
CALL SUBSCREEN sub_container.
* Call subscreens
CALL SUBSCREEN sub_header.
* header defaulting
WHEN ‘BHEAD’. And so on.
Then I reach CALL METHOD p_2100_instance->get_add_header_data.
P_2100_instance is an instance of a class that looks very much like the BADI I need. The BADI definition name is HRHAP00_ADD_HEADER. I can now go to SE18 and take a look. Hmm, 3 methods.
Let`s implement the class and see what happens. To be able to see what happens I implement all three methods I put BREAK-POINT statement in them. So that`s my ZCL_IM_HR_HRHAP00_ADD_HEAD implementation.
I assume that you know how to implement a BAI, dear reader, but if not, I Googled a nice SDN forum thread that should help: Performance Appraisal : BADIs – Header – Additional data
So we now have the BADI implemented. I go PHAP_CREATE to create an appraisal instance (whatever you call it, HR friends). Oops, “Additional data” button does not trigger my BADI.
Cracking the necessary customizing
Ok, there must be something more. PHAP_CREATE does not offer any “customizing” where I could change something, so go back to OOAM (PHAP_CATALOG). I have no idea what to do with the appraisal template definitions, so let`s go check the menu. I learnt that some “advanced” options and customizing are hidden under discrete main menu entries, rather that accessible via the buttons or right mouse clicks. Interesting, there is a section Enhancements under Goto. There is then “Additional Header Data” item further in the menu. And I cannot see my enhancement here. I must find a way how to get it here (There is a “Create” button here too, that could make the whole thing much easier if you create the implementation from here. Just a guess, I am not going to try).
The Google and SDN comes to play again. This thread helps: how to create a enhancement in a enhancement area in MBO module. Let`s go OOHAP_BASIC, Enhancement Area “AY”, new enhancement. The thread says “F4, there is your filter value of your new BAdI implementation”. For whatever reason the search help didn`t work for me, but when I put in the definition and saved, it worked. In the thread there is one more useful information is at the very bottom: “To make enhancement be visible in “Free enhancement” combo-box in appraisal template catalog (OOAM), the view cluster VC_T77HAP_CATEGORY “Category groups” should also be maintained”.
Let`s go SM34, view cluster = VC_T77HAP_CATEGORY. Ah, so I have to assign my Enhancement to an appraisal category group. And assign it to a category too. These two I know, because my appraisal template belongs to one of these. Then comes the enhancement area. I know that from before too = “AY” (see above).
On the way I learnt that I am supposed to put the enhancement to the “Layout” tab of the appraisal template (see first SDN thread above: “I apologize, it is not in the “Processing” tab page but it is in the “LAYOUT” tab page”).
So I go check “Layout”, namely the “Further” section. By default there is nothing, but I can select “Personnel Header Data”. I noticed that my “Additional data” button (in PHAP_CREATE) is not there for some of the appraisal forms, so could it be that I have to select this “Personnel Header Data” (at least) to be able to see that button? And now I also know that if I do everything right, I should get my BADI implementation visible here too. And If I select it, it will get triggered and I get my custom additional data.
For those new to appraisal templates like me it is important to know there are “statuses” of the forms. If the form is “Released” then you see it in PHAP_CREATE, but you cannot make any more changes. If it is “Not Released”, you can make changes, but not visible in PHAP_CREATE. If you need to switch between these two statuses, go right mouse click -> Status -> Release (or Cancel Release).
And now, when we got that far, if I go PHAP_CREATE and select my “demo template” here we go: BREAK-POINT in the debugger is here.
Adding custom fields
At first I got frightened that I will have to somehow figure out how to create the BADI implementation from scratch. But it`s not that bad. There is this “Personnel Header Data” default option which has a class behind it. That`s something that I would expect. Unfortunately the documentation of the BADI description does not say anything about it (or I must have missed it). If you go to SE24 and search for PERSONNEL_HEADER_DATA, such class does not exist either. So the best option (maybe the only one, maybe there are others) is to go to PHAP_CATALOG menu -> Enhancements -> Additional Header Data -> click on PERSONNEL_HEADER_DATA and click display. Voila! Here comes the class.
When you compare the number of lines of the code in this class, which is by the way called CL_IM_HRHAP00_ADD_HEADER_1, it will tell you that there is a long way to write that code yourself. That means you will either have to call this functionality somehow or maybe copy that class, register it as described above and use the copy instead. It`s up to you.
It makes no sense to flush code here, if you can do some ABAP, I just gave you all the clues necessary to be able to add custom fields as per your requirement.
Conclusion and appeal
Hope I won`t be accused of posting boring step-by-step tutorials. I know we have wikis etc. But I tried to share a story here including the reasoning, how I managed to step further etc. Some patterns should be reusable in many other situations, outside of HR or authorizations.
If you want to give this blog additional sense, what about accepting a challenge from outside your box and then writing a blog about that? It would feel good to know that I inspired somebody maybe and one more blog that will provide useful knowledge was born. If you do that, if you accept my challenge, please post a link under this blog so I can read it too. It would be a pity to miss it.