‎2011 Jan 05 1:43 PM
Hi,
My customer has a report listing invoices. A non-SAP program calls a remote function creating an invoice with BAPI. My customer wants the list to be refreshed after the invoice is created via RFC or to refresh the list in specified time intervals.
Is there any way to accomplish that task?
thanks,
‎2011 Jan 05 8:35 PM
Hi,
here is program example that will refresh PO numbers.
1/Auto refresh Program example
REPORT ZHHTEST02.
data: gt_ekko type table of ekko,
gs_ekko type ekko,
ok_code type syucomm.
start-of-selection.
SET USER-COMMAND 'REFRESH'.
ok_code = 'REFRESH'.
sy-ucomm = 'REFRESH'.
write:/.
end-of-SELECTION.
at user-command.
case ok_code.
when 'REFRESH'.
* Select current data
select * from ekko into table gt_ekko.
* Display data
sy-lsind = 0.
loop at gt_ekko into gs_ekko.
write:/ gs_ekko-ebeln.
endloop.
CALL FUNCTION 'YWAIT'
starting new task 'INFO' PERFORMING set_event ON END OF TASK
EXPORTING
ITIME = 10.
when others.
endcase.
FORM set_event using taskname.
SET USER-COMMAND 'REFRESH'.
ok_code = 'REFRESH'.
sy-ucomm = 'REFRESH'.
ENDFORM.
2/Wait function, it has to be set up as RFC
FUNCTION YWAIT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(ITIME) TYPE IDAT00 OPTIONAL
*"----------------------------------------------------------------------
wait up to ITIME seconds.
ENDFUNCTION.Thank you
Jan
‎2011 Jan 05 8:35 PM
Hi,
here is program example that will refresh PO numbers.
1/Auto refresh Program example
REPORT ZHHTEST02.
data: gt_ekko type table of ekko,
gs_ekko type ekko,
ok_code type syucomm.
start-of-selection.
SET USER-COMMAND 'REFRESH'.
ok_code = 'REFRESH'.
sy-ucomm = 'REFRESH'.
write:/.
end-of-SELECTION.
at user-command.
case ok_code.
when 'REFRESH'.
* Select current data
select * from ekko into table gt_ekko.
* Display data
sy-lsind = 0.
loop at gt_ekko into gs_ekko.
write:/ gs_ekko-ebeln.
endloop.
CALL FUNCTION 'YWAIT'
starting new task 'INFO' PERFORMING set_event ON END OF TASK
EXPORTING
ITIME = 10.
when others.
endcase.
FORM set_event using taskname.
SET USER-COMMAND 'REFRESH'.
ok_code = 'REFRESH'.
sy-ucomm = 'REFRESH'.
ENDFORM.
2/Wait function, it has to be set up as RFC
FUNCTION YWAIT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(ITIME) TYPE IDAT00 OPTIONAL
*"----------------------------------------------------------------------
wait up to ITIME seconds.
ENDFUNCTION.Thank you
Jan
‎2011 Jan 05 11:14 PM
... or OO, integrate like this
DATA: ok_code LIKE sy-ucomm.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: on_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_event_handler DEFINITION
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_finished.
* Start Timer again
gr_gui_timer->interval = pa_autow.
CALL METHOD gr_gui_timer->run.
* cause PAI
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = gc_cmd_refresh.
ENDMETHOD. "on_finished
DATA:
gr_gui_timer TYPE REF TO cl_gui_timer,
gr_event_handler TYPE REF TO lcl_event_handler,
gs_vtyp like ts_vtyp.
*======================================================================*
*= Selection screen =*
*======================================================================*
PARAMETERS:
pa_autow TYPE flag DEFAULT 'X'.
* ...
SELECTION-SCREEN END OF BLOCK date.
*&---------------------------------------------------------------------*
*& Form init_autorefresh
*&---------------------------------------------------------------------*
* Timer starten oder stoppen
*&---------------------------------------------------------------------*
FORM init_autorefresh .
IF pa_autow IS NOT INITIAL.
CREATE OBJECT gr_gui_timer.
SET HANDLER gr_event_handler->on_finished FOR gr_gui_timer.
gr_gui_timer->interval = pa_autow.
CALL METHOD gr_gui_timer->run.
ELSEIF gr_gui_timer IS BOUND.
gr_gui_timer->cancel( ).
ENDIF.
ENDFORM. " init_autorefreshRegards,
Clemens
‎2011 Jan 06 6:41 AM
thanks for your reply Jan,
I have focused on a solution that will trigger and handle a static event. The solution did not work
the alternative solution was using asynchronous function call as you mentioned. I wonder whether the WAIT statement will lead to poor system performance because there is ~250 users running the same program. Please let me know if you have experienced any performance problems.
If a performance problem arise I will set the WAIT paremeter to 1 second and make the list refresh when a new record is available.
- ferudun
‎2011 Jan 06 6:47 AM
thanks for your reply,
As I replied to Jan my first focus was on a solution that will trigger and handle a static event. I have intended to fire a static event within the function creating the invoice and handle the event in the report pragram. The solution did not work.
- ferudun
‎2011 Jan 06 7:28 AM
Hi,
when you are selecting data from database:
I/Database have timestamp(creation time)
1/use database timestamp.
get parameter id 'ZERZET' field lv_erzet.
********First select
if lv_erzet is initial.
lv_erzet0 = sy-uzeit.
select * from vbak into table gt_vbak.
else.
*****Following selects
lv_erzet0 = sy-uzeit.
select * from vbak appending table gt_vbak
where erzet GE lv_erzet.
endif.
lv_erzet. = lv_erzet0.
set parameter id 'ZERZET' field lv_erzet.
sort gt_vbak by vbeln.
delete adjacent duplicates from gt_vbak comparing vbeln.
II/If db doesn't have timestamp, create custom field with time stamp and in user exit for transaction populate creation date and use same technique in chapter I/
Thank you
Jan
.
1/Save in memory id previous time of select just append new records
Edited by: Jan Hoblik on Jan 5, 2011 11:31 PM
‎2011 Jan 06 8:45 AM
Hi Ferudun,
don't worry: The WAIT (as the use of CL_GUI_TIMER) will not affect system performance. On unix infrastructure it will suspend the calling process and use no resources.
But you should be aware that this interruption causes an implicit database commit. That means if you have done any updates/inserts they can not be rolled back anymore. I don't know if this applies to your program, if not, just ignore it.
Regards,
Clemens