database - ERP Q&A https://www.erpqna.com/tag/database/ Trending SAP Career News and Guidelines Fri, 06 Dec 2024 09:12:39 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.1 https://i0.wp.com/www.erpqna.com/wp-content/uploads/2021/11/cropped-erpqna.png?fit=32%2C32&ssl=1 database - ERP Q&A https://www.erpqna.com/tag/database/ 32 32 109149340 Create a SQL user with access to multiple spaces in SAP Datasphere https://www.erpqna.com/create-a-sql-user-with-access-to-multiple-spaces-in-sap-datasphere/ Fri, 06 Dec 2024 09:12:35 +0000 https://www.erpqna.com/?p=88921 Suppose you want to access two SAP Datasphere spaces using the same SQL user, how do you create such a user? That’s what we will go through in this blog post. As an example, we have two spaces as the below screenshot shows. We will create a SQL user that can access both of these […]

The post Create a SQL user with access to multiple spaces in SAP Datasphere appeared first on ERP Q&A.

]]>
Suppose you want to access two SAP Datasphere spaces using the same SQL user, how do you create such a user? That’s what we will go through in this blog post.

As an example, we have two spaces as the below screenshot shows. We will create a SQL user that can access both of these spaces. For this we take the following steps.

  1. Create a Database User Group including an admin user;
  2. Create an SQL user with the new admin user;
  3. Create a Database User for each space;
  4. Grant read access to the views that you want the SQL user to have access to.
Figure 1: Two spaces for which we will create one SQL user with read access to both spaces

Step 1 – Create a Database User Group including an admin user

In the side navigation area of SAP Datasphere, choose System > Configuration > Database Access > Database User Groups. Here, create a Database User Group. This will provide you right away with administrator credentials. If you need documentation on the creation process, go to this help page. In there, there is also a link to the SAP HANA Cloud documentation that describes the Database User Group Concept.

Figure 2: Dialog for creating a Database User Group

Step 2: Create an SQL user with the new admin user

After the Database User Group is created, go to your preferred database client tool to log on with that user. In this blog post we use the SAP Database Explorer. With the admin user, we create a new SQL user. This will be the user getting read access to the two SAP Datasphere spaces.

CREATE USER DWCDBGROUP#READ_SPACES#BOBBY PASSWORD "<A1a etc.>" SET USERGROUP DWCDBGROUP#READ_SPACES

Now log on with the newly created SQL user. Tip: in DB Explorer, you can right click on the existing instance and choose “Add Database with Different User” – then it adds a new user while re-using the instance details, which saves you some time.

Figure 3: Add new Database Instance entry with the newly created SQL user

When we check the views in the two spaces that this user has access to, we see that currently no views are accessible.

Figure 4: The newly created SQL user has no privileges yet on either of the two spaces

Step 3: Create a Database User for each space

To grant read access from the two spaces to this SQL user, you first have to create a Database User in each of the spaces. You do this under Space Management > Database Access > Database Users for each of the spaces. Make sure you tick the checkboxes for Enable Read Access (SQL) and With Grant Option. Deploy the space to activate the user and fetch the credentials.

Figure 5: Dialog to create a Database User for a given space

Step 4: Grant read access to the views that you want the SQL user to have access to

Using the database users created in step 3 – one for each space – we go through the following for each of the spaces.

Check to which views the database user has access. The following statement gives you a list of the views that are exposed for consumption. If you want to add more views, you’ll have to expose them for consumption in the SAP Datasphere view editor.

select OBJECT_NAME from effective_privileges
where SCHEMA_NAME IN ('SEFAN_SALES','SEFAN_HIERARCH2') AND GRANTEE_TYPE = 'USER' AND IS_GRANTABLE = 'TRUE' AND user_name = current_user;

As you can see, this gives us a the list of views exposed for consumption in our space.

Figure 6: List of the views that the space database user has access to

The space database user also has grant select privileges, because we made that setting when creating the user. Therefore, we can fire GRANT SELECT statements and provide our SQL user with read access to the views. You cannot grant access on the entire schema, only on individual objects. SAP Datasphere does not provide you with any user that has full schema access with a grant option. Below we grant the SQL user access to one view.

