Friday, 29 August 2014

Reorganize Tables in SAP


Why do we need to reorganize table in SAP system?

This is the important question before we plan to reorganize table in SAP system. Since Data Management Strategy is the key factor to boost system performance and to keep data accessibility more efficient, we need to maintain or organize the data itself. One of the strategy is to reorg certain table which can impact on system performance. Reorganizing table can also be used to improve database structure, transform dictionary managed to locally managed table space, merge data in table space from many small files into larger files and perform segments defragmentation.
What types of reorganization is provided by SAP using BR*Tools?
You can perform the following types of reorganization:                                      

  • Reorganize tables online
  • Check tables for reorganization
  • Clean up tables after aborted reorganization
  • Convert LONG and LONG RAW fields to CLOB or BLOB online (Oracle 10g or higher)
  • Stop reorganization (command-line mode only)
  • Suspend reorganization (command-line mode only)
  • Resume reorganization (command-line mode only)
What is the procedure to perform reorganization using BR*Tools ?

  1. Run BRTOOLS. Choose Segment Management or run from the command prompt brspace –f tbreorg.
  2. Enter table name in Table names (table).
  3. Choose Reorganize Tables.
  4. Set the required option like new destination table space or set the parallel thread which will be used to perform reorganization. The more you set the thread, the faster your process will be. But this limited to the CPU specification in OS level.
  5. Choose continue to start processing.
  6. Check the detail log in s<encoded timestamp>.tbr.
Please take note that this online reorganization will impact on system performance, therefore you need to run this when the system load is low.

 

Thursday, 31 July 2014

What are the functions of SAPOSCOL?

What are the functions of SAPOSCOL?

SAPOSCOL is an operating system collector. It is a standalone program that runs in operating system background.
SAPOSCOL collects data about operating system resources like
·         CPU Utilization
·         Usage of Physical Memory
·         Usage of Virtual Memory
·         Usage of file systems
·         Usage of Physical disks
·         Usage of running processes

SAPOSCOL runs exactly once per host and runs independently of the sap system.

By default, SAPOSCOL collects data every 10seconds and records it. It also records the hourly average statistics for the last 24hours in shared memory. This data will be fetched by background job “SAP_COLLECTOR_FOR_PERFORMANCE” and writes it to the MONI performance database table.


Sunday, 27 July 2014

DB post steps

DB post steps:


1. Create OPS$ users

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME         STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
PSAPUNDO                    ONLINE
PSAPTEMP                     ONLINE
PSAPCRM                       ONLINE
PSAPCRM731                 ONLINE
PSAPCRMUSR                ONLINE



SQL> create user OPS$BCRADM DEFAULT TABLESPACE PSAPCRMUSR temporary tablespace psaptemp identified externally;

User created.

SQL> create user OPS$ORABCR DEFAULT TABLESPACE PSAPCRMUSR temporary tablespace psaptemp identified externally;

User created.

SQL> grant connect, resource to ops$bcradm;

Grant succeeded.

SQL> grant sapdba to ops$orabcr;

Grant succeeded.

2. Drop exBIDing table ops$sidadm.sapuser (Source <sid>)

SQL> drop table ops$c2radm.sapuser;

Table dropped.

3. Create table ops$sidadm.sapuser (target <sid>)

SQL> create table ops$BCRadm.sapuser (userid varchar2(256), passwd varchar2(256));

Table created.

SQL> insert into ops$BCRadm.sapuser values ('SAPCRM','a234678z');

1 row created.


SQL> alter user sapcrm profile default;

User altered.

SQL> alter user system identified by a234678z;

User altered.

4. Update schema owner password using brconnect.

brconnect -u system/a234678z -f chpass -o sapcrm -p a234678z

5. Run scripts sapdba_role.sql and sapconn_role.sql

 sapdba_role.sql :

 sqlplus /nolog @sapdba_role <SAPSCHEMA_ID>
 <SAPSCHEMA_ID>: for owner SAPR3: R3, SAP<SID>: <SID>, SAP<SID>DB: <SID>DB

