'How to get HDI Container Schema from ABAP?

I need to dynamically get the SCHEMA name to access one table in HDI Container from ABAP.

is there any table in hana that I can select the SCHEMA?

I already can select if I put the schema, but the schema of HDI change in each System.



Solution 1:[1]

I may have misunderstood your exact requirement but function module DB_DBSCHEMA will give you the current schema for the HDB instance your ABAP is pointing to.

Alternatively, this code will provide an internal table of all schemas ...

TYPES:
  BEGIN OF typ_schemas,
    schema_name TYPE string,
  END OF typ_schemas.

DATA:
  lo_sql       TYPE REF TO cl_sql_statement,
  lv_sql       TYPE string,
  lt_schema    TYPE STANDARD TABLE OF typ_schemas.

CREATE OBJECT lo_sql.

lv_sql = |SELECT * FROM "PUBLIC"."SCHEMAS"|.

DATA(lo_result) = lo_sql->execute_query( lv_sql ).
lo_result->set_param_table( REF #( lt_schema ) ).
lo_result->next_package( ).
lo_result->close( ).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1