cancel
Showing results for 
Search instead for 
Did you mean: 

HANA XSA : hdbvirtualtable dynamic schema name

mani_ac
Participant

Hi,

I have created a virtual table(.hdbvirtualtable) by using and deployed in DEV space

VIRTUAL TABLE "RS_KNA1" AT "REMOTE"."NULL"."SAPDEV"."KNA1" 

It is failing in QA because the schema name is different .

VIRTUAL TABLE "RS_KNA1" AT "REMOTE"."NULL"."SAPQA"."KNA1" <br>

Is it possible to pass schema name dynamically in MTA project and keep the same code across all the environments
(DEV,QA and PROD)

I checked the hdblogicalschema and hdbvirtualtableconfig options but not sure how to achieve it using that.

Can you please guide .

View Entire Topic
pfefferf
Active Contributor

One way can be to define a hdblogicalschema artefact for each environment (including the environment specific settings like the schema). The defined logical schema than can be used in the hdbvirtualtableconfig.

The relevant question is then, how you deploy the specific information to the specific environments. Here for instance the "include-filter" option of the @sap/hdi-deploy - npm (npmjs.com) can be used. With that it can be defined that only the specific environment relevant hdblogicalschema artefact is deployed.

If you have only one virtual table you could apply the same approach for an environment specific hdbvirtualtableconfig artefact.

mani_ac
Participant

Hi florian.pfeffer ,

Thank you for the reply. I have many virtual tables,based on your suggestion I created two DEV.hdblogicalschema and PROD.hdblogicalschema. Then one of my hdbvirtualtableconfig looks like below.;


 {
 	"RS_KNA1": {
 		"target": {
 			"logical_schema": "SAPDEV",
 			"object": "KNA1"
 		}
 	}
 }

But we have to hardcode the logicalschema SAPDEV in the hdbvirtualtableconfig. But here I am not sure how to change this(SAPQA) dynamically when deploying the same mtar to QA and PROD. Because logical_schema should be SAPQA when deploying to QA

Can you please suggest how to specify ?

pfefferf
Active Contributor

The logical schema name must always be the same and should point on the different environments to different (remote) schemas.

For instance:

Logical schema definition for DEV:

{
  "MY_LOGIC_SCHEMA": {
    "target": {
      "remote": "REMOTE1",
      "schema": "SCHEMA1"
    }
  }
}

Logical schema definition for QA:

{
  "MY_LOGIC_SCHEMA": {
    "target": {
      "remote": "REMOTE2",
      "schema": "SCHEMA2"
    }
  }
}

You see the name of the logical schema is the same and can be used in the virtual table configuration statically.

During deployment you can use the include-filter to deploy either the DEV or the QA logical schema definition, depending on the system.

mani_ac
Participant

Thank you florian.pfeffer .

This makes sense. One last question. There are not a lot of examples around --include-filter so I am not sure how to implement include-filter option and pass dynamically when deploying which system it is .

Can you please guide me here.

package.json - But here I am not sure how to give and pass dynamically say DEV or QA

{
"name": "deploy",
"dependencies": {
"@sap/hdi-deploy": "3.11.9"
},
"scripts": {
"start": "node node_modules/@sap/hdi-deploy/deploy.js --auto-undeploy --include-filter src/DEV.hdblogicalschema parameter environment=DEV;"
}
}
pfefferf
Active Contributor

The include-filter option is described in the readme of the @sap/hdi-deploy package.

Regarding the "dynamic" setting in the npm script. Use env variables. Depending on the tooling/setup (e.g. mta) you are using, you have to inject it specifically.

mani_ac
Participant
0 Kudos

Hi florian.pfeffer , Thank you . I tried a whole day with different ways still struggling to achieve this.

I created 3 files with the same name as SPACE name . DEV.hdblogicalschema QA.hdblogicalschema PROD.hdblogicalschema

I tried in mta.yaml to give like this and assumed that $space is prebuilt environment variable but its not working.
Is there a way I can set the file name dynamically? Can you please suggest

path: Database
    requires:
      - name: hdb-container
        properties:
          HDI_DEPLOY_OPTIONS: 
            "auto_undeploy" : true
            "include_filter" : [ "src/${space}.hdblogicalschema" ] 
          TARGET_CONTAINER: '~{hdi-container-name}'