You are on page 1of 12

Author: Manish Kumar

SAP Basis Consultant

Page 1 of 12
TABLE OF CONTENTS

1. Document Overview ............................................................................................................................ 3


2. Objective ............................................................................................................................................... 3
3. Requirements ....................................................................................................................................... 3
4. Flow Diagram ........................................................................................................................................ 4
5. User Creation to run the script from Control-M ................................................................................. 5
6. Script creation ...................................................................................................................................... 6
6.1 Required Executables for Script Preparation .............................................................................. 6
6.2 System stop scripts ....................................................................................................................... 7
6.3 System start scripts ...................................................................................................................... 8
7. Scheduling through Control-M agent ................................................................................................ 10
8. Conclusion: ......................................................................................................................................... 11
9. References: ......................................................................................................................................... 11
For Feedback ............................................................................................................................................... 12
About Accenture ......................................................................................................................................... 12

Page 2 of 12
1. Document Overview
This document gives the brief idea on Automating SAP System Start and Stop activity for SAP Application
running on Windows server using Control-M Agent.

2. Objective
SAP system Start and Stop is the most commonly and frequently used task in SAP Basis Administration.
In almost every project the common activity is monthly OS Patching and in some of big projects the
number of Servers are even more. So manually starting and stopping of SAP system in a tight schedule is
a challenging task to perform. In that case automating Start and Stop will reduce so much effort and
time. One other instance is sometimes for the system running on Azure SAP MMC fails to launch due to
some sever issue then without launching SAP MMC using Start and Stop scripts, Start/Stop activity can
be achieved easily. One instance where we are using this automation in our project is as the developers
do not work during off business hours so keeping the servers up during off business hours is waste of
resources. So, every day after business hours the Non-prod systems and Servers go down post business
hours and come up before business logins. By using automation, we save hours of effort daily which
could have been incurred just for Starting and Stopping of SAP System.

This automation is very efficient and can be used anywhere in SAP Basis administration which requires
System Start and Stop.

3. Requirements
For Scheduling SAP Start and Stop automation on Windows Server using Control-M we need Control-M
agent to be installed on those servers. The Start and Stop Jobs can be scheduled on the Control-M agent
which will trigger the Start and Stop Jobs Scripts placed on the SAP server.

For example if we want to Schedule Start and Stop of SAP System “SID” hosted on windows server
“sid-np-db01” with Database SQL Server named “SID” hosted on same server. As a sample, below will be
the required details:

Details Value
System Name/Database Name SID
Windows Server Name sid-np-db01
Control-M User ctladmin
Script path C:\Program Files\SAP\hostctrl\scripts
Start Job Script sid-np-db01_SID_Start.BAT
Stop Job Script sid-np-db01_SID_Stop.BAT
DB start/stop log location C:\Program Files\SAP\hostctrl\Script_DB_Log
SAP start/stop log location C:\Program Files\SAP\hostctrl\script_log

Page 3 of 12
4. Flow Diagram
SAP System “SID”
installed on Server
“sid-np-db01”

Control-M agent to be installed


on Server “sid-np-db01”

User “ctladmin” to be created both


in OS & DB (MS SQL server) with
admin rights

Both Start/Stop Scripts Prepared and


placed on the server “sid-np-db01” at a
specific location

This will run the Windows Batch file containing Stop


If stop Job triggers Script and will stop instances in below sequence:
Start/Stop Job
triggered 1. Stop Application instance/CI
through 2. Stop Message Server
ControlM 3. Stop SQL Database services

If start Job triggers

Once all the instances are stopped. Output


This will run the Windows Batch file containing Start will be displayed on Control-M agent and
Script and will start instances in below sequence: incase of Job failure the output will be send
to the DL mentioned in agent.
1. Start SQL Database Services
2. Start Message Server
3. Start Application instance/CI

End of Stop
Job
Once all the instances are started. Output
will be displayed on Control-M agent and
incase of Job failure the output will be send
to the DL mentioned in agent.

End of Start
Job
Page 4 of 12
5. User Creation to run the script from Control-M
Create OS user “ctladmin” in the OS and add it to the Administrators group. So that it will have admin
rights to perform the required operation. Below screenshot shows the access control that administrator
user has:

Page 5 of 12
6. Script creation
Scripts can be placed at any location in the server. In our case the scripts Batch files and logs directory
where the Start/Stop logs will be written are at below locations.

Start Script: C:\Program Files\SAP\hostctrl\scripts\sid-np-db01_SID_Start.BAT


Stop Script: C:\Program Files\SAP\hostctrl\scripts\sid-np-db01_SID_Stop.BAT
SAP start Logs: C:\Program Files\SAP\hostctrl\script_log\StartInstance.log
SAP stop Logs: C:\Program Files\SAP\hostctrl\script_log\StopInstance.log
DB start Logs: C:\Program Files\SAP\hostctrl\Script_DB_Log\StartInstance.log
DB stop Logs: C:\Program Files\SAP\hostctrl\Script_DB_Log\StopInstance.log

6.1 Required Executables for Script Preparation

For preparation of both Start and Stop Script we need the below details:

• Path for Kernel executables of that System.


• Hostname of the instance (both the Application/CI Instance and the message server).
Central Instance HostName: cbsidci
ASCS HostName: cbsidascs
• Instance Number
Central Instance Number: 00
ASCS Instance Number: 01

