on 08-28-2014 1:59 PM
Hi Guys,
I have created a little script that runs SU3 to pick up and display the user's system id.
It works fine when going in for the first time, or if I run it manually from my screen but if I leave my screen and try to return to it from another screen via the back/up/cancel buttons it goes into a loop and then crashed out .... any thoughts anyone?
Regards.
Patrick.
Thanks to all those that took the time to reply.
I could see the inherent loop in calling SU3 every time you arrived at the landing page and that routine returning you back there, but it was the inconsistencies and the erratic behaviour that were foxing me, e.g. why it worked first time through for instance, and why the loop was irregular.... anyway that was then and this is now.
In the end I used the blogs of Steve Rumsby, Sebastian Steinhauer & Tamas Hoznek to create a simple WebRFC. It works great - lightening fast and loop free. Here is the function module for what it's worth ... (disclaimer - I am not a ababer)
FUNCTION ZPERSO_USER_LOOK_UP.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" QUERY_STRING STRUCTURE W3QUERY
*" HTML STRUCTURE W3HTML
*" MIME STRUCTURE W3MIME
*" CHANGING
*" REFERENCE(CONTENT_TYPE) LIKE W3PARAM-CONT_TYPE DEFAULT
*" 'application/json'
*" REFERENCE(CONTENT_LENGTH) LIKE W3PARAM-CONT_LEN
*" REFERENCE(RETURN_CODE) LIKE W3PARAM-RET_CODE
*"----------------------------------------------------------------------
DATA: name TYPE STRING.
SORT QUERY_STRING DESCENDING.
READ TABLE QUERY_STRING WITH KEY NAME = '_Name'.
name = QUERY_STRING-VALUE.
translate name to upper case.
data: first like usr03-name1, last like usr03-name2.
data: fullname(60) type c.
* select single name1 name2 from usr03 into (first, last) where bname = name.
* concatenate first last into fullname separated by space.
data: l_pernr type persno.
select single pernr from pa0105 into l_pernr
where subty = '0001'
and endda = '99991231'
and usrid = sy-uname.
select single nachn vorna from pa0002 into (last, first)
where pernr = l_pernr
and endda = '99991231'.
concatenate first last into fullname separated by space.
DATA: htmldoc LIKE LINE OF HTML.
CONCATENATE '{"results": [ {"key": "fullname", "value": "' fullname '"}, {"key": "personnel_no", "value": " ' l_pernr '" }]}'
INTO htmldoc-line.
INSERT htmldoc INTO TABLE HTML.
ENDFUNCTION.
Thanks Again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Patrick,
can you put your script actions here so that we know what is there exactly and little more description of your scenario.
SUshant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sushant,
Here's the setup...
... nothing much to it ... go to SU3 and pick up the userid, come back and display it on the screen.
As I say it works fine when I land on this page so the 'ObScreenHandler' seems to fire it up fine but when I stop on another t-code (even SU3) and try to come back the my landing page via the back/up/cancel buttons I get into a loop, or an error, or both!
See the little video of the problem in action... Personas Looping Problem - PatrickTR's library
Hi Patrick,
onCreateHandler is invoked on every screen load. So when you hit back, it gets called again. Hence it ends up in loop.
If you have Landing page with Go button -> Current page -> SU3 pattern then instead of onCreateHandler of current page, move the script to Landing Page script "Go 1" button which will click on standard Go button and then execute other script steps.
Thanks
Chinthan
Hi Chinthan,
Thanks for the response.
Can you say a few more words please. I want this script to run automatically so that when someone comes to it for the first time, the system can establish some basic details on the logged on user.
How do I get that 'go' button to click automatically if I can't use the 'onscreenhandler'?
Also under what circumstances would you use the OnScreenHandler if it is liable to loop?
I can see why this has the potential to loop but why does it not loop first time around - when I hit the landing page for the first time the script works as expected?
Regards.
Patrick.
Hi Patrick,
Yes onCreateHandler is provided to perform action on screen load. So the first time it loads data and navigates to SU3. But when you click back button it will load data and navigate to SU3 again resulting in loop.
For example, I have a simple script to copy value and paste it into another text field and it is called from onCreateHandler of current page
I can achieve the same from landing page by adding extra step to click on Go button first (in this case display glasses icon) and then calling RefreshScreen step and then same copy and paste steps will work
Hope that helps.
Thanks
Chinthan
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.