Using WebRFC for update in a Personas script
In a previous blog – Calling RFCs from a Personas script – I described using a WebRFC to perform lookups in a Personas script more quickly than you can using the traditional method of driving the relevant SAPgui transaction. At the end of that blog I left a tantalising comment that “a WebRFC can perform updates as well as lookups“, and wondered what possibilities that might offer. Here’s my first step into that investigation.
One thing I’ve tried to automate using “traditional” Personas scripts is some basic user management. Within our SAP support team we often get calls from users that have forgotten their password and/or had their user locked through too many failed login attempts. I thought it would be useful to streamline the management of that situation for the users in our team. The demo in my previous blog was a simple user lookup built into the “home screen”, to check a users real name against the username. I’ve tried scripting lock and unlock buttons but that gets complicated because the functionality in the SU01 transaction is a toggle. Using WebRFC calls to do this seemed like it would be easier. Here’s what I ended up with:
Notice first that the “Lookup” button brings back two values – the user’s full name and also the current locked/unlocked status. A WebRFC function can return multiple values. Also notice that I change the label on the lock/unlock button to make it clear what it is going to do.
The script on that button is:
The WebRFC call in full:
This WebRFC actually returns three values – the name and a textual description of the lock state, both of which are copied to fields on the screen, and a literal copy of the lockflags from ERP which is copied to a hidden field for use by the second script. Steps 7-10 change the label on the second button.
The lock/unlock button then calls a second WebRFC, passing it both the username and the desired action – lock or unlock. Actually to keep this script simple, for the desired action I pass the current lockstate from the hidden field populated earlier and the ABAP function flips it – passing in “UUU” causes the user to be locked, and anything else causes the user to be unlocked.
And the WebRFC call in full:
I also have a step 5 to push the first button to update the state of the displayed (and hidden) fields.
The ABAP functions called are attached. There’s nothing of particular interest in them – just the usual code to unpack parameters and pack return values, plus calls to some standard BAPIs to get user info and set/unset a lock.
There are business functions with similar simplicity – Purchase Order release, for example – that could easily be given the same treatment, allowing users to release POs without ever going near ME28 or ME29N. Clearly with the right amount of work you could do pretty much anything this way, building complex functionality in an ABAP function and using Personas to build the UI. That’s is an interesting possibility and well worth exploring further. It may not really be in the spirit of Personas, but for me, part of the fun of IT is finding new, unexpected ways to use tools and devices. 🙂
I’m now collecting ideas for others users for this technique. Suggestions in the comments, please!
I thought webrfc is obsolete and should not be used anymore? My understanding is that webrfc comes from the times there was an external ITS and was only brought to internal ITS for compatibility issues.
"WebRFC and Web Reporting are old techniques which work as is. No new features will be added. If new developments are planned they should be implemented using either BSP or Web Dynpro UI technology."
Is my understanding wrong? Are you talking here about another WebRFC technology or are you benefiting of SAP's "once there, it will be there and never removed" strategy?
We are taking about the same thing, and yes those notes do say the technology is obsolete. However, support for it is in the shiny new SAP product that is Personas. I'm assuming that wouldn't be the case if it was going to go away anytime soon. Perhaps Peter Spielvogel or Tobias Queck have some thoughts on this?
To me this is a reason to advice against Personas, as it depends on a technology marked obsolete. Even with a new product from SAP using it, this is far from being good, as it will be the only product using webrfc.
Maybe it's time SAP rewrites those SAP notes or gradually move Personas to another technology (like GW)
I think it is fair to say that WebRFC is far from necessary to make good use of Personas. The ability to call WebRFCs is provided for when the "standard" Personas functionality isn't quite good enough. I do agree with you that if facilities are provided to extend standard functionality then they should be based on something with a longer lifespan (not obsolete from the start). Gateway services do seem to be the obvious thing to use.
I have no inside information on future development plans. Maybe the Personas team already have this in mind and would like to comment?
I am a little bit confused about your advice because it is based on your statement that “Personas depends on technology marked obsolete”. Let’s step back for a moment and think about what Personas is: Personas allows customers to personalize SAP DYNPRO screens. Dynpro is a technology that is not intended to be used for any new UI development BUT it is still one of the technologies that many customers use.
To summarize, WebRFCs are not required, but an advanced option for customers that have no other alternatives to get data out of their SAP systems into a Personas script. As usual, my recommendation is to let the customer decide whether to use it or not. I think Steve explained quite nicely why it helps him.
would you be so kind and share the script and WebRFC-Details with us like you did in the other posts? Wolud be a great help for learning how to use.
Thanks in advance,
Sure. Sorry - I'm not sure why I didn't. I'll update the blog later this morning.
Hi there! I'm an ABAP developer with some functional (SD) background and now I'm exploring Personas in depth. What a great and powerful product!
As a use case, I'm starting with a Z transaction that displays a list of deliveries (VL01N). From that list, when in SAP GUI, the user must go on 5 different transactions (using /N or /O) doing lots of manual work just to copy and paste document numbers to feed each transaction until all the steps are done so the logistic process can go on. And my user does it about 200 times each day!
My objective was to free the user from all of these steps and I'm now almost done on it!
One of the challenges I've gone is that, since the user mark one delivery and click on my script button I call 5 transactions without showing it to the user, and each of them makes some kind of update on that delivery. At this point sometimes I saw the script stopping because one process haven't realeased the SAP internal tables yet, so the next transaction wasn't able to lock those tables!
The solution was to develop a RFC that receives the delivery number, check if it is locked during 5 seconds max and then returns a flag telling to the Personas' script if that delivery is locked or not. From there I check on my script that flag before going on the next transaction. I made this RFC available as a WebRFC so I can call it from my script.
This is an example where Personas + ABAP + Functional knowledge fit together to make a complex procedure sooooooo much easier, faster and beaultiful for the end user.
One other challenge I had during this development is that since you issue a "/N" on one transaction you completely lose the context of that transaction. Since I would like the user to look at the screen and think that everything was just updated, I had to adress this too and I've made use of some ABAP to save and restore report screen variants so that at the end of the process I could re-enter my Z transacition with the same parameters so the user just see a small "blink" on the screen when, in the background, I've left the original transaction, have gone to 5 other transactions and relaunched the original transaction without him even perceiving it.
It's really impressive, people smile when I show it!
Thank you all for all the good ideas, examples and knowledge sharing!
Thanks for sharing your examples! I'd be really interested to hear more, and I'm sure others would too. Would you be willing to share your examples in a blog or two, with screen shots or videos to show how they work?
This is a great example. It would be great if you write a more detailed blog as Steve suggested. It will help us all.
Thanks for sharing your experience.