Sunday, September 11, 2016

Program to change mass password in SAP

Home


Below program will help for security consultants...!

Ask ABAP Consultant to develop a REPORT with below code (only if your client allows), and execute same to reset password for no. of user.


*&---------------------------------------------------------------------*

*& Report  ZNAME_OF_YOUR_PROGRAM

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*



REPORT  ZNAME_OF_YOUR_PROGRAM message-id zpassword.



tables usr01.



data: lt_return type bapiret2 occurs 0 with header line.

data: message type string.

data: lw_user type BAPIBNAME-BAPIBNAME.

data: it_bname type standard table of usr01, wa_bname type usr01.

data: dummy type bapipwd value 'n$NRC}va9/w-/WxYikSp8~a+Zb=NU7+oEVv'.



select-options: s_bname for usr01-bname obligatory NO INTERVALS.

parameters: p_passw type bapipwd obligatory.



SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(13) vText10.

SELECTION-SCREEN POSITION 15.

PARAMETERS: rb11 RADIOBUTTON GROUP rb1.

SELECTION-SCREEN COMMENT 18(10) vText11.

SELECTION-SCREEN POSITION 35.

PARAMETERS: rb12 RADIOBUTTON GROUP rb1.

SELECTION-SCREEN COMMENT 38(10) vText12.

SELECTION-SCREEN END OF LINE.



SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(13) vText20.

SELECTION-SCREEN POSITION 15.

PARAMETERS: rb21 RADIOBUTTON GROUP rb2.

SELECTION-SCREEN COMMENT 18(15) vText21.

SELECTION-SCREEN POSITION 35.

PARAMETERS: rb22 RADIOBUTTON GROUP rb2.

SELECTION-SCREEN COMMENT 38(30) vText22.

SELECTION-SCREEN END OF LINE.



AT SELECTION-SCREEN OUTPUT.

vText10 = 'Log info:'.

vText11 = 'short'.

vText12 = 'detail'.

vText20 = 'Password must'.

vText21 = 'not be changed'.

vText22 = 'be changed at first logon'.



at selection-screen.



*  loop at s_bname where option ne 'EQ'.

*    message e001.

*  endloop.



start-of-selection.

select *

from usr01

into corresponding fields of table it_bname

where bname in s_bname.



*  loop at s_bname.

loop at it_bname into wa_bname.

*    select count(*) from usr01 where bname in s_bname.

select count(*) from usr01 where bname = wa_bname-bname.

if sy-subrc ne 0.

*      write: / 'Userid:', s_bname-low , 'is not found in database'.

write: / 'Userid:', wa_bname-bname , 'is not found in database'.

continue.

endif.



if rb22 = 'X'.

dummy = p_passw.

endif.



*    Write: / 'about to reset password for user:', s_bname-low.

*    lw_user = s_bname-low.

lw_user = wa_bname-bname.

CALL FUNCTION 'BAPI_USER_CHANGE'

EXPORTING

USERNAME  = lw_user

PASSWORD  = dummy

PASSWORDX = 'X'

* don't work        PRODUCTIVE_PWD = rb21

TABLES

RETURN    = lt_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.



if rb21 = 'X'.

CALL FUNCTION 'SUSR_USER_CHANGE_PASSWORD_RFC'

EXPORTING

BNAME        = lw_user

PASSWORD     = dummy

NEW_PASSWORD = p_passw.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.



*      update USR02 set PWDHISTORY = '1' where BNAME = wa_bname-bname.

*      update USR02 set PWDSTATE = '0' where BNAME = wa_bname-bname.

*      update USR02 set PWDINITIAL = '2' where BNAME = wa_bname-bname.

*      commit work.

endif.


if rb12 = 'X'.

Write: / 'about to reset password for user:', wa_bname-bname.

loop at lt_return.

write: / '.....' , lt_return-MESSAGE.

endloop.

write : / '.', '.', '.'.

endif.



if rb11 = 'X'.

read table lt_return index 1.

message = lt_return-message.

Write: / 'About to reset password for user:', wa_bname-bname.

Write: at 55 '...', message.

endif.


endloop.

if sy-subrc ne 0. write: / 'No user selected'. endif.

Oracle Startup, Parameter File and Oracle Cache Management: System Global Area (SGA) and Program Global Area (PGA)

Home



Oracle startup phrases:

Offline      : Oracle instance processes and buffer do not exist
Nomount : Read parameter file, start processes, allocate memory buffer
Mount : Open control files
Open : Open all data files and online redo log files


Oracle initialization parameter file:

