Showing posts with label export. Show all posts
Showing posts with label export. Show all posts

Thursday, 20 March 2025

how to export and import all users in SAP HANA using export and import option in HANA studio

Exporting and importing all users in SAP HANA can be done using the SAP HANA Studio or the SAP HANA Database Explorer. Below are the steps to export and import users using the export and import option in HANA Studio:

---

### **Exporting Users in SAP HANA**
1. **Open SAP HANA Studio**:
   - Launch SAP HANA Studio and connect to your HANA system.

2. **Open the Export Wizard**:
   - In the **Systems** view, right-click on the HANA system you want to export users from.
   - Navigate to **Export** > **Catalog Objects**.

3. **Select Export Type**:
   - In the Export Wizard, choose **Users** as the object type to export.
   - Click **Next**.

4. **Specify Export Options**:
   - Select the users you want to export. You can export all users by selecting the appropriate option.
   - Choose the export format (e.g., SQL script or CSV).
   - Specify the file path where the export file will be saved.
   - Click **Next**.

5. **Review and Export**:
   - Review the selected options and click **Finish** to start the export process.
   - The users will be exported to the specified file.

---

### **Importing Users in SAP HANA**
1. **Open SAP HANA Studio**:
   - Launch SAP HANA Studio and connect to the target HANA system where you want to import the users.

2. **Open the Import Wizard**:
   - In the **Systems** view, right-click on the HANA system.
   - Navigate to **Import** > **Catalog Objects**.

3. **Select Import File**:
   - Browse to the location of the exported file (e.g., SQL script or CSV) containing the user data.
   - Click **Next**.

4. **Specify Import Options**:
   - Choose the appropriate import options (e.g., overwrite existing users or skip conflicts).
   - Click **Next**.

5. **Review and Import**:
   - Review the selected options and click **Finish** to start the import process.
   - The users will be imported into the target HANA system.

---

### **Notes**:
- **Permissions**: Ensure you have the necessary privileges (e.g., `USER ADMIN` or `ROLE ADMIN`) to export and import users.
- **Passwords**: User passwords are not exported for security reasons. You will need to reset passwords after importing users.
- **Roles and Privileges**: If you want to export/import roles and privileges along with users, you may need to export/import those separately.

---

### **Alternative Method: Using SQL Scripts**
You can also use SQL scripts to export and import users:
1. **Export Users**:
   - Generate a script to create users using SQL commands like `SELECT 'CREATE USER ' || USER_NAME || ' PASSWORD <new_password>;' FROM USERS;`.
   - Save the script to a file.

2. **Import Users**:
   - Execute the script in the target system to create the users.

---

Let me know if you need further clarification!

how to export and import sap hana database users in system refresh

During a system refresh in SAP HANA, you may need to export and import database users to ensure that the target system has the same user configurations as the source system. Below is a step-by-step guide to export and import SAP HANA database users:

---

### **Step 1: Export Users from the Source System**

#### **Option 1: Export Users Using SQL Scripts**
1. **Generate the List of Users:**
   Run the following SQL query in the source system to generate a list of users and their roles:
   ```sql
   SELECT USER_NAME, CREATE_TIME, LAST_SUCCESSFUL_CONNECT, VALID_FROM, VALID_UNTIL
   FROM USERS
   WHERE USER_NAME NOT IN ('SYS', 'SYSTEM', '_SYS_REPO', '_SYS_STATISTICS');
   ```

2. **Export User Roles and Privileges:**
   Use the following SQL query to export user roles and privileges:
   ```sql
   SELECT GRANTEE, GRANTED_ROLE, IS_GRANTABLE
   FROM GRANTED_ROLES;
   ```

