Application Development 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: 

Raise event asynchron

Former Member
0 Kudos

Hi

I would like to inform a transaction, which runs in forground on frontend everytime a new delivery is created in the system (in the end it is an alv grid with all open deliveries and I would like to trigger an automatic refresh).

I tried to create a object and pass into a FM to trigger an event from the FM, but this is not allowed.

Any ideas how this could be solved.

Thanks

Rene

1 ACCEPTED SOLUTION

mandar_shete
Active Participant
0 Kudos

Hi,

You can get some idea from following code for your requirment

report ZTEST_MSS.
*REPORT ZAUTO_REFRESH .
DATA: G_INIT_ONCE,
      OK_CODE(20),
      G_REF_FROM_TIMER.

DATA: BEGIN OF ITAB OCCURS 0,
        CARRID TYPE SPFLI-CARRID,
        CONNID TYPE SPFLI-CONNID,
        COUNTRYFR TYPE SPFLI-COUNTRYFR,
        CITYFROM TYPE SPFLI-CITYFROM,
        AIRPFROM TYPE SPFLI-AIRPFROM,
        COUNTRYTO TYPE SPFLI-COUNTRYTO,
        CITYTO TYPE SPFLI-CITYTO,
        AIRPTO TYPE SPFLI-AIRPTO,
        FLTIME TYPE SPFLI-FLTIME,
        DEPTIME TYPE SPFLI-DEPTIME,
        ARRTIME TYPE SPFLI-ARRTIME,
        DISTANCE TYPE SPFLI-DISTANCE,
        DISTID TYPE SPFLI-DISTID,
        FLTYPE TYPE SPFLI-FLTYPE,
        PERIOD TYPE SPFLI-PERIOD,
      END OF ITAB.


IF G_INIT_ONCE <> 'X'.
  G_INIT_ONCE = 'X'.
  CALL FUNCTION 'Z_ENQUE_SLEEP'
     STARTING NEW TASK 'WAIT'
     PERFORMING WHEN_FINISHED ON END OF TASK.

ENDIF.

WRITE:/ 'wait for 10 sec....'.

AT USER-COMMAND.
  CASE OK_CODE.
    WHEN 'FCT_R'.
      SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE ITAB.
      WRITE:/ SY-UZEIT.
      LOOP AT ITAB.
        WRITE:/ ITAB-CARRID,ITAB-CONNID.
      ENDLOOP.
      SY-LSIND = 0.
      IF G_REF_FROM_TIMER = 'X'.

        CALL FUNCTION 'Z_ENQUE_SLEEP'
          STARTING NEW TASK 'INFO'
          PERFORMING WHEN_FINISHED ON END OF TASK.

        G_REF_FROM_TIMER = ''.
      ENDIF.
  ENDCASE.


*---------------------------------------------------------------------*
*       FORM WHEN_FINISHED                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  TASKNAME                                                      *
*---------------------------------------------------------------------*
FORM WHEN_FINISHED USING TASKNAME.
  RECEIVE RESULTS FROM FUNCTION 'Z_ENQUE_SLEEP'.

  G_REF_FROM_TIMER = 'X'.

* Trigger an event to run the at user-command
  SET USER-COMMAND 'FCT_R'.
  OK_CODE = 'FCT_R'.
  SY-UCOMM = 'FCT_R'.

ENDFORM.                    " WHEN_FINISHED

*************************************************************************


FUNCTION Z_ENQUE_SLEEP.
*"----------------------------------------------------------------------
*"*"Local interface:
*"----------------------------------------------------------------------


CALL FUNCTION 'ENQUE_SLEEP'
          EXPORTING
           SECONDS = 10.


ENDFUNCTION.

2 REPLIES 2

mandar_shete
Active Participant
0 Kudos

Hi,

You can get some idea from following code for your requirment

report ZTEST_MSS.
*REPORT ZAUTO_REFRESH .
DATA: G_INIT_ONCE,
      OK_CODE(20),
      G_REF_FROM_TIMER.

DATA: BEGIN OF ITAB OCCURS 0,
        CARRID TYPE SPFLI-CARRID,
        CONNID TYPE SPFLI-CONNID,
        COUNTRYFR TYPE SPFLI-COUNTRYFR,
        CITYFROM TYPE SPFLI-CITYFROM,
        AIRPFROM TYPE SPFLI-AIRPFROM,
        COUNTRYTO TYPE SPFLI-COUNTRYTO,
        CITYTO TYPE SPFLI-CITYTO,
        AIRPTO TYPE SPFLI-AIRPTO,
        FLTIME TYPE SPFLI-FLTIME,
        DEPTIME TYPE SPFLI-DEPTIME,
        ARRTIME TYPE SPFLI-ARRTIME,
        DISTANCE TYPE SPFLI-DISTANCE,
        DISTID TYPE SPFLI-DISTID,
        FLTYPE TYPE SPFLI-FLTYPE,
        PERIOD TYPE SPFLI-PERIOD,
      END OF ITAB.


IF G_INIT_ONCE <> 'X'.
  G_INIT_ONCE = 'X'.
  CALL FUNCTION 'Z_ENQUE_SLEEP'
     STARTING NEW TASK 'WAIT'
     PERFORMING WHEN_FINISHED ON END OF TASK.

ENDIF.

WRITE:/ 'wait for 10 sec....'.

AT USER-COMMAND.
  CASE OK_CODE.
    WHEN 'FCT_R'.
      SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE ITAB.
      WRITE:/ SY-UZEIT.
      LOOP AT ITAB.
        WRITE:/ ITAB-CARRID,ITAB-CONNID.
      ENDLOOP.
      SY-LSIND = 0.
      IF G_REF_FROM_TIMER = 'X'.

        CALL FUNCTION 'Z_ENQUE_SLEEP'
          STARTING NEW TASK 'INFO'
          PERFORMING WHEN_FINISHED ON END OF TASK.

        G_REF_FROM_TIMER = ''.
      ENDIF.
  ENDCASE.


*---------------------------------------------------------------------*
*       FORM WHEN_FINISHED                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  TASKNAME                                                      *
*---------------------------------------------------------------------*
FORM WHEN_FINISHED USING TASKNAME.
  RECEIVE RESULTS FROM FUNCTION 'Z_ENQUE_SLEEP'.

  G_REF_FROM_TIMER = 'X'.

* Trigger an event to run the at user-command
  SET USER-COMMAND 'FCT_R'.
  OK_CODE = 'FCT_R'.
  SY-UCOMM = 'FCT_R'.

ENDFORM.                    " WHEN_FINISHED

*************************************************************************


FUNCTION Z_ENQUE_SLEEP.
*"----------------------------------------------------------------------
*"*"Local interface:
*"----------------------------------------------------------------------


CALL FUNCTION 'ENQUE_SLEEP'
          EXPORTING
           SECONDS = 10.


ENDFUNCTION.

Former Member
0 Kudos

Hi

Thanks. I did a first test and it looks great. I will do a bit more and then I will let you know.

Thanks

Rene