Register Login

Check if your SAP servers are alive from the Command Prompt

Updated May 18, 2018

This is a very useful tip that can help you check if an SAP R/3 server is up and running. This way, you don’t have to log on to the system just to find out.
Additionally, you can create another script that uses the FOR command to check ALL your servers so you don’t have to check one by one. Have the script do the job for you.

The key to this script is the command SAPINFO.exe, which comes on the SAPFrontEnd CD (SAPGUI). It’s part of the SDK. If you don’t have the file, e-mail me and I’ll send it to you.

The syntax of SAPINFO is:
sapinfo ashost=host sysnr=nn

When used in a batch file (.bat or .cmd) you can check the errorlevel returned by the program. If it is 1 then the system is not up and running.

My script below first checks if the system is on the network by ‘pinging’ it and expecting a reply.

If you want to check all your systems, then create another script (example: checkallrfcs.bat) and use this command:

FOR /F %%i in (SAPsystems.txt) do call checkrfc %%i 00

The command above reads the file SAPsystems.txt, which should have a list of all the servers (one server name per line) and then it invokes the script ‘checkrfc’ passing the server name as a parameter. The 00 indicates the instance number.

I believe you will find it extremely useful and it will save you tons of time.
Now, you can just run the script, sit back and watch it report the status of the systems.

Script code:

@echo off
rem ======================================================================
rem Script: CheckRFC.BAT
rem It uses SAPINFO from the RFC-SDK (SAPGUI) to check an RFC destination.
rem It needs two parameters: 1. Hostname 2. Instance Number
rem A ping is sent to the host. If successful an RFC check is carried out.
rem By: Giovanni Davila
rem ======================================================================

if “%2″==”" goto NoParameter
echo Pinging %1 …
ping %1 -n 2 | find /i “reply” >nul && goto CheckRFC
echo System does not exist on the network! & goto Bye

:CheckRFC
sapinfo ashost=%1 sysnr=%2 & if errorlevel 1 goto System_Down
echo —————————-
echo System is up. RFC checks OK!
echo —————————-
goto Bye

:System_Down
echo —————
echo System is down!
echo —————
goto Bye

:NoParameter
echo ———————————————-
echo You did not specify at least one parameter!
echo Syntax: checkrfc “hostname” “instance number”
echo Example: checkrfc mydev 00
echo ———————————————-

:Bye


Comments

  • 26 Dec 2012 9:41 am Chetan Sutar
    as i read the above script it's with network ping ...wat abt the sap server
    if server is up u will get ping and not for dispatcher up
  • 21 Apr 2015 6:10 pm Guest

    Where from  variable %1 and %2 is passed.


×