2012 Feb 24 9:32 AM
Hi,
I have created the following sample program for testing. And it seems like the call-back routine does not get triggered when I put in function call to execute external OS command. Can anyone confirm if it is indeed not possible to implement call-back with this type of scenario? Anyone has any alternatives?
Basically, the RFC-enabled function will act like a separate timer (a different dialog task run in the background). When time is up, it will execute the call-back routine in ZTEST. This routine can be used for further clean-up action, such as closing connections, releasing logical lock, etc.
report ztest .
p_maxrun type i.
start-of-selection.
call function 'z_timer'
starting new task destination 'NONE'
performing handle_timeout on end of task
exporting i_interval = p_max.
loop at itab.
perform ping_ip_address changing good.
if good <> 'X'.
continue.
endif.
endloop.
form handle_timeout.
message s000(38) 'timeout occured.'.
leave program.
endform.
form ping_ip_address.
call function 'SXPG_CALL_SYSTEM' to run external OS command "PING" on application server.
endform.
**************************************************
Function z_timer
*"----
""Local Interface:
*" IMPORTING
*" VALUE(I_INTERVAL) TYPE AVGTIM
*"----
wait up to i_interval.
Endfunction.
Hi,
I have created the following sample program for testing. And it seems like the call-back routine does not get triggered when I put in function call to execute external OS command. Can anyone confirm if it is indeed not possible to implement call-back with this type of scenario? Anyone has any alternatives?
Basically, the RFC-enabled function will act like a separate timer (a different dialog task run in the background). When time is up, it will execute the call-back routine in ZTEST. This routine can be used for further clean-up action, such as closing connections, releasing logical lock, etc.
report ztest .
p_maxrun type i.
start-of-selection.
call function 'z_timer'
starting new task destination 'NONE'
performing handle_timeout on end of task
exporting i_interval = p_max.
loop at itab.
perform ping_ip_address changing good.
if good <> 'X'.
continue.
endif.
endloop.
form handle_timeout.
message s000(38) 'timeout occured.'.
leave program.
endform.
form ping_ip_address.
call function 'SXPG_CALL_SYSTEM' to run external OS command "PING" on application server.
endform.
**************************************************
Function z_timer
*"----
""Local Interface:
*" IMPORTING
*" VALUE(I_INTERVAL) TYPE AVGTIM
*"----
wait up to i_interval.
Endfunction.
2012 Feb 24 9:54 AM
Hi,
please check this demo:
Program
REPORT ZSBAB008 NO STANDARD PAGE HEADING.
DATA: XV_SWITCH(1) TYPE N VALUE 1.
DATA: XV_ARCUS(3) TYPE N.
DATA: XV_SKIP(02) TYPE N.
DATA: XV_POS(02) TYPE N.
DATA: XV_BOGEN TYPE F.
CONSTANTS: PI TYPE F VALUE '3.1415926535897932'.
DATA: BEGIN OF XK_UFO,
L01(35) VALUE 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
L02(35) VALUE 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB',
L03(35) VALUE 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC',
L04(35) VALUE 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD',
L05(05) VALUE 'VVVVV',
END OF XK_UFO.
DATA: BEGIN OF XK_UFO2,
L01(35) VALUE 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
L02(35) VALUE 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
L03(35) VALUE 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
L04(35) VALUE 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
L05(05) VALUE 'WWWWW',
END OF XK_UFO2.
PARAMETERS: XP_WAIT LIKE SY-SPONR DEFAULT 1 no-display.
START-OF-SELECTION.
* Aufruf Warteschleife
CALL FUNCTION 'ZT_ENQUE_SLEEP'
STARTING NEW TASK 'WAIT'
PERFORMING FERTIG ON END OF TASK
EXPORTING
SECONDS = XP_WAIT
EXCEPTIONS
OTHERS = 1.
* Bild ausgeben
PERFORM AUSGABE.
************************************************************
AT USER-COMMAND.
************************************************************
* RESET User Idle Time
COMMIT WORK.
* Aufruf Warteschleife
CALL FUNCTION 'ZT_ENQUE_SLEEP'
STARTING NEW TASK 'WAIT'
PERFORMING FERTIG ON END OF TASK
EXPORTING
SECONDS = XP_WAIT
EXCEPTIONS
OTHERS = 1.
* Bild ausgeben
PERFORM AUSGABE.
*&---------------------------------------------------------------------*
*& Form FERTIG
*&---------------------------------------------------------------------*
* Ausgabe veranlassen
*----------------------------------------------------------------------*
* --> L_TASK Taskname
* <-- keine Ausgabeparameter
*----------------------------------------------------------------------*
FORM FERTIG USING L_TASK.
RECEIVE RESULTS FROM FUNCTION 'ENQUE_SLEEP'.
SET USER-COMMAND 'SHOW'.
ENDFORM. " FERTIGFM
FUNCTION ZT_ENQUE_SLEEP.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(SECONDS) LIKE SY-SPONR
*" EXCEPTIONS
*" SYSTEM_FAILURE
*"----------------------------------------------------------------------
CALL FUNCTION 'ENQUE_SLEEP'
EXPORTING
SECONDS = SECONDS
EXCEPTIONS
SYSTEM_FAILURE = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
RAISE SYSTEM_FAILURE.
ENDIF.
ENDFUNCTION.
Sorry, original output couldn't be shown in browser as a code ...
Regards,
Klaus
Edited by: Klaus Babl on Feb 24, 2012 11:00 AM
2012 Feb 27 7:22 AM
Hi Klaus,
Thank you for your reply. The sample code is pretty similar with what I have done on my own implementation. The only difference is your sample code did not call external OS command.
I have finally decided to give up implementing the call-back routine. As a workaround, I have to execute a function module, BP_JOB_ABORT, to terminate the background job instead.
Regards
Chong Wah
2012 Feb 27 7:25 AM
Call-back routine not implemented. But use function module BP_JOB_ABORT in the newly spawn task to terminate the background job instead. Not as ideal as the call-back routine approach, but it works.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |