Notes on SAPJ2EE

Hi All,

Today I’m going to share my notes on SAPJ2EE. Hopefully it will bring some useful information for those who read.

documentation: http://<host&gt;:50500
administration tool: /usr/sap///j2ee/admin/go
port number : 50504 (look in prepconf.log)
configtool /usr/sap///j2ee/configtool
dispatcher port number : 50510
server port number : 50520
log files: /usr/sap///j2ee/cluster/server/managers/console_logs
/usr/sap/J2EE//work\dev_jcontrol
Bex: http://<host&gt;:8005/sap/BW/Bex

Java Paramater (JVM memory heap): OSS 710146

sapj2ee01

SAP License (OSS 870871)

sapj2ee02

Accessing J2EE server of SAP system

see in SMICM –> Parameters –> Display:
icm/HTTP/j2ee_0 = PREFIX=/,HOST=localhost,CONN=0-500,PORT=50100
to access J2EE: http://<host&gt;:50100
user id: J2EE_ADMIN, password: defined during installation (AOP: accentA0P)
role in R/3: SAP_J2EE_ADMIN, becomes groups in UME

To check SAP J2EE installed or not

SMCIM –> Goto –> HTTP Server –> Display Data

sapj2ee03

J2EE Server Operational = TRUE means J2EE server is running (may take sometime to start up–> start the J2EE server and J2EE applications)
Check from web: http://<host&gt;:50100/index.html

sapj2ee04

Profile parameter to start J2EE:

  • rdisp/j2ee_start_control
  • rdisp/j2ee_start

To start manually within R/3:

sapj2ee05

To stop manually within R/3:

sapj2ee06

sapmmc / SAP management console

http://<hostname&gt;:5<instance number>13

sapj2ee07

sapj2ee08

sapj2ee09

monitor J2EE

jcmon “pf=/usr/sap/<SID>/sys/profile/<SAPSID>_<INSTANCE_ID>_<HOST>”

user admin

http://<hostname&gt;:5<instance number>00/useradmin

sapj2ee10

J2EE_ADMIN user in client 001 make sure unlcoked
SAPSR3DB user in DB make sure unlocked

J2EE startup log

  • /usr/sap/<SID>/DVEBMGS<SYS Number>/work
    • dev_bootstrap
    • jvm_bootstrap.out
    • jvm_bootstrap_ID*.out
    • dev_bootstrap_ID*.out
    • log_bootstrap_ID*.log
    • std_bootstrap.o00
    • dev_jcontrol
    • jvm_sdm.out

 

  • /usr/sap/<SID>/DVEBMGS<SYS Number>/j2ee/cluster/server0/log
    • defaultTrace.*.trc
    • applications.*.log

 

  • /usr/sap/<SID>/DVEBMGS<SYS Number>/j2ee/cluster/server0/log/system/
    • server.0.log
    • security.0.log
    • httpaccess
    • webcontainer

 

Thanks for reading.

Understanding SAP Memory

Hi All,

 

Today I’m gonna share with you my understanding on SAP memory in a visual description and hopefully, in a simplest way possible.

SAP Memory Components

sapmemorypict02

sapmemorypict01

  • Local Memory is associated with individual work process
    Local work process memory is for : Executables, Data, stack, buffer for DB transfer, local roll area, local paging area
  • Shared Memory is associated with all the processes of one instance. Allocated at instance start.
    •  R/3 Buffers contain global objects for all users and work processes such as programs and customizing tables
    • Extended Memory contains user contexts – that is, objects associated with individual users. such as variables, set/get parameters; report lists, authorizations, and internal tables
    • Heap Memory contains user contexts when Extended Memory is full or quota is reached. Allocated on demand.
    • Roll Memory (Roll Buffer+R/3 Roll file) contains initial part of user context
    • R/3 Paging Memory (R/3 Paging buffer + R/3 Paging file) contains ABAP objects such as extracts; context-independent objects such as exports (memory for specific ABAP commands)
      =============
      The data processed in work processes is stored in two memory areas: roll and paging area
      User contexts are not only stored in roll area. As of R/3 Release 3.0, they are primarily stored in R/3 extended memory.

sapmemorypict03sapmemorypict04

sapmemorypict07

sapmemorypict05

sapmemorypict08

sapmemorypict09

sapmemorypict10

sapmemorypict11

SAP Memory Allocation

  • Memory allocation sequence (dialog wp):
    1. Init roll area
    2. Extended memory (until EM full or user quota is reached)
    3. The rest of Roll Area
    4. Allocate local Heap Memory (PRIV)
  • Memory allocation sequence (non-dialog wp except in NT):
    1. Roll Area
    2. Allocate local Heap Memory (PRIV)
    3. Extended memory

sapmemorypict06
I hope you find this sharing useful.

How to create and transport SAP Query

Hi All,

Today I’m going to share how to create and hen transport SAP Query.

Create SAP Query

Create Infoset: SQ02

Create SAP Query: SQ01

Create User Group: SQ03

 

