SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Rings the bell on any PC, that has a sapgui connected to SAP



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Nov 18, 2007 8:28 pm    Post subject: Rings the bell on any PC, that has a sapgui connected to SAP Reply with quote

This ABAP rings the bell on any chosen pc, that has a sapgui connected to SAP

Code:
REPORT SAPLGRAP.
************************************************************************
* This program seds an audio alert to a specific user's frontend
* server. The program needs a pre-registered rfc program listening on
* every pc. The rfcexec can be started from the windows automatic
* startup like this:
* rfcexec -a100.100.100.100.rfcexec -ggatewayhostname -xsapgwXX
*                  ^                        ^
*            IP of the pc        IP of the gateway host
************************************************************************

* Get the terminal, that belongs to the user
start-of-selection.
  data: user value 'IMRE'.
  DATA: OPCODE TYPE X VALUE 2.
  DATA: BEGIN OF USR_TABL OCCURS 10.
          INCLUDE STRUCTURE UINFO.
  DATA: END OF USR_TABL.

  CALL 'ThUsrInfo' ID 'OPCODE' FIELD OPCODE
    ID 'TAB' FIELD USR_TABL-*SYS*.

* Get the corresponding IP address
  data: arp_command(30) value '/usr/sbin/arp',
        BEGIN OF TABL OCCURS 0,
        LINE(200),
        END OF TABL,
  ip_address(100).

  read table usr_tabl with key bname = 'IMRE'.
  if sy-subrc <> 0. write: 'There is no such a user logged in'.
  exit.endif.
  arp_command+14 = usr_tabl-term.
  CALL 'SYSTEM' ID 'COMMAND' FIELD arp_command
               ID 'TAB'     FIELD TABL-*SYS*.
  read table tabl index 1.
  shift tabl right up to ')'.
  shift tabl right deleting trailing ')'.
  shift tabl left up to '('.
  shift tabl left deleting leading '('.

* Get the systems that has been registered on the gateway.
  data: begin of connected_systems occurs 10.
          include structure GWY_SYSTEm.
  data: end of connected_systems.

  call function 'GWY_READ_CONNECTED_SYSTEMS'
  exporting
   gwhost = 'optima'
   gwserv = 'sapgw00'
  tables
   CONNECTED_SYSTEMS = CONNECTED_SYSTEMS.

* Get the registrated entry for the user's ip.
  data: host_string(40).

  loop at CONNECTED_SYSTEMS.
    if CONNECTED_SYSTEMS-ADDR1 = tabl and
       CONNECTED_SYSTEMS-SYSTYPE = 'REGISTER_TP'.
       host_string = CONNECTED_SYSTEMS-tpname.
      exit.
    endif.
  endloop.
  if host_string is initial. write: 'No registered RFC server'.
  exit.endif.

* Create a new destination in RFCDES
  tables: rfcdes.

  rfcdes-rfcdest = 'ZTTTT'.
  rfcdes-rfctype = 'T'.
  rfcdes-rfcoptions = 'H=%%RFCSERVER%%,N='.
  rfcdes-rfcoptions+19 = host_string.
  rfcdes-rfcoptions+59 = ','.
  condense rfcdes-rfcoptions NO-GAPS.
  modify rfcdes.
  if sy-subrc <> 0. write: 'Unsuccessfull modification'.
  exit. endif.
  commit work.

* Call the alert with the new destination
  DATA : BEGIN OF RET OCCURS 10,
          TEXT(80),
         END OF RET .
  data: command(256) value
        'sndrec32.exe /play /close c:/winnt/ringin.wav'.
  CALL FUNCTION 'RFC_REMOTE_EXEC' DESTINATION 'ZTTTT'
                                   EXPORTING
                                     COMMAND = COMMAND
                                   TABLES
                                     PIPEDATA = RET.

* Delete the rfc destination
  clear rfcdes.
  select single * from rfcdes where rfcdest = 'ZTTTT'.
  delete rfcdes.
  if sy-subrc <> 0. write: 'Unsuccessfull delete'.
  exit. endif.
  commit work.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.