‎2010 Sep 21 5:51 AM
Dear All,
We are working on a Weighbridge Interface scenario, where the weighbridge is sending data to a digitizer, which is connected to the COM port of a PC. The objective is to read the data from the digitizer, and display in a Module pool screen. However, there is one more requirement: the weight may fluctuate until it stabilizes, and the fluctuations have to be displayed on screen. For example, the tare weight of a vehicle may be 12.4 TON, but when the vehicle is standing on the weighbridge, the weight may vary from 10.4 to 12.4 TON. The idea is to capture the stable weight, so that any discrepancies can be avoided. In the current IT system implementation, the fluctuations in the weight are displayed. But using ABAP, can these fluctuations be captured? For example, we may design a screen containing a field for capturing the weight, and the weight displayed there automatically refreshes as soon as there is a change in the digitizer reading. Is this possible to achieve? If so, how?
Awaiting answers.
Thanks and Regards,
Sid
‎2010 Sep 21 8:13 AM
Hi Sid,
just a suggestion for the refreshing of an ABAP screen: you can use class CL_GUI_TIMER, but it only handles whole seconds, i.e. 1 second, 2 seconds and so on, but not 0.5 seconds...
An example of an ABAP listing could be the following:
*&---------------------------------------------------------------------*
*& Report ZZAVV001
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zzavv001 NO STANDARD PAGE HEADING.
CONSTANTS: c_yes(1) TYPE c VALUE 'X'.
DATA: BEGIN OF t_bseg OCCURS 0.
INCLUDE STRUCTURE bseg.
DATA: END OF t_bseg.
data: d_num_bkpf type i,
d_num_bseg type i.
PARAMETERS: interval TYPE i DEFAULT 5. "meaning 5 seconds
*----------------------------------------------------------------------*
* CLASS lcl_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_receiver DEFINITION
*----------------------------------------------------------------------*
* Global data
*----------------------------------------------------------------------*
DATA:
test TYPE i,
receiver TYPE REF TO lcl_receiver,
timer TYPE REF TO cl_gui_timer.
START-OF-SELECTION.
CREATE OBJECT timer.
CREATE OBJECT receiver.
SET HANDLER receiver->handle_finished FOR timer.
timer->interval = interval.
CALL METHOD timer->run.
PERFORM load_data. "or whatever you have to do to read the weight
PERFORM show_list. "or whatever you have to do to print the weight you've read
*----------------------------------------------------------------------*
* CLASS lcl_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_receiver IMPLEMENTATION.
METHOD handle_finished.
PERFORM carga_datos.
PERFORM muestra_listado.
CALL METHOD timer->run.
ENDMETHOD. "handle_finished
ENDCLASS. "lcl_receiver IMPLEMENTATION
*&---------------------------------------------------------------------*
*& Form load_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM load_data.
clear: d_num_bkpf,
d_num_bseg.
select single count( * )
into d_num_bkpf
from bkpf.
select single count( * )
into d_num_bseg
from bseg.
ENDFORM. "load_data
*&---------------------------------------------------------------------*
*& Form show_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM show_list.
*
get time.
skip to line 1.
position 1.
write: / 'Date / Time:', sy-datum, sy-uzeit.
write: / 'Number of BKPF records:', d_num_bkpf.
write: / 'Number of BSEG records:', d_num_bseg.
*
ENDFORM. " show_list
Okay, it's just a tiny code snippet, but I hope it may help you by designing auto-refreshing screens.
Kind regards,
Alvaro
‎2010 Sep 21 9:13 AM
You can use fm SAPGUI_SET_FUNCTIONCODE.
This module allows you to simulate user input (or rather to enforce user input) - in other words to make your program behave as if the user clicked some function (SY-UCOMM). You specify that user-clicked-function as the module parameter. Due to this simulated "user input " the next dialog step is preformed by the running program (PAI, PBO) which involves refreshing the screen.
So you can have a loop that contains yuor code reading the weight data and a call to this module - that should keep refreshing the screen until you exit from loop.
regards
‎2011 May 07 11:10 AM
Hi Alvaro and Maciej,
Sorry for the delayed reply. Your answers were really very helpful. Combining both the approaches, we could refresh the screen. Rewarded the answers.
Thanks for your inputs again.
Sincere Regards,
Sid