Variant Configuration – PFunction vs Function

Home / Blog / Variant Configuration – PFunction vs Function

Today post again is largely due to my good friend Jeremy Meier.  I’ve heard about pfunctions for a long time.  But I never understood the different between functions and PFunctions.  So today, to solidify it in my own mind I’m going to talk about PFunction vs Function and why you would use one versus the other.

So, in my previous life, I used functions heavily, and they worked great.  For example, I had functions that would take a string of digits and convert it into specific characteristic values.  The company I worked for used “intelligent” catalog numbers for everything.  This is actually was a great way to implement variant configuration for the customer service group.  They typed in a string of digits, and the configurator figured out exactly what to populate, leaving only a handful of other values for the CSR to populate.  Now this is great.  The function needed to have an input (the catalog number) and bunch of outputs (each cstic that would be populated).  Now this is fine, until the first time you have to make an addition, say you add a new special option that drives a new characteristic.  Well, now you need to update the CU66 function interface, and also the SE37 ABAP function to bring in the new value and output the proper value.  It’s not the end of the world, but it can be a hassle.

Now, what I just finally figured out (yes, I know I can be slow) is that if you simply change the procedure to PFUNCTION vs Function, then you don’t really need any inputs.  the PFUNCTION statement populates the GLOBALS structure which contains the instance of the $SELF, $PARENT and $ROOT.  So now, you know the current level, the level directly above and the topmost level.  Using that instance number, you can plug into any number of CUPR functions that exist in standard SAP.  (CUPR_SET_VAL, CUPR_GET_VAL, etc.)  These functions allow you to extract the configuration using the instance #, and you don’t have to explicitly define every cstic you want to extract.

So, the real difference is PFUNCTION will send the instance automatically.  You can even have a PFUNCTION that has no parameters and you will have the full range of input and output, and you can set anything, including values at the parent level based on something in the lower level.  It really is pretty slick.  So, pfunction vs function, really is a big difference and clearly something I wish I understood a lot sooner in my career.  But like everything, live and learn and keep learning .

Thanks for reading, and thanks again Jer,

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,

Leave a Reply

Your email address will not be published. Required fields are marked *