Transport (export)

In source system, Call tx SQ02

sapqueryexport

Release TR

Transport to target system using STMS

 

Import

In target system, Call tx SQ02

sapqueryimport

Creating SAP transaction code for a SAP Query

Create Transaction SE93

Type: Transaction with parameters

Transaction: START_REPORT

Default Values: D_SREPOVARI-REPORTTYPE AQ

D_SREPOVARI-REPORT <user group>

D_SREPOVARI-EXTDREPORT <SAP query>

 

How to install SAP Help Library

Hi All,

Today I’m going to share simple steps to install SAP Help Library so it will be accessible from your SAP GUI when your users are using SAP application.

Steps to install SAP Library:

1. Install SAP Library in a file server

saphelp1

in my case: Install to G:\SAPHelp, space required: ~2GB

2. Share the path for SAP users

saphelp2

Share G:\SAPHelp to SAPHelp

3. Execute SR13

saphelp3

Path: \\<file server ip>\SAPHelp\PlainHTML\helpdata
Platform: WN32
Area: IWBHELP
Language: EN
Default: <tick>

SAP: Customizing Logon Text and Company Logo

Hi All,

Today I’m going to share how to customize logon text and maintain company logo in SAP application. I’ve done this in SAP ECC 5 & SAP ECC 6.

Maintain Logon Text

Go to Transaction SE61 and select the document class ‘General Text’ (selection using F4 help), and create a text with the name ZLOGIN_SCREEN_INFO in the system language determined with the profile parameter zcsa/system_language.

If the text does not exist in the system language, no output is made.

Note that there is space on the logon screen for 16 lines for every 45 fixed-font characters or for approximately 60 proportional font characters.

Title lines (can be recognized by format keys starting with a ‘U’) are highlighted in the display.

You may also output icons at the beginning of lines by using an icon code (for example, @1D@ for the STOP icon). You can get a list of icon codes from Report RSTXICON. Pay attention to the codes with two ‘@’ symbols displayed by the report. You cannot include text symbols. The function ‘include character’ cannot be used.

sap-logontext-se61

Maintain Company Logo

Call transaction SMW0 to upload image

sap-companylogo-smw0

Call SE16 to maintain SSM_CUST table with key=START_IMAGE

SAP CompanyLogo-SE16.png

 

 

SAP: Post Installation and Post Migration Steps

Hi All,

Today I’m going to share my notes on additional steps to be performed after successful SAP installation or SAP migration process.

NEW INSTALLATION

  • Installation Check: Call transaction SICK, SM21, ST22, SM50, SM51
  • Update Kernel
  • Update Oracle Patch
  • Turn-off Archive Log
  • Update Support Package: Call SPAM
  • ABAP Generator: Call SGEN
  • Turn-on Archive Log
  • Maintain Logon Group: Call transaction SMLG
  • Maintain Operation Mode: Call transaction RZ04, SM63
  • Maintain Logon Text: Execute transaction SE61

sappostinstall01

Go to Transaction SE61and select the document class ‘General Text’ (selection using F4 help), and create a text with the name ZLOGIN_SCREEN_INFO in the system language determined with the profile parameter zcsa/system_language.

If the text does not exist in the system language, no output is made.

Note that there is space on the logon screen for 16 lines for every 45 fixed-font characters or for approximately 60 proportional font characters.

Title lines (can be recognized by format keys starting with a ‘U’) are highlighted in the display.

You may also output icons at the beginning of lines by using an icon code (for example, @1D@ for the STOP icon). You can get a list of icon codes from Report RSTXICON. Pay attention to the codes with two ‘@’ symbols displayed by the report. You cannot include text symbols. The function ‘include character’ cannot be used.

  • Maintain Company Logo: Call transaction SMW0 to upload image, Call SE16 to maintain SSM_CUST table with key=START_IMAGE

sappostinstall02

sappostinstall03

  • Check transport mechanism: Configure STMS in client 000, Check RDDIMP* job (in SM37)
  • Install SAPHelp
  • Activate SAPGUI for HTML
  • Schedule DB13: backup, check database, optimizer stats, etc
  • Monitor CCMS: call RZ20, examine & clear alerts
  • Setup sapmmc: http://:513/sapmc/sapmc.html
  • Activate table logging: Call tx SCU3
  • Activate Audit logs: Call tx SM19
  • Establish connection to SAP OSS: Call tx OSS1
  • Configure Solution Manager
  • Install RTCCTOOL: Check OSS 91488
  • Enable Audit: Call SM19 & SM20
  • Schedule job PFCG_TIME_DEPENDENCY: Call tx PFUD