GRANT SELECT ON SEFAN_SALES."vBusinessPartner" TO DWCDBGROUP#READ_SPACES#BOBBY

When now checking again the list of views with the SQL user, you can see that this view popped up. Below screenshot is made after we repeated all of the above step also for our other space.

Figure 7: Views in the SAP Datasphere space that the SQL user has read access to

Build a procedure to grant access to all consumable views of a space at once

Granting read access to all individual views in a space can be a bit cumbersome, but of course you can automate this by coding a procedure that loops over all consumable views for a space and then grants read access to each view. Below code creates such procedure. Make sure to create the procedure with the Database User Group Admin, and then grant access to that procedure to the database users of the space. These can then execute this procedure.

--execute with ADM user
CREATE OR REPLACE PROCEDURE grant_select_on_objects (
    IN IP_SPACE NVARCHAR(256),
    IN IP_SQL_USER NVARCHAR(256)
)
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
AS
BEGIN
    -- Declare a cursor for the SELECT statement
    DECLARE CURSOR C FOR 
        SELECT SCHEMA_NAME, OBJECT_NAME 
        FROM effective_privileges 
        WHERE SCHEMA_NAME = :IP_SPACE
          AND GRANTEE_TYPE = 'USER'
          AND IS_GRANTABLE = 'TRUE'
          AND USER_NAME = CURRENT_USER;

    -- Variables to hold the fetched data
    DECLARE v_schema_name NVARCHAR(256);
    DECLARE v_object_name NVARCHAR(256);
    DECLARE v_sql NVARCHAR(5000);

    -- Loop through the result set
    FOR cur_row AS C DO
        v_schema_name = cur_row.SCHEMA_NAME;
        v_object_name = cur_row.OBJECT_NAME;

        -- Construct and execute the GRANT statement
        v_sql = 'GRANT SELECT ON "' || v_schema_name || '"."' || v_object_name || '" TO "' || :IP_SQL_USER || '"';
        EXECUTE IMMEDIATE :v_sql;
            
    END FOR;

END;

GRANT EXECUTE ON grant_select_on_objects TO SEFAN_SALES#READ_SPACES;
GRANT EXECUTE ON grant_select_on_objects TO SEFAN_HIERARCH2#READ_SPACES

When the procedure is created, execute it with the space database users as follows:

CALL DWCDBGROUP#READ_SPACES#ADM.grant_select_on_objects('SEFAN_HIERARCH2', 'DWCDBGROUP#READ_SPACES#BOBBY');
CALL DWCDBGROUP#READ_SPACES#ADM.grant_select_on_objects('SEFAN_SALES', 'DWCDBGROUP#READ_SPACES#BOBBY');

As you can see below, the SQL user now has access to the views from both spaces.

Figure 8: Views in the SAP Datasphere space that the SQL user has read access to

Because the access is for individual objects, when you want to add views that have been newly created or exposed since, you’ll have to run the procedure or the individual statements again.

Rating: 5 / 5 (1 votes)

The post Create a SQL user with access to multiple spaces in SAP Datasphere appeared first on ERP Q&A.

]]>
88921
Migrating dangerous goods data in SAP S4/HANA: not as simple as it seems! https://www.erpqna.com/migrating-dangerous-goods-data-in-sap-s4-hana-not-as-simple-as-it-seems/ Wed, 15 Feb 2023 11:05:22 +0000 https://www.erpqna.com/?p=72125 When switching from one system to another, it’s important to make sure that all data is transferred correctly. We ran into some interesting challenges when migrating our own dangerous goods data. Unfortunately, due to the fact that these processes are relatively new in S/4HANA only a small amount of information about it could be found […]

The post Migrating dangerous goods data in SAP S4/HANA: not as simple as it seems! appeared first on ERP Q&A.

]]>
When switching from one system to another, it’s important to make sure that all data is transferred correctly. We ran into some interesting challenges when migrating our own dangerous goods data.

Unfortunately, due to the fact that these processes are relatively new in S/4HANA only a small amount of information about it could be found online. This inspired us to write this blog post to contribute to the community and help others who are struggling with the same difficulties. Think of it as a step-by-step guide for your own data migration.

Below we explain each step in the process of migrating dangerous goods data.

The first step is to create a migration project.