sapconn_role.sql :
sqlplus /nolog @sapconn_role

Starting SAP

1. Verify <sid>adm environment pinting to 11g binaries, 11g client

DIR_LIBRARY
LD_LIBRARY_PATH
TNS_ADMIN
ORACLE_HOME_PATH

2. Go to cdexe and run ldd dboraslib.so , should be able to load libraries

hostname:bcradm 11> cdexe
hostname:bcradm 12> ldd dboraslib.so
        linux-vdso.so.1 =>  (0x00007fff1e9ff000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f43e8d81000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f43e8b78000)
        libclntsh.so.11.1 => /oracle/client/10x_64/instantclient/libclntsh.so.11.1 (0x00007f43e61c2000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f43e5e21000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f43e5b1a000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f43e5896000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f43e5680000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f43e5463000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003a7b400000)
        libnnz11.so => /oracle/client/10x_64/instantclient/libnnz11.so (0x00007f43e5097000)
        libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f43e4e7e000)
        libaio.so.1 => /lib64/libaio.so.1 (0x00007f43e4c7c000)

3.Run R3trans –d using <sid>adm, return code to be 000

If return code other than 000 analyse r3trans.log
hostname:bcradm 13> R3trans -d
This is R3trans version 6.23 (release 720 - 17.09.12 - 20:12:05 ).
unicode enabled version
R3trans finished (0000).


4. Startsap and verify startup logs

Ps –eaf| grep dw
Ps –eaf| grep sap
Ps –eaf| grep ms ,
ps –eaf| grep scs,
ps –eaf| grep ers

5. Login to SAP via sapgui and apply sap license

Record hardware key to generate saplicense via sap market place
hostname:bcradm 16> saplicense -get
saplicense: HARDWARE KEY = xxxxxxxxxxx

6. Set below paaremter to login with user sap* 000 client

DEFAULT.PFL:login/no_automatic_user_sapstar = 0
Set below paramters relevant to transport

Example:
BIR_DVEBMGS01_sapbirci:DIR_EPS_ROOT = /usr/sap/trans/isu/BIR/EPS
BIR_DVEBMGS01_sapbirci:DIR_TRANS = /usr/sap/trans/isu/BIR

7. Reinitialize TMS after DB copy

logon to 000  as DDIC
Run transaction SE06 -->database copy or database migration
Reinstall CTS -->  yes
change original <S_System <SID>>to <T_System <SID>> -->yes
cts not configured --> ok
delete the TMS Configuration --> yes
delete all versions of transports --> yes
delete transport routs --> yes
Configure TMS

Logon to 000 Client with user DDIC and password

Go to STMS and configure TMS as self domain, verify domain.cfg tp_domain.PFl creation at right location at OS level.

Go to system overview, create a virtual system
Go to transport routes and add routes, adjust and dBIRribute

8. Suspend background jobs, run report BTCTRNS1

9. Configure SAP Profile Parameter Files

After the database restore, the active profiles lBIRed in the SAP system will be from the old hostname.  These profiles need to be deleted and the profiles from the OS need to be re-imported.  Proceed as follows:

Run transaction RZ10.

Delete source system profiles:

Click the Profile drop-down box and choose a profile (this process must be done for each profile).
Select menu items: Profile -> Delete -> All versions of a profile.

Click Yes to first prompt to update the database

Click No to delete the files from the OS Level

Click green check on all versions deleted screen

Repeat steps 1-3 for all source system profiles lBIRed in the Profile drop-down lBIR.

Import all profiles from UNIX by selecting menu items: Utilities -> Import Profiles -> of active servers.

Green back arrow.

10. Fix Logon Group Names

Run transaction SMLG

Add the newly added systems to exBIRing LOGON groups.
Highlight the New Hostname Entries.
Click the Assign Group button and assign the Logon groups respectively.
Highlight the Old Hostname Entries.
Click the Delete button.
Save.  

Note: Do not delete the groups instead of that delete only instances assigned. If you delete the groups both the groups and instances will be deleted.

Re-execute transaction SMLG once again and validate the logon group configuration.


11.Fix RFC Server Group