POST MIGRATION

  • Installation Check: Call transaction SICK, SM21, ST22, SM50, SM51
  • Printer check: Check SPAD (printer spool servers)
  • Profile check: Call RZ10, Check default profile (hostname)
  • Maintain Operation Mode: Call transaction RZ04, SM63
  • Check transport mechanism: Check STMS in client 000, RDDIMP* job (in SM37)
  • Check SAPHelp: Check SAP Help/SAP Library (menu: Help–> Application Help)
  • Check SAPGUI for HTML
  • Check DB housekeeping job: Call DB13: backup, optmizer stats, check database, etc
  • CCMS monitoring: Check RZ20
  • Check SAP Management Console: http://:513
  • Check interfaces: Check all interface jobs
  • Activate table logging: Call tx SCU3
  • Activate Audit logs: Call tx SM19
  • Establish connection to SAP OSS: Call tx OSS1

Additional Procedures to Follow After SAP System Copy from Oracle Online Backup

(Reference: SAP Note 400241)

Hi All,

 

Today I’m going to share my notes on Additional Procedures to Follow After SAP System Copy from Online Backup. The tasks below were done within sqlplus.

In my notes below, I was performing restore from SAP system RP1 to RS1 (they’re both SAP ECC 5 systems running on Oracle RDBMS).

I hope you find this useful.

 

SQL> SELECT OWNER FROM DBA_TABLES WHERE TABLE_NAME = ‘T000’;

OWNER
——————————
SAPRP1

SQL> SELECT OWNER FROM DBA_TABLES WHERE TABLE_NAME = ‘SAPUSER’;

OWNER
——————————
OPS$RP1ADM

SQL> drop table OPS$RP1ADM.SAPUSER;

Table dropped.

SQL> SELECT * FROM DBA_USERS WHERE USERNAME =’OPS$RS1ADM’;

no rows selected

SQL> create user “OPS$RS1ADM” default tablespace SYSTEM TEMPORARY tablespace PSAPTEMP identified externally;

User created.

SQL> grant connect, resource to “OPS$RS1ADM”;

Grant succeeded.

SQL> CREATE TABLE “OPS$RS1ADM”.SAPUSER (USERID VARCHAR2(256), PASSWD VARCHAR2(256));

Table created.

SQL> INSERT INTO “OPS$RS1ADM”.SAPUSER VALUES (‘SAPSR3′,’SAP’);

1 row created.

SQL> select GRANTED_ROLE from DBA_ROLE_PRIVS where grantee = ‘OPS$RS1ADM’;

GRANTED_ROLE
——————————
CONNECT
RESOURCE

SQL> grant SAPDBA to “OPS$RS1ADM”;

Grant succeeded.

SQL> commit;

Commit complete.
Last step change unix environment for <SID>ADM user (file “.dbenv_erpapRS1.csh” and “.dbenv_erpapRS1.sh”) as follows:
dbs_ora_schema = SAPRP1

Unix scripts to simplify start, stop, restart Oracle EBS and its Oracle RDBMS

Hi All,

In this post, I’m gonna share my handy scripts I developed to simplify (by running one script) to start Oracle EBS and to shutdown Oracle EBS in Unix environment.

With these scripts, start and shutdown Oracle EBS is simply by running a script, and they keep your machine resources (CPU and RAM) optimally used. Oracle EBS and Oracle RDBMS processes and services only up when needed, and they all die when we don’t need them, in a simpler term.

Here are my scripts.

Oracle EBS start, shutdown and restart – Windows scripts

START SCRIPTS

start-EBS.sh

/myscripts/startEBS-DB.sh
/myscripts/clrpersEBS.sh
su – -c ‘/oracle/EBS/inst/apps/EBS_roloel5/admin/scripts/adstrtal.sh apps/apps’
applmgrEBS
/myscripts/chkEBS.sh

startEBS-DB.sh

/myscripts/mntEBS.sh
mv -f /etc/resolv.conf /etc/resolv.conf.delauto
su – -c ‘/oracle/EBS/db/tech_st/11.1.0/appsutil/scripts/EBS_roloel5/addlnctl.sh
start EBS’ oracleEBS
su – -c ‘/oracle/EBS/db/tech_st/11.1.0/appsutil/scripts/EBS_roloel5/addbctl.sh s
tart’ oracleEBS

clrpersEBS.sh

