Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
steverumsby
Active Contributor


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:
https://server/sap/bc/webrfc?_FUNCTION=Z_user_fullname&_Name={name}

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:
https://server/sap/bc/webrfc?_FUNCTION=Z_user_setlock&_bname={name}&_lockstate={lockstate}

 

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. :smile:

 

I'm now collecting ideas for others users for this technique. Suggestions in the comments, please!

10 Comments