We use the Migrate Your Data app in the Migration Cockpit.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 1: Migrate Your Data – Migration Cockpit

Once you’ve created your migration project and its various migration objects, you can start migrating your dangerous goods data.

Make sure you upload this data in the following order:

  • PC – Product compliance info
  • DG – Assessment for unpackaged products (content-based)
  • DG – Assessment for packaged products

Select your template from the drop-down list for the migration object you want to upload.

Select Download Template -> Download CS Files.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 2: Download the data migration template

Remark

Make sure the material is compliance-relevant before you start uploading. You can change this setting in the material master data. Open the Manage Product – Master Data app.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 3: Manage Product – Master Data

Select your material and click Edit. You can now make changes in the Product Compliance tab.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 4: Decide if your product is compliance-relevant or not

Product compliance Info

The first two tabs (Introduction and Field List) contain useful information about this process, so be sure to read through it carefully. Because this information is so thorough, I won’t discuss it here.

The most important tab in this file is Chemical Compliance View, which contains the following columns.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 5: Excel file Product Compliance Info

Start by entering the Internal Number. This is a unique code containing letters (A-Z) and up to 80 characters. This number is for internal use only and will not be shared with clients or external parties.

You can enter the number in the following path:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 6: Path to customising internal number range
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 7: Define internal number range

The second column (Responsible Unit) shows the group of employees responsible for the specific packaged or unpackaged product. You can configure this information in the following path:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 8: Path to customising responsible units for dangerous goods
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 9: Define responsible units for dangerous goods

The third column (Responsible Unit for Dangerous Goods) can have the same value as the previous column.

The next tabs (until the Product Master Assignment) can be populated with information about the product itself.

In the tab Product Master Assignment you can link the internal number you just entered to the product number. This product number is a unique code derived from the product master that can be shared with clients.

In the next column you can choose to enter an X or to leave it blank. If you enter an X, it will retrieve the name from the product master linked to the product number.

The next three tabs contain optional information that does not have to be entered for a successful upload process. In the last tab you can assign a ‘goal’ to your product. Enter the unique internal number (A-Z) and link it to a goal. This can be a goal defined in the system.

Once you have double-checked all entered data, save it as an XML file. You can also save it as an XLS file if you want to make changes to it later.

Now you can start the upload process.

Go to the migration object and click Upload File.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 10: Step 1 in the data upload

Click Upload.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 11: Upload your XML file

Select the file you just created.

If you selected the right template, a successful transfer notification will appear.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 12: Success notification

When you return to the main menu, the system will automatically recommend the next step:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 13: Step 2 in the data upload

Click on Prepare. The following message will appear:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 14: Preparing staging tables

Click on Prepare Staging Tables.

The following message will appear:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 15: Information message during the preparing of the staging tables

Click on the Monitoring tab to see the status.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 16: How to open the monitoring view

If any errors appear, they can be viewed in detail here.

These errors must first be resolved before the process can continue.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 17: Success notification

If the staging tables were successfully uploaded, the system will suggest the next step:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 18: Step 3 in the data upload

Click here to confirm any statuses. This is not always necessary.

Once you’ve completed this process, the system will suggest the next step:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 19: Step 4 in the data upload

Select Start Simulation.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 20: Starting the simulation

A message will appear when the process has started.

Return to the Monitoring tab to view the status and check for any errors.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 21: Simulation notification

If there are no errors, the following notification will appear:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 22: Success notification

In the Options column, click Show Messages for a detailed overview of the upload process.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 23: Additional option to see all the details

Open the My Unpackaged Dangerous Goods app

and click To Be Classified for an overview of your materials.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 24: App to see result after uploading the product compliance file
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 25: Result after uploading the product compliance file

Unpackaged product

Once you complete this step, you can continue uploading the next file: Assessment for Unpackaged Products (Content-Based).

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 26: Excel file Assessment for Unpackaged Products (Content-Based)

Before the release of SAP S/4HANA 2020, you had to upload the text-based regulation and enter the dangerous goods texts in different languages. The current content-based regulation contains all information for the UN numbers.

Like the previous file, this one also includes an introduction tab. Be sure to read this information carefully.