rm -rf /oracle/EBS/inst/apps/EBS_roloel5/ora/10.1.3/j2ee/oacore/persistence/*
rm -rf /oracle/EBS/inst/apps/EBS_roloel5/ora/10.1.3/j2ee/oafm/persistence/*
rm -rf /oracle/EBS/inst/apps/EBS_roloel5/ora/10.1.3/j2ee/forms/persistence/*

mntEBS.sh

mount /dev/sde1 /oracle/EBS
mount /dev/sdd1 /oracle/EBS/db/apps_st/data

 

SHUTDOWN SCRIPTS

stopEBS.sh

su – -c ‘/oracle/EBS/inst/apps/EBS_roloel5/admin/scripts/adstpall.sh apps/apps’
applmgrEBS
su – -c ‘/oracle/EBS/inst/apps/EBS_roloel5/admin/scripts/adapcctl.sh status’ app
lmgrEBS
/myscripts/stopEBS-DB.sh

stopEBS-DB.sh

su – -c ‘/oracle/EBS/db/tech_st/11.1.0/appsutil/scripts/EBS_roloel5/addbctl.sh s
top’ oracleEBS
su – -c ‘/oracle/EBS/db/tech_st/11.1.0/appsutil/scripts/EBS_roloel5/addlnctl.sh
stop EBS’ oracleEBS
mv /etc/resolv.conf.delauto /etc/resolv.conf

 

StartStopEBSscripts.png

Important Notes on Oracle RDBMS

Hi All,

Today I’m going to share some of my Notes on Oracle RDBMS. Pardon me if it’s in tabular format, I hope you find them useful.

start Oracle Management Console:
Oracle 9.2 Unix ora<sid># oeamapp console
Oracle 10g Unix $ORACLE_HOME/bin/emctl access by: http://<DBhost&gt;:5500/em
Oracle isqlplus (10g) access by: http://<DBhost&gt;:5560/isqlplus/
Oracle insallation log file: Unix /oracle/oraInventory/logs
Windows c:\Program Files\Oracle\Inventory\logs
Oracle listener default port: 1527
Oracle Net configuration files: listener.ora
tnsnames.ora
sqlnet.ora
search sequence (OSS 445038): /etc (but not sqlnet.ora, use TNS_ADMIN if ORACLE_HOME is not set) in Windows:
/var/opt/oracle $TNS_ADMIN path (client software)
/ORACLE_HOME/network/admin /ORACLE_HOME/network/admin
test: tnsping SID
sqlplus /nolog
connect <DBUSER>/<DBPWD>@<SID>
where: DBUSER: SAPR3 or SAPBWD
DBPWD: SAP
CONNECT command: CONNECT <DBUSER>/<DBPWD>@<SID>.WORLD]
DB Link in Oracle (authorization limited by connecting user): goto Enterprise Management (EM) and create the link to test:
desc <SCHEMA>.<OBJECT>@<SID>[.WORLD]
DB LINK (OSS 518241):
Test DB connection (add entry in tnsnames.ora & sqlnet.ora, test with tnsping)
in target DB: Create a new user in Target DB
  CREATE OR REPLACE VIEW viewname AS SELECT * FROM <DBID>.tablename
  GRANT select ON <DBID>.tablename TO <username>
or :
  CREATE SYNONYM synoname FOR <DBID>.tablename
Test:
SELECT * FROM <view or table> –> using <username>
oerr oerr ora 600
Oracle ping <ORACLE_HOME>/bin/tnsping <DBID> <Count> tnsping FSD 50
Unicode Test unicode:
Check in V$NLS_PARAMETERS table: value of NLS_NCHAR_CHARACTERSET if UTF8 —> unicode
Character set Check in V$NLS_PARAMETERS table: value of NLS_CHARACTERSET (US7ASCII or WE8DEC)
Estimating table size:
1-st method – using statistics
1. Analyze statitics for the table.
From SQLPlus run the following command: ANALYZE TABLE COMPUTE STATISTICS; or ANALYZE TABLE ESTIMATE STATISTICS;
2. Make select form DBA_TABLES, ALL_TABLES or USER_TABLES dictionary view.
SELECT avg_row_len FROM dba_tables WHERE table_name = ”;
where avg_row_len – is an average row length (in bytes), including row overhead;
= avg_row_len * number_of_rows * (1 + PCTFREE/100) * 1.15 where number_of_rows – expected number of rows in you table; 1.15 – just in case :).
NOTE: If it’s a new table or it’s empty, you may insert some “demo” records before analyzing the table.
2-nd method – using math estimation
1.. Calculate maximum row length of the table based on the following facts:
CHAR( n ), VARCHAR2( n ) – n bytes
DATE – 8 bytes;
NUMBER( p, s ) = floor( (p+1)/2 ) + 1, if it’s a negative number – add one byte (+1). For example, Oracle uses 3 bytes to store number: 512 (NUMBER(3)).
2. = MAX_ROW_LENGTH * (1 + PCTFREE/100) * number_of_rows * 1.15 where 1.15 – just in case.
IN SAP: Use DB05
Oracle export: From dos prompt:
exp sap<SID>/sap tables=smen_buffc query=”where ….” log=export.log
will generate file: EXPDAT.DMP in the current directory, log file = export.log
to view help :
exp help=y
Advisable to be imported into the same DBID
Oracle import: From dos prompt:
imp
warning: the imported table will have tablespace whis is the same name as the source system.
if table exists, will be skipped.
Connect as sysdba/sysoper/internal OS user has to be included in Unix : dba, Windows: ORA_<SID>_DBA
Environment variable on Windows: dbms_type=ora
PATH=<oracle_home>\bin;… (<oracle_home>\bin in first position)
dbs_ora_tnsname=<sid>
dbs_ora_schema=SAPR3 or dbs_ora_schema=SAP<sid> (depending on which user the R/3 tables belong to)
NLS_LANG=AMERICAN_AMERICA.<characterset> (see note 381674)
SAPDATA_HOME=<drive>:\oracle\<sid>
ORACLE_SID=<sid> (normal Oracle installation) or unique instance name, for example <sid>001 (RAC installation)
USER=<sid>adm
Environment variable on Unix: dbms_type
Contains an ID for the database used; in the case of Oracle the value is always “ora”.
Only required for <sid>adm
dbs_ora_schema
Contains the name of the database user used by R/3
If dbs_ora_schema is not set, SAPR3 is used by default
Only required for <sid>adm
dbs_ora_tnsname
Contains an alias in which the correct target database is determined for links in the tnsnames.ora
Usually corresponds to the dbs_ora_tnsname of the R/3 SID (see note 562403).
Only required for <sid>adm
DIR_LIBRARY
Specifies the path for the database-dependent SAP library dboraslib
It must therefore be set for <sid>adm to /usr/sap/<sid>/SYS/exe/run.
LIBPATH (AIX)/SHLIB_PATH (HP-UX)/LD_LIBRARY_PATH (other UNIX systems)
Operating system variable which contains the search paths for libraries
May be important for access to Oracle client libraries such as libclntsh or libwtc8; for more detailed information see note 521230
For access to SAP libraries, /usr/sap/<sid>/SYS/exe/run must be contained in the <sid>adm environment (see note 588739).
NLS_LANG
Specifies the Oracle code page used in the client
Example: AMERICAN_AMERICA.WE8DEC (where WE8DEC is the code page)
In the R/3 environment, the specified code page (WE8DEC in the example above) must always be identical to the codepage that is actually used by the database.

SELECT VALUE FROM V$NLS_PARAMETERS
WHERE PARAMETER = ‘NLS_CHARACTERSET’;
It can be determined using

ORACLE_BASE
Specifies the path for the oraInventory (standard: /oracle)
Must be set accordingly for ora<sid>
ORACLE_HOME
Specifies the path for the current Oracle home directory under which the Oracle software can be found
Naming convention:
/oracle/<sid> (Oracle <= 8.0)
/oracle/<sid>/<release>_<bits> (Oracle >= 8.1)

Example: /oracle/C11/920_64 for Oracle 9.2 (64-bit) and SID=C11
Must be set the same for ora<sid> and <sid>adm.
ORACLE_SID
Contains the name of the Oracle instance; ORACLE_SID = <sid> in the case of a normal installation. In RAC environments, ORACLE_SID is the unique indicator for an instance (for example, <sid>001).
Must be set the same for ora<sid> and <sid>adm
ORA_NLS33
Specifies the path for the Oracle NLS files that contain code page information for Oracle >= 8.x
Must always be set to $ORACLE_HOME/ocommon/nls/admin/data for ora<sid>.
For <sid>adm, see the recommendations made during the installation of the client software (note 180430 and subnotes referenced there).
PATH
Contains the paths under which programs to be executed are to be found
To access R/3 executables (disp+work, R3trans, brconnect …), /usr/sap/<sid>/SYS/exe/run must be contained here. /usr/sap/<sid>/SYS/exe/run must be contained.
To access Oracle executables (lsnrctl, sqlplus, …), $ORACLE_HOME/bin must be contained here.
If the Oracle Cluster Manager is used in the RAC environment, $ORACLE_HOME/oracm/bin must also be set in the PATH for ora<sid>.
SAPDATA_HOME
Indicates the directory under which directories such as sapdata, saptrace, sapbackup or sapreorg are to be found (standard: /oracle/<sid>)
Should be set for <sid>adm and ora<sid>
SAPSYSTEMNAME
System-ID (<sid>) of the SAP system
Is only needed for <sid>adm

Create Instance oradim80 -new -sid ROL -STARTMODEauto
Create Database (run catalog.sql and catproc.sql in <ORA_HOME>/rdbms/admin subsequently using sqlplus / as sysdba) connect INTERNAL;
SET ECHO ON;
SET TERMOUT ON;
SHUTDOWN ABORT;
STARTUP NOMOUNT PFILE=init.ora;
CREATE DATABASE ROL
CONTROLFILE REUSE
MAXDATAFILES  254
MAXLOGFILES   255
MAXLOGHISTORY 1000
MAXLOGMEMBERS 3
MAXINSTANCES  50
CHARACTER SET “WE8DEC”
DATAFILE
‘E:\oracle\ROL\sapdata1\system_1\system.data1’ SIZE 250M REUSE
NOARCHIVELOG
LOGFILE
GROUP 11 (
‘E:\oracle\ROL\origloga\log_g11m1.dbf’,
‘E:\oracle\ROL\mirrloga\log_g11m2.dbf’
) SIZE 20M REUSE
,GROUP 13 (
‘E:\oracle\ROL\origloga\log_g13m1.dbf’,
‘E:\oracle\ROL\mirrloga\log_g13m2.dbf’
) SIZE 20M REUSE
,GROUP 12 (
‘E:\oracle\ROL\origlogb\log_g12m1.dbf’,
‘E:\oracle\ROL\mirrlogb\log_g12m2.dbf’
) SIZE 20M REUSE
,GROUP 14 (
‘E:\oracle\ROL\origlogb\log_g14m1.dbf’,
‘E:\oracle\ROL\mirrlogb\log_g14m2.dbf’
) SIZE 20M REUSE
;
EXIT
CREATE DATABASE RBW CONTROLFILE REUSE MAXLOGFILES 255 MAXLOGMEMBERS 3 MAXLOGHISTORY 1000 MAXDATAFILES 254 MAXINSTANCES 50 NOARCHIVELOG  CHARACTER SET WE8DEC DATAFILE ‘E:\oracle\RBW/sapdata1\system_1\system.data1’ SIZE 350M REUSE AUTOEXTEND OFF LOGFILE GROUP 1 (‘E:\oracle\RBW\origlogA\log_g11m1.dbf’, ‘E:\oracle\RBW\mirrlogA\log_g11m2.dbf’) SIZE 50M REUSE, GROUP 2 (‘E:\oracle\RBW\origlogB\log_g12m1.dbf’, ‘E:\oracle\RBW\mirrlogB\log_g12m2.dbf’) SIZE 50M REUSE, GROUP 3 (‘E:\oracle\RBW\origlogA\log_g13m1.dbf’, ‘E:\oracle\RBW\mirrlogA\log_g13m2.dbf’) SIZE 50M REUSE, GROUP 4 (‘E:\oracle\RBW\origlogB\log_g14m1.dbf’, ‘E:\oracle\RBW\mirrlogB\log_g14m2.dbf’) SIZE 50M REUSE
Oracle Service setup in Windows <SAPEXE>\sapstartsrv -t
To shrink PSAPTEMP datafiles: stopsap r3
execute sqlplus/svrmgrl:
SELECT * FROM dba_tablespaces WHERE tablespace_name=’PSAPTEMP’, take note the storage parameters
SELECT COUNT(*) FROM dba_segments WHERE tablespace_name=’PSAPTEMP’, should return 0
drop tablespace PSAPTEMP using sapdba
recreate PSAPTEMP using sapdba
Delete Oracle DB (UNIX), On Windows, use Oracle Database Assistance program 01. Login as connect / as sysdba at svrmgrl
02. startup the database if it’s not already started. The database must at least mounted.
03. spool /tmp/deletelist.lst
04. select name from v$datafile; (This will get all the datafiles; alternatively, you can select file_name from dba_data_files)
05. select member from v$logfile;
06. select name from v$controlfile;
07. archive log list (archive_log_dest is where the archived destination is)
08. locating ifile by issuing show parameter ifile (alternatively, check the content of init.ora)
09. spool off
10. Delete in O/S level the files listed in /tmp/deletelist.lst
11. remove all the entries which refer to the deleted database in tnsnames.ora and listener.ora (located in $ORACLE_HOME/network/admin)
12. remove all database links referring to the deleted database.
13. check “/var/opt/oracle/oratab” to make sure there is no entry of the database deleted. If yes, remove it.
14. DONE
Database Load R3load.exe  -ctf I “D:\/DATA/SAPSSEXC.STR” “C:\SAPinst ORACLE KERNEL/DDLORA.TPL” “C:\SAPinst ORACLE KERNEL/SAPSSEXC.TSK” ORA -l “C:\SAPinst ORACLE KERNEL/SAPSSEXC.log” to create TSK file
R3load.exe -dbcodepage 1100 -i “C:\SAPinst ORACLE KERNEL/SAPSSEXC.cmd” -l “C:\SAPinst ORACLE KERNEL/SAPSSEXC.log” -stop_on_error To load database (after creating cmd file manually)
stop_on_error / continue_on_error
Oracle patch installation (OSS Note 839182) Backup <ORACLE_HOME> (oracle/RP1/102_64)
/oracle/RP1/102_64/Opatch/opatch version check opatch version
/oracle/RP1/102_64/Opatch/opatch lsinventory check oracle inventory (done this before and after applying the patch)
su – orarp1 applying oracle patch
cd <oracle patch base directory / source>
/oracle/RP1/102_64/Opatch/opatch apply -verbose
/oracle/RP1/102_64/Opatch/opatch lsinventory
After applying patch which is done after SAP installation completed and got error: ORA-01092 startup upgrade
execute catalog.sql and catproc.sql in /oracle/<SID>/102_64/dbs
Oraclae tnsnames.ora TNS_ADMIN
Startup Nomount : –
 Read the parameter file and start the instance.
 Instance name identified by ORACLE_SID env parameter.
 The parameter file controls such things as SGA size, database name that can connect to this instance.
 Database not associated with instance yet.
 As an example, you may need to do this if you will mount a standby database.
Startup Mount : –
 Associates database with the instance.
 Open and read control files
 Establish physical files associated with database. i.e location, size, amount of redo log files. Physical database file names and locations.
 DBA may need to be in mount state for all kinds of DBA activity.
 examples :
 rename/move system datafile.
 put database in archivelog mode.
 Database not yet available for user connections.
 Startup Open
 Ensure physical files exist.
 make available for normal operations.
 open online datafiles, redo logs.
 acquire rollback segments.

Important SQL Statements for a DBA in general or a SAP DBA

Hi All,
Today, I’m going to share some of my notes on SQL statements that I used frequently or what I think it’s important for troubleshooting as DBA in general or SAP DBA as particular.

Note SQL Remark
33516 alter tablespace PSAPTEMP default storage (INITIAL 10M NEXT 1M MINEXTENTS 1 MAXEXTENTS 1000);
16277 alter rollback segment prs_1 storage (maxextents 800);
select PERNR, LGA01, BET01, LGA02, BET02, LGA03, BET03, LGA04, BET04, LGA05, BET05, LGA06, BET06, LGA07, BET07, LGA08, BET08, LGA09, BET09, LGA10, BET10, LGA11, BET11, LGA12, BET12, LGA13, BET13, LGA14, BET14, LGA15, BET15, LGA16, BET16, LGA17, BET17, LGA18, BET18, LGA19, BET19, LGA20, BET20 from SAPR3.PA0008 where MANDT=480 and PERNR=’00200589′;
select name from v$database; To determine DB_NAME
select instance from v$thread; To determine instance (SID)
select * from global_name; To determine Global Database Name
619188 SELECT SUBSTR(EVENT, 1, 30), TIME_WAITED, AVERAGE_WAIT FROM V$SYSTEM_EVENT ORDER BY TIME_WAITED DESC; To find which wait event slowing down Oracle system (exclude idle times)
151603 alter database tempdb modify file (name = tempdev, size = 250MB)
alter database tempdb modify file (name = templog, size =  50MB)
SQL Server
363018 ALTER DATABASE PRD ADD LOG FILE (NAME = PRDLOG2, FILENAME = ‘l:\PRDLOG\PRDLOG2.ldf’, SIZE = 512, MAXSIZE = UNLIMITED, FILEGROWTH = 100MB) SQL Server
ALTER DATABASE PRD MODIFY FILE (NAME = ‘PRDLOG’,SIZE = 2048)
Table and Index size sort SELECT SEGMENT_NAME, BYTES FROM DBA_SEGMENTS WHERE OWNER=’SAPR3′ ORDER BY BYTES; DBEXPORT
Number of Rows in table (provided statistic is updated) SELECT TABLE_NAME, NUM_ROWS FROM DBA_TABLES ORDER BY NUM_ROWS;
Tablespace storage parameter SELECT * FROM DBA_TABLESPACES WHERE TABLESPACE_NAME=’PSAPTEMP’; DBEXPORT
Monitor PSAPTEMP use during db export (PSAPTEMP should be twice as biggest table size) SELECT SUM(BYTES), SUM(EXTENTS) FROM DBA_SEGMENTS WHERE TABLESPACE_NAME=’PSAPTEMP’; DBEXPORT
609430 select name from v$obsolete_parameter where isspecified=’TRUE’; ORA-32004: obsolete and/or deprecated parameter(s) specified
select attr,val from UME_STRINGS where PID like ‘%iffah%’; portal
alter database datafile ‘/oracle/JP1/sapdata6/rolll_1/roll.data1’ resize 500M;
690241 ALTER SYSTEM FLUSH SHARED_POOL
SAP Table entries SELECT TABLE_NAME, NUM_ROWS FROM DBA_TABLES inner join (select OBJ_NAME from SAPRP1.TADIR inner join SAPRP1.DD02L on SAPRP1.DD02L.TABNAME=SAPRP1.TADIR.OBJ_NAME where PGMID=’R3TR’ and OBJECT=’TABL’and (TABCLASS=’TRANSP’ or TABCLASS=’POOL’) and DEVCLASS in (‘VAR’,’VBAS’,’VS’,’VSCORE’)) on TABLE_NAME=OBJ_NAME ORDER BY NUM_ROWS;
ALTER DATABASE ADD TEMPFILE ….
Unlock, reset, enable SAP* select BNAME,UFLAG from SAPSR3.USR02 where MANDT=800 and BNAME=’SAP*’;
update SAPSR3.USR02 set UFLAG=0 where MANDT=001 and BNAME=’SAP*’;
delete from SAPSR3.USR02 where MANDT=810 and BNAME=’SAP*’;
create spfile from pfile=
Generate log file: ALTER SYSTEM SWITCH LOGFILE;
Enabling Archivelog STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ARCHIVE LOG LIST;
ALTER DATABASE OPEN;
Disabling Archivelog STARTUP MOUNT;
ALTER DATABASE NOARCHIVELOG;
ARCHIVE LOG LIST;
ALTER DATABASE OPEN;
SAP Note 600513 – ORA-25153 after recovery due to missing tempfiles select tablespace_name,file_name from dba_data_files where tablespace_name=’PSAPTEMP’;
select tablespace_name,file_name from dba_data_files where tablespace_name=’PSAPUNDO;
alter tablespace PSAPTEMP add tempfile ‘<filename>’ reuse;
CREATE TEMPORARY TABLESPACE “PSAPTEMP” TEMPFILE ‘<filename>’ SIZE 2047984K
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 10240K;
oracle import monitor (imp) select substr(sql_text,instr(sql_text,’INTO “‘),30) table_name,
rows_processed,
round((sysdate-to_date(first_load_time,’yyyy-mm-dd hh24:mi:ss’))*24*60,1) minutes,
trunc(rows_processed/((sysdate-to_date(first_load_time,’yyyy-mm-dd hh24:mi:ss’))*24*60)) rows_per_min
from   sys.v_$sqlarea
where  sql_text like ‘INSERT %INTO “%’
and  command_type = 2
and  open_versions > 0;
Lobsegment SELECT owner, table_name, column_name, segment_name, index_name
FROM DBA_LOBS
WHERE segment_name = ‘SYS_LOB0017931286C00016$$’;
Lobindex SELECT owner, table_name, column_name, segment_name, index_name
FROM DBA_LOBS
WHERE index_name = ‘SYS_IL0021404147C00007$$’;
Move/rename data file STARTUP MOUNT;
ALTER TABLESPACE <tablespace name> OFFLINE;
ALTER TABLESPACE alter tablespace <tablespace name> ONLINE
ALTER TABLESPACE <tablespace name> RENAME DATAFILE ‘<fully qualified path to original data file name>’ TO ‘<new or original fully qualified path to new or original data file name>’;
or use brtools (space management)
See table extents inside datafile SELECT owner, segment_name FROM dba_extents a, dba_data_files b WHERE a.file_id = b.file_id AND b.file_name = ‘/oracle/AOP/sapdata6/sr3_38/sr3.data38’; or use brtools (segments management)
ORA 1187 alter database tempfile ‘/oracle/AOP/sapdata2/temp_1/temp.data1’ drop;
alter tablespace PSAPTEMP add tempfile ‘/oracle/AOP/sapdata2/temp_1/temp.data1’ reuse;
alter database tempfile ‘/oracle/AOP/sapdata2/temp_1/temp.data1’ autoextend on maxsize 10000M;
Alter database datafile alter database datafile ‘/oracle/AOP/sapdata1/sr3700_4/sr3700.data4’ autoextend off;

alter database datafile ‘/oracle/AOP/sapdata1/system_2/system.data2’ autoextend on maxsize 5000M;

select sum(bytes)/1024/1024 from dba_free_space where tablespace_name = ‘PSAPSR3’ and file_id = 67;
SELECT substr(owner,1,5), substr(segment_name,1,5),block_id,blocks, bytes FROM dba_extents WHERE file_id = 67;
select file_id, block_id, blocks, bytes,  ‘Free’ from dba_free_space where tablespace_name = ‘PSAPSR3’ and file_id = 67 and rownum < 7 order by block_id desc;
See last free space in all datafiles for a tablespace (for shrinking) select sfs.file_id, sfs.block_id, sfs.bytes from dba_free_space sfs inner join
(select fs.file_id, max(fs.block_id) maxblock from dba_free_space fs inner join (select distinct file_id from dba_data_files where tablespace_name=’PSAPSR3′) df on fs.file_id=df.file_id group by fs.file_id order by fs.file_id) fidmaxb
on sfs.file_id=fidmaxb.file_id and sfs.block_id=fidmaxb.maxblock order by sfs.bytes desc;
See last free space in a datafile (for shrinking) select file_id, block_id, blocks, bytes,  ‘Free’ from dba_free_space fs inner join dba_data_files df on fs.file_id = df.file_id where tablespace_name = ‘PSAPSR3’ and rownum < 7 order by block_id desc;
select fs.file_id, max(fs.block_id) from dba_free_space fs inner join (select distinct file_id from dba_data_files where tablespace_name=’PSAPSR3′) df on fs.file_id=df.file_id group by fs.file_id order by fs.file_id;
Cluster table SELECT owner, table_name, column_name, segment_name, index_name FROM DBA_LOBS
WHERE table_name = ‘ATAB’;
select tabname, varkey from sapsr3.atab where tabname=’TVCPL’;
select count(*) from sapsr3.atab where tabname=’TVCPL’;
Memory Note 570375 – SAP on Sun Solaris: Swap Space and Paging
PSAPTEMP error during backup after system copy alter database tempfile ‘/oracle/AOP/sapdata2/temp_1/temp.data1’ drop including datafiles;
alter tablespace PSAPTEMP add tempfile ‘/oracle/AOP/sapdata2/temp_1/temp.data1’ size 2048M autoextend on maxsize 10000M;
Check archive log mode ARCHIVE LOG LIST
select grantee, granted_role, default_role from dba_role_privs where grantee=’SYSTEM’;

I hope you find them useful.