ABAP code outside repository and monitoring script

With external program RFC2ABAP (delivery with SAPGUI, option RFCDSK) you can execute an ABAP from a text file directly.

With the external program RFC2ABAP (delivery with SAPGUI, option RFCDSK) you can execute an ABAP directly from a text file. This tool first creates a connection with the system and then performs the execution by ABAP system processor. Obviously, it is not necessary to create the program through Workbench. You can also improve your administration scripts substantially. As an example, you can look my monitoring SAP system script below...

(the rz20 is more complete of course):


Follow the short instructions:

1. Write the following ABAP source under: mon.ab4 text file in your workstation disc, next to RFC2ABAP tool (same directory).

REPORT ZDCJP002.

DATA: SERVERNAME      LIKE SPFID-APSERVER.
DATA: MSGSERVER LIKE MSXXLIST-NAME VALUE 'MSGSERVER'.
DATA: BEGIN OF INTG_TBL OCCURS 100.
      INCLUDE STRUCTURE SALSTINTG.
DATA: END OF INTG_TBL.

DATA: BEGIN OF GZ_STATE_TBL OCCURS 0,
        APSERVER      LIKE SPFID-APSERVER,
        ANSWTIME      TYPE I,
        USERNR        TYPE I,
        TAFREQ        TYPE I,
        UZEIT         LIKE SY-UZEIT,
      END   OF GZ_STATE_TBL .


  REFRESH GZ_STATE_TBL .

  REFRESH INTG_TBL.
  CALL FUNCTION 'RZL_STRG_READALL_I'
       EXPORTING
            SRVNAME       = MSGSERVER
       TABLES
            INTG_TBL      = INTG_TBL
       EXCEPTIONS
            OTHERS        = 01.
 LOOP AT INTG_TBL WHERE VALUE1 = 7353.
* LOOP AT INTG_TBL WHERE VALUE1 = 7353 AND VALUE5 = 3537.
   GZ_STATE_TBL-APSERVER = INTG_TBL-NAME.
   GZ_STATE_TBL-ANSWTIME = INTG_TBL-VALUE2.
   GZ_STATE_TBL-TAFREQ = INTG_TBL-VALUE3.
   GZ_STATE_TBL-USERNR = INTG_TBL-VALUE4.
   GZ_STATE_TBL-UZEIT = INTG_TBL-VALUE.
   APPEND GZ_STATE_TBL .
  ENDLOOP.


   WRITE: / SY-VLINE, (20) 'Instancia'(016),
             SY-VLINE, (10) 'Usuarios'(017),
             SY-VLINE, (13) 'Resp.time/ms'(020),
             SY-VLINE, (10) 'Events/min'(019),
             SY-VLINE,  (8) 'Sample'(020),
             SY-VLINE.
  ULINE: /(77).
                             .
  LOOP AT GZ_STATE_TBL .
      WRITE: / SY-VLINE, (20) GZ_STATE_TBL-APSERVER ,
               SY-VLINE, (10) GZ_STATE_TBL-USERNR ,
               SY-VLINE, (13) GZ_STATE_TBL-ANSWTIME ,
               SY-VLINE, (10) GZ_STATE_TBL-TAFREQ ,
               SY-VLINE,  (8) GZ_STATE_TBL-UZEIT USING EDIT MASK
   '__:__:__',
    SY-VLINE.
  ENDLOOP.
ULINE: /(77).

2. Write the following Perl Script, next to RFC2ABAP:

#!/usr/bin/perl
### Juan Pablo de Coustillas 29.05.2002
### Monitor.pl
### Monitor use RFC2ABAP
### Allow monitor states of  SAP systems
### systems.txt have the conection SAP data:
### host,user,password,client

###PATH where system.txt is located
$sapfile="systems.txt";
###PATH where RFC2ABAP is located
$rfc2abap="RFC2ABAP"; 

#----------- Check files
if ( ! -f "$sapfile" ) {
   die "cannot open systems.txt file";
}

#---------- Perfom loop to call RFC2ABAP
if (open(SYSTEM, "< $sapfile")) {

  while (my $access = 
 
  ){
   chop($access);
   ($host, $user, $password, $client) = 
           split(",", "$access");
   $command =       
  "RFC2ABAP -h $host -s 00  -c $client 
   -u $user -p $password -f mon.ab4 
   -g $host -x sapgw00";
   print `$command`;
   }

  close(SYSTEM);
}
 

3. Write the file system.txt next to perl script with the following information:

hostname,username,password,client

Ej:

SAPPRD,Ad0009,099911,100
SAPDEV,Ad0009,099911,100
SAPQUA,Ad0009,099911,100
SAPBWD,Ad0009,099911,100
SAPBWP,Ad0009,099911,100

4. Execute the script. It writes the amount of connected users by terminal, response time, event per second, etc per server.

If you don't have a perl interpreter handy, you can perform ABAP code with the following shell command:

RFC2ABAP -h hostname -s 00 -c Cient -u Username -p password -f mon.ab4 -g hostname -x sapgw00

This was first published in June 2002

Dig deeper on SAP ABAP

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close