Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Timed Out Exception

Former Member
0 Likes
383

hi,

i have to capture time_out exception in my code......How to do that.....also what is the class name for time_out exception

2 REPLIES 2
Read only

Former Member
0 Likes
349

Hi Nishu,

CL_GUI_TIMER caters to your requirement.

Please find the code below...

report z_refresh_test.

----


  • CLASS lcl_gui_timer DEFINITION

----


  • ........ *

----


class lcl_gui_timer definition inheriting from cl_gui_control.

public section.

constants: eventid_finished type i value 1 .

class-data: interval type i value '0'.

events: finished .

methods:

cancel

exceptions

error,

constructor

importing

lifetime type i optional

value(shellstyle) type i optional

value(parent) type ref to cl_gui_container optional

exceptions

error,

run

exceptions

error,

dispatch redefinition.

endclass.

----


  • CLASS lcl_event_handler DEFINITION

----


  • ........ *

----


class lcl_event_handler definition.

public section.

class-methods:

on_finished

for event finished of lcl_gui_timer.

endclass.

data: gui_timer type ref to lcl_gui_timer.

data: event_handler type ref to lcl_event_handler.

data: timeout_interval type i value '3'.

parameters:

p_datum type sy-datum,

p_uzeit type sy-uzeit.

at selection-screen output.

p_datum = sy-datum.

p_uzeit = sy-uzeit.

Create Object Gui_Timer.

set handler event_handler->on_finished for gui_timer.

gui_timer->interval = timeout_interval.

call method gui_timer->run.

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


  • ........ *

----


class lcl_event_handler implementation.

method on_finished.

  • Start Timer again

gui_timer->interval = timeout_interval.

call method gui_timer->run.

  • cause PAI

call method cl_gui_cfw=>set_new_ok_code

exporting

new_code = 'REFR'.

endmethod.

endclass.

----


  • CLASS lcl_gui_timer IMPLEMENTATION

----


  • ........ *

----


class lcl_gui_timer implementation.

method constructor.

type-pools: sfes.

data clsid(80).

data event_tab type cntl_simple_events.

data event_tab_line type cntl_simple_event.

if clsid is initial.

data: return,

guitype type i.

guitype = 0.

call function 'GUI_HAS_OBJECTS'

exporting

object_model = sfes_obj_activex

importing

return = return

exceptions

others = 1.

if sy-subrc ne 0.

raise error.

endif.

if return = 'X'.

guitype = 1.

endif.

if guitype = 0.

call function 'GUI_HAS_OBJECTS'

exporting

object_model = sfes_obj_javabeans

importing

return = return

exceptions

others = 1.

if sy-subrc ne 0.

raise error.

endif.

if return = 'X'.

guitype = 2.

endif.

endif.

case guitype.

when 1.

clsid = 'Sapgui.InfoCtrl.1'.

when 2.

clsid = 'com.sap.components.controls.sapImage.SapImage'.

endcase.

endif.

call method super->constructor

exporting

clsid = clsid

shellstyle = 0

parent = cl_gui_container=>default_screen

autoalign = space

exceptions others = 1.

if sy-subrc ne 0.

raise error.

endif.

call method cl_gui_cfw=>subscribe

exporting

shellid = h_control-shellid

ref = me

exceptions others = 1.

if sy-subrc ne 0.

raise error.

endif.

  • Register the events

event_tab_line-eventid = lcl_gui_timer=>eventid_finished.

append event_tab_line to event_tab.

call method set_registered_events

exporting

events = event_tab.

endmethod.

method cancel.

call method call_method

exporting

method = 'SetTimer'

p_count = 1

p1 = -1

queue_only = 'X'

exceptions others = 1.

if sy-subrc ne 0.

raise error.

endif.

endmethod.

method run.

call method call_method

exporting

method = 'SetTimer'

p_count = 1

p1 = interval

queue_only = 'X'

exceptions others = 1.

if sy-subrc ne 0.

raise error.

endif.

endmethod.

method dispatch .

case eventid.

when eventid_finished.

raise event finished.

endcase.

endmethod.

endclass.

Regards,

Younus

<b>Reward Helpful Answers!!!!!</b>

Read only

Former Member
0 Likes
349

To avoid Time Out short-dump, you can simply create a piece of code in which you can raise a commit on-request.

Check out:

CONSTANTS: cw_counter_limit TYPE I VALUE '50'. "or what you want
DATA: cw_counter TYPE i.

Try to check out if your program has a main cycle (as LOOP, or DO) which is the greater bottleneck.

Immediately after the LOOP statement, put this:

cw_counter = cw_counter + 1.

IF cw_counter EQ cw_counter_limit.
cw_counter = 0.
COMMIT WORK.
ENDIF.

This will release all the locks, and clears to 0 the time of a workprocess. You will not fail in a Timed_Out exception anymore.

Hope this helps,

Roby.