3. **Generate SQL Scripts for User Creation:**
   Create a script to generate `CREATE USER` and `GRANT` statements for all users:
   ```sql
   SELECT 'CREATE USER "' || USER_NAME || '" PASSWORD "InitialPassword" NO FORCE_FIRST_PASSWORD_CHANGE;'
   FROM USERS
   WHERE USER_NAME NOT IN ('SYS', 'SYSTEM', '_SYS_REPO', '_SYS_STATISTICS');
   ```

   Save the output as a SQL script (e.g., `create_users.sql`).

4. **Export the Script:**
   Save the generated SQL script to a file for later use.

---

#### **Option 2: Export Users Using SAP HANA Cockpit**
1. Log in to the SAP HANA Cockpit.
2. Navigate to **Security** > **Users**.
3. Export the list of users and their roles to a CSV or Excel file.

---

### **Step 2: Import Users into the Target System**

#### **Option 1: Import Users Using SQL Scripts**
1. **Execute the SQL Script:**
   Run the SQL script generated in Step 1 (e.g., `create_users.sql`) in the target system to create the users.

2. **Grant Roles and Privileges:**
   Execute the `GRANT` statements to assign roles and privileges to the users.

   Example:
   ```sql
   GRANT "ROLE_NAME" TO "USER_NAME";
   ```

3. **Verify User Creation:**
   Check that the users and roles have been correctly imported:
   ```sql
   SELECT * FROM USERS;
   SELECT * FROM GRANTED_ROLES;
   ```

---

#### **Option 2: Import Users Using SAP HANA Cockpit**
1. Log in to the SAP HANA Cockpit in the target system.
2. Navigate to **Security** > **Users**.
3. Use the **Import Users** option to upload the CSV or Excel file exported from the source system.

---

### **Step 3: Post-Import Steps**
1. **Reset Passwords:**
   After importing users, reset their passwords to ensure security:
   ```sql
   ALTER USER "USER_NAME" PASSWORD "NewPassword";
   ```

2. **Validate User Access:**
   Test user logins and verify that they have the correct roles and privileges.

3. **Check System-Specific Users:**
   Ensure that system-specific users (e.g., `SYS`, `SYSTEM`) are not overwritten during the import process.

---

### **Step 4: Automate the Process (Optional)**
If you frequently perform system refreshes, consider automating the export and import process using:
- **SAP HANA SQL Scripts**: Write a script to export and import users.
- **SAP HANA CLI (hdbsql)**: Use command-line tools for automation.
- **SAP HANA Transport Management**: Use transports to move users and roles between systems.

---

### **Important Notes:**
- **Passwords**: Passwords are not exported during the process. You will need to reset them in the target system.
- **System Differences**: Ensure that the source and target systems are compatible (e.g., same SAP HANA version).
- **Backup**: Always take a backup of the target system before performing a system refresh.

By following these steps, you can successfully export and import SAP HANA database users during a system refresh.

Tuesday, 24 November 2020

Client export and import

 Pre- requisites for client export and import:

  • Check the size of client using report rsspacecheck.
  • Login credentials for both source and target client and their authorization.
  • Source SAP system and Target SAP system should be same version inclusing TP tool and R3 trans.
  • Check for TMS configuration.
  • There must not be any background job running or in released status in the SAP system (SM37).

Process:

source system:

  • Run the T-code: SCC8
  • select the correct profile and description
  • select the target system details(Namesake)
  • schedule as background job
  • conform the pop up based on profile selected.
  • check the SCC3 logs.

TR files will be generated in /user/sap/trans/cofiles
                                      /user/sap/trans/data      

move the above data,cofile & text file to respective location in the target system @ OS level.

target system:

Run t-code: stms_import
Navigate to  Extras > Other Requests > Add, ---> enter the TR number.
import the TR.
Run scc7
check logs in scc3

Wednesday, 15 May 2019

SAP HANA COCKPIT NOTES 17: EXPORT RESOURCES

Export Resources


Export registration information about resources in the form of a file you can use to import the resources into another system. 

Prerequisites

  • Your cockpit user has the assigned role Cockpit Resource Administrator
  • The resources you're exporting are running and available on the network.