Run transaction RZ12
Add the newly added systems to exBIRing server groups.
Click create assignment provide exBIRing server group name and hostname
Choose apply current quotos and save


12. Configure Op Modes

After the database restore, the target system will contain Operation Modes from the old hostname.  These Op Modes need to be deleted and the correct Op Modes need to be imported.  Proceed as follows:
Run transaction RZ04
Choose exiting operation mode and delete
Click create operation mode
Select a server name and press SHIFT F2.
Do this for each source system op mode lBIRed.
Click the SAVE button and provide day mode
Click yes to add other operation mode (night), select no and save.

13. Create RFC’s between CRM, ISU and BW systems

CRM --> ISU & ISU --> CRM
Use user rfcuser or copy rfcuser with in the rfc and maintain the rfc’s, perform authorization test
CRM --> BW & ISU --> BW
Use user KIWALE with in the rfc connections
BW --> CRM & BW -->ISU
Use user BIWREMOTE, ALEREMOTE or rfcuser relevant to system

14. Logical system conversion

Go to SCC4 and record the logical system

Go to WE20 and record logical systems relevant to ISU, CRM and BW
      
1. Disconnect from previously connected BWR (EX : BWR – source , BWS – target) 

(For all systems that are source systems of BW: ISU, CRM)
Run Transaction SE37
Enter RSAP_BIW_DISCONNECT
Hit Test/Execute (F8)
Enter data into the following fields:
I_BIW_LOGSYS:  BWRCLNT500
I_OLTP_LOGSYS: <Logical system for your Production System>
I_FORCE_DELETE: X
Hit execute (F8)

Difference between PFILE and SPFILE? What are their advantages?

Difference between PFILE and SPFILE? What are their advantages?

 PFILE

Until Oracle 8i, we were using a text file called the PFILE (parameter file) for setting the database initialization parameters. This PFILE is read at instance startup time to get specific instance characteristics. The PFILE is text based, and can be edited in an editor like vi on UNIX or Notepad on Windows. Any changes that were made in PFILE would only take effect when the database is restarted,
Since SAP/Oracle recommends using SPFILE over PFILE, I will provide some details on SPFILE to answer your question in more detail.

SPFILE

In Oracle9i, a new feature called SPFILE (server parameter file) was introduced. SPFILE is a binary file that contains the same information as the old PFILE. SPFILE permits dynamic changes without requiring you to restart that instance.

By default, if you do not specify PFILE in your STARTUP command, Oracle will use server parameter file (SPFILE). If you choose to use the traditional text initialization parameter file (PFILE), you must specify the PFILE clause when issuing the STARTUP command.

The SPFILE is different from the PFILE in that it cannot be directly edited. This is because it has a header and footer that contain binary values. Since you cannot change a SPFILE directly, Oracle allows you to manage the SPFILE via the ALTER SYSTEM command.

When you execute the ALTER SYSTEM command, the parameter change is validated immediately, which helps avoid errors associated with entering an incorrect parameter name or an invalid value. In addition, the ALTER SYSTEM allows you to specify whether you want to update the parameter immediately, update just the SPFILE, or both. All these features help avoid human error associated with manually updating a PFILE.

The following example shows how to change the current value of SESSIONS and store the value in the SPFILE.

SQL> ALTER SYSTEM SET SESSIONS=200 SCOPE=SPFILE;

The new part in this command is the parameter SCOPE. You have the following options for this.
SCOPE = SPFILE

(For both static and dynamic parameters, changes are recorded in the spfile, and will take effect in the next restart.)

SCOPE = MEMORY

(For dynamic parameters, changes are applied in memory only. No static parameter change is allowed.)

SCOPE = BOTH

For dynamic parameters, the change is applied in both the server parameter file (SPFILE) and memory. No static parameter change is allowed.)
For dynamic parameters, we can also specify the DEFERRED keyword. When specified, the change is effective only for future sessions.

Now for the first part of your question. Since you are using Oracle 10G, you have to use the ALTER SYSTEM command to change the Oracle parameters as recommended by the SAP Early Watch Alert.