Page 6 of 12
In our case, for preparing the Start and Stop Script for System “SID” below is the location for Kernel
executables:

Kernel Path: E:\usr\sap\SID\SYS\exe\uc\NTAMD64"

6.2 System stop scripts

For the above-mentioned System details the Stop Job will be as below:

Script Name: sid-np-db01_SID_Stop.BAT

Content:

set CMD_PATH="E:\usr\sap\SID\SYS\exe\uc\NTAMD64"

cd %CMD_PATH%

"E:\usr\sap\SID\SYS\exe\uc\NTAMD64\stopsap" SID nr=00 SAPDIAHOST=cbsidci > "C:\Program


Files\SAP\hostctrl\script_log\StopInstance.log"

"E:\usr\sap\SID\SYS\exe\uc\NTAMD64\stopsap" SID nr=01 SAPDIAHOST=cbsidascs > "C:\Program


Files\SAP\hostctrl\script_log\StopInstance.log"

net stop SQLAgent$SID > "C:\Program Files\SAP\hostctrl\Script_DB_Log\StopInstance.log"

net stop MSSQL$SID > "C:\Program Files\SAP\hostctrl\Script_DB_Log\StopInstance.log"

Page 7 of 12
When the Stop Script is triggered, it will run as follows:

• Set command will first set the path of Kernel executable and then change the directory to that
executable path.
• CI will stop first as per the command with hostname cbsidci.
• ASCS will stop after CI.
• Then at last SQL services will stop.
• No need to set the delay as the next line command will run after the previous line command has
finished its Job.

6.3 System start scripts

For the above-mentioned System details the Stop Job will be as below:

Script Name: sid-np-db01_SID_Start.BAT

Content:

net start MSSQL$SID > "C:\Program Files\SAP\hostctrl\Script_DB_Log\StartInstance.log"

net start SQLAgent$SID > "C:\Program Files\SAP\hostctrl\Script_DB_Log\StartInstance.log"

set CMD_PATH="E:\usr\sap\SID\SYS\exe\uc\NTAMD64"

cd %CMD_PATH%

"E:\usr\sap\SID\SYS\exe\uc\NTAMD64\startsap" SID nr=01 SAPDIAHOST=cbsidascs > "C:\Program


Files\SAP\hostctrl\script_log\StartInstance.log"

"E:\usr\sap\SID\SYS\exe\uc\NTAMD64\startsap" D0H nr=00 SAPDIAHOST=cbsidci > "C:\Program


Files\SAP\hostctrl\script_log\StartInstance.log"

Page 8 of 12
When the Start Script is triggered, it will run as follows:

• First, it will start the SQL Services.


• Then set command will first set the path of Kernel executable and then change the directory to
that executable path.
• ASCS will be started first.
• Then at last CI/Application instance will be started.
• No need to set the delay as the next line command will run after the previous line command has
finished its Job.

Once the Scripts windows batch files are prepared, these are ready to use, and the batch files can be
scheduled and triggered using any scheduler. For testing purpose these batch files could be just run by
double clicking on the scripts and the System will Start and Stop as per the Script.

In our scenario for Stopping the System during Off business hours and starting of systems before
business starts, we are scheduling the start and stop jobs through Control-M agent.

Page 9 of 12
7. Scheduling through Control-M agent

We have different options to use above created scripts for automating the SAP system start stop
activity. In our case we are scheduling it on Control-M agent to run the batch files as per schedule.

We will just provide the Server Name, Path where the Script batch files are placed and schedule both
the Start and Stop Job as per the required Schedule on Control-M

Below is Snapshot of Control-M where the Script details needs to be provided.

Page 10 of 12
8. Conclusion:

This document throws light on the Automation of SAP system Start and Stop activity for the SAP
applications running on Windows Server using Windows batch file with the help of Control-M agent. This
document explains how easily the Scripts can be prepared by providing minimum unique details of the
SAP system and the Start/Stop activity can be automated thus by reducing so much of human effort. This
can be more useful and economical in projects where the number of SAP systems are more, and multiple
System needs to be stopped and started at a certain time.

Below are some of the benefits that can be achieved by Automating Start/Stop on Windows Azure:

• Noncritical SAP Systems and Servers can be snoozed during the off-business hours which are
not in use during that time thus by saving considerable cost on daily basis.
• During Monthly patching where many systems needs to be stopped at a time. This could be
achieved with less resource and effort by using Start/Stop Automation.
• In Windows Azure Cloud, sometimes when Server crashes and SAP Management Console is
unable to launch, we can perform the Start and Stop activity using the Script gracefully.

9. References:

https://help.sap.com/saphelp_tm80/helpdata/en/47/1d6feeff6e0d46e10000000a155369/content.htm?
no_cache=true

https://communities.bmc.com/docs/DOC-59263

https://blogs.sap.com/2019/11/04/automatic-snoozing-of-sap-systems-on-azure/

Page 11 of 12
For Feedback
For any kind of feedback on this document, contact: manishk212@gmail.com

About Author
Manish Kumar is an SAP Basis Consultant with 4 Years of Experience which includes working
in SAP Basis Administration, SAP Upgrades, SAP Migration projects, Certified in Microsoft
Azure Fundamentals. Currently working as Software Development Senior Analyst in Accenture,
India.

Page 12 of 12

You might also like