Attention: The content of this blog was not created by SAP. It was written by a non-SAP consultant, Arvind Lachhireddy (HANA Consultant, Pythian) to help your migration journey to the cloud. Therefore, please keep in mind that it might take some more time to get answer for your question in case you leave any to this blog.
The SAP HANA XS Advanced Migration Assistant tool is used to convert XS ”classic” code and SAP HANA Repository database content (e.g., Calc Views) to the format and syntax for XS Advanced (XSA) and SAP HANA Deployment Infrastructure (HDI). However, several common issues may be encountered when deploying the converted objects to SAP BTP Cloud Foundry and SAP HANA Cloud.
This article describes how to update your converted artifacts to remediate some of these common issues before deploying the converted code into the target environment. In the sections and screenshots below, we are using SAP Business Application Studio (BAS) to make the required code changes.
1. Calculation Views
If your original content in the SAP HANA Repository was organized under multiple packages and sub-packages, you might choose to split the conversion into chunks at the package level when you run the XSA migration utility. This will result in splitting your content across multiple separate HDI containers which will have an impact on data source references in the converted code.
All calculation views are dependent on various other database objects such as tables, views, procedures, functions, and so on. The first thing we need to check is whether the namespace for the calculation view is the same as in the dependent object(s) that have been migrated and deployed.
Here, package1.SchemaName:: is the schema reference generated by the XSA migration utility. Please check on the object name as in the database (along with namespace if configured). If there is a change in the object reference the view will throw an error of missing objects during deployment.
Alternatively, you can use the text editor in BAS to change the reference. Locate the resource URI XML tag and find the package reference. Then change it appropriately according to the namespace (if used).
In addition, if there is any date() function used in the calculation in Calculation Views and Table Functions, those need to be replaced with the daydate() function, since the date() function is not supported in SAP HANA Cloud.
2. Stored Procedures
In SAP HANA Cloud, the UPDATE … FROM <table> SQL syntax is not supported. Instead, the MERGE INTO syntax (added as of SAP HANA 2.0) can be used for any update scenario that was previously implemented using the UPDATE FROM syntax. For more information, see MERGE INTO Statement (Data Manipulation).The DML statement in the screenshot above using the UPDATE FROM syntax is not supported in SAP HANA Cloud and will give the error shown below:To address this, the UPDATE FROM statement must be replaced by MERGE INTO as shown below.
In some scenarios, a developer may have chosen to use the TRUNCATE statement to perform a delete of all data in a table or partition (Note: TRUNCATE should be used with caution because it is irreversible and cannot be rolled back if the transaction fails). If the objects you are truncating are in the same HDI container as the procedure, then the TRUNCATE statement will work and no adjustment is needed.
However, if you’re using a synonym to reference a table in another HDI container or external schema, then TRUNCATE will not work and will throw an error. So, you will then need to modify your code accordingly.
In this case, if you replace the TRUNCATE statement with the DELETE FROM statement, as shown below, then the deployment will be successful.
NOTE: The DELETE FROM statement can be a reasonable replacement for TRUNCATE on small and mid-sized tables. However, if you have specific reasons for using the TRUNCATE statement and require its use, then you can instead create a procedure within the target HDI container or schema (i.e., where the table is present) to execute the TRUNCATE statement there. Then you can call the custom truncate procedure remotely using a synonym from your container and procedure.
Typically, there are few complications or issues when deploying migrated table functions and scalar functions. However, these objects are often dependent on other objects such as tables, calculation views, and/or procedures. So, you must deploy the dependent objects with the proper namespace referenced in the table function.
In the below example, as we see in calculation views, the function uses a schema reference. This needs to be corrected by referring to the appropriate database object names in the migrated environment to avoid ”unknown object” errors during deployment
To correct the invalid reference, remove the old (”classic”) package namespace from the object name and replace the object name with the exact object name present in the migrated database.
4. SDI Flowgraphs
To illustrate the scenario we can see the source and converted codes below.
5. Replication Tasks
If the remote source is available but the reptask is not connected to it, this can be an issue with the access privileges. Access has to be granted to the remote source by adding the missing remote source in the grants file and deploying it.
These are just a few tips and hints to help you with the migration of your ”classic” SAP HANA database content for deployment to SAP HANA Cloud.
Please feel free to leave any comments/questions. It might take some time as this content is not from SAP, but we will do our best to get back to you with accurate and reliable information.