In the first tab (Product), enter the internal number of the unpackaged product. This is a unique code containing letters (A-Z) and up to 80 characters. This number is for internal use only and will not be shared with clients or external parties. It is the same number as the one in the first tab of the Product Compliance file (Chemical Compliance View). The same number must be entered in the Purpose Management tab.

In the second tab (Basic Classification), enter the same internal number as in the previous tab.

In the second column (Compliance Requirement Version ID), enter an R value for the transport type. For example: R00925 is linked to ADR R00926 with IMDG.

This information can be found in the Manage Compliance Requirements app. The field containing these values is called the ID of the Business Configuration Object. This is hidden by default and can be opened in the Settings tab (see Figure 28).

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 27: Manage Compliance Requirements – Dangerous Goods app
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 28: How to add the ID of the business configuration object

The third column must be populated according to the process status of the classification. This is a required field with two possible options: RE for ‘released’ and IP for ‘in progress’. In the Transport Permissions column, 01 stands for ‘allowed’ and 02 stands for ‘not allowed’.

The next column concerns whether a product can be classified as a dangerous good. If you enter 01, it will not be classified as a dangerous good. If you enter 02, it will be classified as a dangerous good. The ID is a four-digit number used to identify dangerous substances during transport.

In the next column, enter the prefix that precedes the identification of the dangerous good. This is usually UN, NA or ID.

In the Packaging Group field, enter a Roman numeral from the Product Safety Data Sheet. Finally, enter the variant from the Dangerous Goods List. This is only required if a UN number is linked to multiple variants in the regulation (e.g. if a product is transported by road and water, it is subject to two different regulations). You can find this information in the Manage Compliance Requirements – Dangerous Goods app.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 29: Manage Compliance Requirements – Dangerous Goods app

Go to the tab Dangerous Goods List. This setting is hidden by default but can be made visible in settings.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 30: How to add the variant

Repeat the same migration steps you took for the Product Compliance Info file. Use the migration object DG – Assessment for Unpackaged Product (Content-Based).

The technical product name can also be added. In our example we chose not to do this. This information can be found in the Product Safety Data Sheet.

You can find your material in the My Unpackaged Dangerous Goods app.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 31: My Unpackaged Dangerous Goods app

Go to the app Analyse Unpackaged Dangerous Goods.

Here you will find your material and the associated data you uploaded.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 32: Analyse Unpackaged Dangerous Goods app
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 33: Details unpackaged dangerous goods

Packaged product

When this data has been successfully migrated, you can move on to the final step: migrating the packaged product. Just like the previous files, the first tab contains an introduction with a lot of useful background information.

The Product tab contains the following fields:

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 34: Excel file assessment for packaged product

Enter the internal number here. In the next column you can describe the outer packaging. The column after that displays the total quantity of the outer packaging.

Enter the units of measure in the next table. You can also enter a description of the inner packaging, if applicable. Sometimes, dangerous goods are transported in single-layer packaging, depending on the quantity and the mode of transport.

In this case, there is no need to mention the outer packaging. This information can be found on the Product Safety Data Sheet.

As with the outer packaging, enter the quality and units here, as well as the number of units in a single outer packaging.

Go to the Regulations tab.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 35: Excel file: Assessment for Packaged Product

In the first column, enter the internal number to create the link. The other columns can be filled in the same way using the information about the unpackaged file.

Go to the Modes of Transport tab.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 36: Modes of Transport tab in the file Assessment for Packaged Product

Create a link to the internal number. Enter the ID number, depending on the transport mode. See the previous sections above to find out where this information can be located.

Complete the other columns as described.

Once you have entered all information, you can start the upload process. Follow the same steps as the previous files. Use the migration object DG – Assessment for Packaged Product.

For results, go to the app My Packaged Dangerous Goods – to Be Classified.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 37: My Packaged Dangerous Goods – To be Classified

Here you can follow your progress. Once everything has been uploaded correctly, it will be removed from the My Packaged Dangerous Goods – To Be Classified list.

SAP S/4HANA Migration Cockpit, SAP S/4HANA Cloud Master Data
Figure 38: Progress during upload packaged products
Rating: 0 / 5 (0 votes)

The post Migrating dangerous goods data in SAP S4/HANA: not as simple as it seems! appeared first on ERP Q&A.

]]>
72125