Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
dustyplanet
Active Participant
0 Kudos
1,205

What is this post about?

As ABAPers, I'm sure all of us have our share of "Eureka!!!" moments, when we discover a possibility that we did not know of earlier...

This is a story of how such a moment left me with a confused set of feelings...
For those interested in the technical details... have you ever wanted to create a report that executes automatically after displaying the selection screen for a specific period of time?
Have you been told it can't be done?
Surprise... surprise !!! It can ! (And if you already knew, why didn't you tell me earlier?!)

This post attempts to tell you precisely how to make this possible and, at no extra cost, my personal advice for dealing with the weird feeling of discovering you were wrong about something!

Why a blog?

Having been an SAP Technical trainer for a few years now, I have had the privilege(or discomfort) of being asked questions in and out of ABAP classrooms about things that have nothing to do with the curriculum. Sometimes - I'd like to think "almost always" 😉 - I know the answer, and sometimes I think I know...
In all cases I say what I know,
"It's possible to do this, and this is how..."
or
"I don't think this is possible... and this is why not...".
More often than not, the question is answered adequately and everyone lives happily ever after, but once in a while I say, convincingly enough, that something isn't possible, based on what I believe, what I have seen, or what I have been told...
   ...only to discover later that I was wrong...

This is about one of those silly occassions, when - thanks to SDN - I discovered a technique, and before I'm sued for refuting the possibility, I wanted to document it, thus the blog... OK, enough philosophizing, let's get to work!

The requirement

Recently, in an ABAP class, a curious and enthusiastic student(aren't they all?) asked me if it was possible to automatically execute a report after displaying the selection screen for a fixed duration of time... Coincidentally, the same day, I also saw a Need to execute Selection Screen Parameter with time specfic on the same possibility! I have to admit I had considered this possibility earlier and in my younger and more enthusiastic days, I had posed this query to my seniors and peers at the time, only to get the predictable response "Not possible!"
In some time, my research on this tapered off, and I never managed to achieve closure on this issue... Today I know that there are people who know it is possible, but I did not have the fortune of communicating with these Gurus and I assumed, like so many people before me, that it really wasn't possible, and so I told my student...

But yesterday, when I was foraging through SDN for some juicy blogs, I stumbled across Rich Heilman's The specified item was not found. and suddenly(imagine lightbulb above my head and bell sound!), I had the answer to the earlier question...

I always knew about the CL_GUI_TIMER class, but strangely never thought I could use it on a selection screen or without a container, until I saw Rich do it!
Sometimes, a solution is so close, you can't see it!

Obviously, I was wrong... but such discoveries excite me, however uncomfortable the realization! Imagine,(not so)long ago, it was said that cancer was incurable, that there were only 9 planets, that the Sun went around the Earth...
When I thought about the kind of people who said these things, I figured I'm in elite company!

So for the benefit of those who don't want to wait years to discover this simple-enough technique, however useless it may seem at first sight, here is the description...

So, How?

For this example, I wrote a simple Executable Program, which has a single field on the selection screen with a default value attached. In 10 seconds, if the user does not execute the program, it executes automatically.
This is achieved by creating an instance of the CL_GUI_TIMER class and setting its interval attribute to 10(or whatever your desired timeout, in seconds) and then invoke the run method. We also need to create a local class to do the job of the handler for the finished event. In my example, the method when_done in class LCL_HANDLER does this. Also remember to register the handler class instance before starting the timer! The only hitch I faced while building this example was to know the Function Code of the "Execute" button, but it didn't take very long to figure that out...

Here's the code...


This program and any usage of the CL_GUI_TIMER class on an older system (prior to 4.6c) will need you to define a local CL_GUI_TIMER class, look at Rich's blog linked above to understand how to do this...

And the next time you find something that most people, including you, did not know existed, do everybody a favor and share it with us!
16 Comments
Peter_Inotai
Active Contributor
0 Kudos
Hi Dushyant,
Thanks for this example.
Do you have any example where it can be useful?
Best regards,
Peter
PS: Similar program....it's fun, but I don't think it makes sense to use it for business applications:

REPORT  ZTEST_INVISIBLE_TRICK         .

*************************************************************
START-OF-SELECTION.
*SAPGUI screen vanishes from user screen list

CALL FUNCTION 'SAPGUI_SET_PROPERTY'
DESTINATION 'SAPGUI'
EXPORTING property = 'VISIBLE'
value = ' '
EXCEPTIONS system_failure = 1
communication_failure = 2
OTHERS = 3.

************************************************************************

DO 1000 TIMES.

*doing some work which takes lot of time
    DO 1000 TIMES.
    ENDDO.
*Resetting time counter of dialog process so that time-out doesnot
*happen. Use this fm within your programs at appropriate locations to
*reset time counter.

CALL FUNCTION 'TH_REDISPATCH'.

ENDDO.

*************************************************************
*Work is complete and now wake up the SAPGUI screen

CALL FUNCTION 'SAPGUI_SET_PROPERTY'
DESTINATION 'SAPGUI'
EXPORTING property = 'VISIBLE'
value = 'X'
EXCEPTIONS system_failure = 1
communication_failure = 2
OTHERS = 3.
dustyplanet
Active Participant
0 Kudos
Hi Peter,
Thanks for your comment !
A simple example would be to create a list that always displays updated information, even if the information keeps changing, you can regenerate the list automatically every minute, in the absence of user input, so that whatever the user sees is current, the same applies to screens...
We generally believe that once control is at the "Presentation Server"(SAPGUI), the only way to trigger code on the application server is for the user to perform a user action(pushbutton, Menu options), but this is one mechanism to force control to be transfered to the Application server in a time-dependent manner.

Thanks for the code, I have seen this earlier, but I fail to see the similarity to my example simply because my program involves a dialog(a selection screen) which triggers code without user input.

Regards,

Dushyant Shetty
abdul_hakim
Active Contributor
0 Kudos
Thanks for sharing this with the community.
dustyplanet
Active Participant
0 Kudos
You're welcome ! Glad you found it useful 🙂

Dushyant
learnsap
Active Participant
0 Kudos
Thanks for sharing this... It was really an Eureka Moment....
Former Member
0 Kudos
this is very nice. thanks for sharing this program

regards
shankar
alexander_schuchman
Participant
0 Kudos
Subject says it all.
dustyplanet
Active Participant
0 Kudos
I'm still waiting for somebody to share their "Eureka" experiences !

Dushyant
0 Kudos
Nice one Dushyant .This class does pretty much same as what function module "ENQUE_SLEEP" does.
dustyplanet
Active Participant
0 Kudos
Thanks Anil,

There are a few things like the auto-refresh example I mentioned, that we can achieve using either ENQUE_SLEEP(using an additional external session/mode) or CL_GUI_TIMER(using only a workprocess).

For the differences, refer to the below posts...

autorefresh dynpro with enque_sleep?

Auto Refresh Report

In fact, I cleared up a lot of facts and features about the similarities and differences between these two techniques, via these forums, with superbly informative replies from some of my favourite SDNers !

Regards,

Dushyant
Former Member
0 Kudos
Good blog. I have some doubts. How this type of programs will use in ABAP programs???

Why we using time to excuting programs???
dustyplanet
Active Participant
0 Kudos
Thank you Senthil...
For an example please refer to the comment below:
Earlier comment
Do let me know if you need more examples...

Regards,

Dushyant
Former Member
0 Kudos
Tested your eureka report. Wonderful.


Vijaya Chamundi
former_member188001
Active Participant
0 Kudos
Thanks mate. What a search you have done. I knew from beginning that you are such a person whom I can always look forward to. Although you may not consider yourself a GURU, but believe me as long as I do, you are definitely a guru.

You can mail me at vaidyasalil@yahoo.com

Regards,
Salil
Former Member
0 Kudos
Hi Dushyant

It was really a great piece of info to me. I dont know how much useful it in real time scenario. But I appreciate u for sharing this knowledge with us.

Hav a great day!
Jeeva
Former Member
0 Kudos
Its good blog

I dont have requirment as of now but its useful .