When Oracle database is started, one of the first things is to read the database initialization parameter file that contains values from either a PFILE (init<SID>.ora) or SPFILE. The parameter values that defines the overall instance configuration such as how much memory to allocate, the file locations of datafiles, optimization parameters and etc.

Oracle instance is started by searching the default location for a parameter file with one of the following names (in this order):

Parameter file Description
1 spfile<SID>.ora SPFILE for the instance - cannot edit the binary file directly
        (Edit through: alter system set <parameter>=<value> scope=spfile)

2 init<DSID>.ora PFILE for the instance name SID - can edit it using text editor



The search is finished as soon as one of the files is found, and the instance is started using that profile, which is normally an SPFILE. If no SPFILE exists in the default directory, the instance is started with the standard initialization file.
- Profile located in $ORACLE_HOME\dbs (Linux/Unix) and $ORACLE_HOME\database (Windows)

- Backup of the PFILE and SPFILE (Recommended to sync the PFILE=SPFILE to allow parameters change with text editor):
 
                                    -  SQL> create pfile from spfile;
   
                                    - SQL> create spfile from pfile;


The SCOPE parameter has three values MEMORY, SPFILE and BOTH. Let’s look at an example of each:

Alter system set db_2k_cache_size=100m SCOPE=SPFILE;

If you want to make a change to a parameter in the spfile without affecting the current instance, you can do so using the SCOPE=SPFILE option of the ALTER SYSTEM statement. This is useful when you want to make a change starting from the next startup and not for the current instance.

Alter system set db_2k_cache_size=100m SCOPE=MEMORY;

In the example above, the SCOPE=MEMORY tells Oracle to make the change for the life of the instance, and to change it back to the default value the next time the database is bounced.

Alter system set db_2k_cache_size=100m SCOPE=BOTH;

When you specify SCOPE=BOTH, the change will be made immediately, and Oracle will also make the change permanent, even after the database is bounced.



SQL> show parameter shared_pool_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------

shared_pool_size                     big integer 216M


SQL> alter system set SHARED_POOL_SIZE = 400M scope=spfile;

then stop database i.e.
sql > shutdown immediate

and then start database instance

sql> startup
Then type the command at sql prompt as follows

sql> show parameter shared_pool_size

The output should show 400M
Determine Dynamic SGA activated
- DB_CACHE_SIZE not equal to 0
- DB_BLOCK_BUFFERS: obsolete and cannot use simultaneously with SGA_MAX_SIZE or
   DB_CACHE_SIZE


Oracle Cache Management

1) System Global Area (SGA)
- Shared memory area that can be called by all Oracle process, contains buffer pool, shared pool, Java pool, large pool, stream pool and Redo buffer
- parameters can be change dynamically without system restart (SGA_MAX_SIZE, DB_CACHE_SIZE)

Determine Dynamic SGA activated
- DB_CACHE_SIZE not equal to 0
- DB_BLOCK_BUFFERS: obsolete and cannot use simultaneously with SGA_MAX_SIZE or
   DB_CACHE_SIZE



2) Program Global Area (PGA)
Process local memory which is assigned to exactly one process (shadow process)

Determine automatic PGA activated




Useful Queries

select status from v$instance;

select STARTUP_TIME from v$instance;

Oracle SQL query to know Oracle version

select value from v$system_parameter where name = 'compatible';

Oracle SQL query to know the path and name of spfile

select value from v$system_parameter where name = 'spfile';

Oracle SQL query to know the localization and number of control files

select value from v$system_parameter where name = 'control_files';

Oracle SQL query to show the database name.

select value from v$system_parameter where name = 'db_name';



SQL Quickviewer (SQVI) instead of use SE16

Home


SQL Quickviewer (SQVI) instead of use SE16

Creating a new Query via Transaction Code SQVI

launch the transaction code SQVI.


First enter a useful name, and next press the "CREATE" button.

As an example, I will quickly create a query, called ZBP_ROLES which  I use a lot in the context of SAP CRM Business Partner Role checks, using a Join between the tables BUT000 and BUT100.

This query will allow me to quickly identify following things:

* which BP roles have been maintained for a certain business partners

* which Business partners are maintained with e.g. the role BUP003 (Employee).



In the title, I just entered a relevant explanation for myself...and in the field Data Source,
 I choose  "Table Join" as will want to create my query based on the two tables.


I next push the button "Insert Table" in order to add my first table (BUT000). This table contains general master data for a Business Partner.



Now you see that my first table has been added.



Add the relevant tables and the join will be link automatically



select the fields to used


Pick for “List fields” for fields to display and “Selection Fields” for filtering, click “Execute” to try on the query



Fill up the filtering information and click the “Execute” button



Done.. here you go for the end results. Export it to Microsoft Excel, Access for further usage