To Enable and Disable Archive logs in System

To Enable and Disable Archive logs in System

Enable:
hostname:oracs5 55>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sat Apr 19 10:53:48 2014
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data mining and Real Application Testing options

SQL>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL>select status from v$instance;
select status from v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 19669
Session ID: 405 Serial number: 49


SQL>startup mount;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area 4777603072 bytes
Fixed Size                  2236008 bytes
Variable Size            2332033432 bytes
Database Buffers         2298478592 bytes
Redo Buffers              144855040 bytes
Database mounted.

SQL>alter database archivelog;

Database altered.

SQL>alter database open;

Database altered.

SQL>archive log list;
Database log mode           Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/CS5/oraarch/CS5arch
Oldest online log sequence     6394
Next log sequence to archive   6397
Current log sequence           6397
SQL>


Disable:


hostname:oracs5 55>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sat Apr 19 10:53:48 2014
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data mining and Real Application Testing options

SQL>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL>select status from v$instance;
select status from v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 19669
Session ID: 405 Serial number: 49


SQL>startup mount;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area 4777603072 bytes
Fixed Size                  2236008 bytes
Variable Size            2332033432 bytes
Database Buffers         2298478592 bytes
Redo Buffers              144855040 bytes
Database mounted.

SQL>alter database Noarchivelog;

Database altered.

SQL>alter database open;

Database altered.

SQL>archive log list;
Database log mode           No Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/CS5/oraarch/CS5arch
Oldest online log sequence     6394
Next log sequence to archive   6397
Current log sequence           6397
SQL>

Tuesday, 30 April 2013

What is an SAP lock ?


What is an SAP lock ?
Different types of SAP locks ?Difference between Write lock(E) and Enhanced write lock(X) ?
How to monitor SAP locks ?How to delete SAP locks ?

SAP lock is set by the executing workprocess when a user/job wants a change access to data.
Whenever a lock to be set the respective workprocess checks in the locktable whether a respective lock conflicts the existing entries in
the locktable. If so, a lock is refused. If there is no conflict, then a lock is set.
There are different types of locks :
Write locks (E) : This is also known as exclusive lock mode as the lock data can be edited by only one user. Any other requests from
workprocesses to set another write lock or read lock are rejected. A cumulate lock can be applied on the lock data by the same lock
owner again.
Read locks (S) : This is also known as shared lock mode as several users can have read access to the locked data at the same time.
Additional read lock requests are entertained even if they are from different users. However a write lock is rejected.
Enhanced write locks (X) : This is also known as exclusive non-cumulative lock mode. An enhanced write lock can be requested only
once even if it is by the same transaction.
Difference between write locks(E) and Enhanced write lock(X) is write locks can be set and released by the same transaction
several times but X type locks can also be set once even by the same transaction.
Optimistic locks (O) : These locks are set up when the users displays the data in change mode. Several optimistic locks can be setup
on the same data. Optimistic locks are read locks(S) at first and converted to write lock (E) when the users wants to save the data. If
an optimistic locks on a data is changed to write lock(E), all other optimistic locks on that data will be deleted.
Locks that are set by an application program are released by the program itself or they are released by the update program once the
database has been changed.
Transaction code SM12 can be used to monitor SAP locks.


Here you have option of selecting locks based on following parameters
tablename
lock argument
client
username



In case, as part of monitoring, if you encounter some old sap locks and after thorough analysis, you would like to delete these, it can be done in the following ways :
Select the locks and delete the lock from SM12
Identify the user who has set the respective lock and end the user session using SM04 transaction code.






Kernel Upgrade steps?


Kernel Upgrade steps
Here is the Procedure to Update your SAP Kernel
Stop all R/3 Processes and the Database
% stopsap all
Stop SAPOSCOL process
% saposcol -d
Stop ListnerControl process by logging in as ora user
%lsnrctrl stop
Download Kernel Patches
Copy Them to a directory on Central Instance
Backup Your Old Kernel (by renaming it or moving it)
uncar the downloaded files
After that restart your services in following order
Listner
SAPOSCOL
Database
R/3