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,
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!
Recently, in an ABAP class, a curious and enthusiastic student(aren’t they all?) asked me if it was possible toautomatically 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…
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…
ankara rus escort
istanbul rus escort
istanbul rus Escort
CLASS lcl_handler DEFINITION.
METHODS: when_done FOR EVENT finished OF cl_gui_timer.
CLASS lcl_handler IMPLEMENTATION.
cl_gui_cfw=>set_new_ok_code( new_code = 'ONLI' ). "ONLI = Execute
TABLES: spfli, sscrfields.
PARAMETERS: pa_carr TYPE s_carrid DEFAULT 'AA'.
DATA: timer TYPE REF TO cl_gui_timer.
DATA: href TYPE REF TO lcl_handler.
AT SELECTION-SCREEN OUTPUT.
*Create the timer as well as the handler
CREATE OBJECT: timer, href.
*Register event handler
SET HANDLER href->when_done FOR timer.
*Set value according to your requirement
timer->interval = 10.
*Start timer timer->run( ).
*Stop Timer once list processing begins
SELECT * FROM spfli WHERE carrid = pa_carr.
WRITE:/ spfli-connid, spfli-cityfrom.
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!
[This is cross-posted from my blog at SAP Developers(or Community) Network athttp://scn.sap.com/people/dushyant.shetty/blog]