Skip to Content

How to reference user defined data types in .hdbtabletype?

In CDS, user defined types can be referenced as a type in structured types. Can a user defined type be used in .hdbtabletype?

In hdbcds, this can be achieved as mentioned below. Help Docs

MyStruct is a table type which uses MyString80 and MyInteger as derived types.

namespace Pack1.Pack2; 

context MyModel
{
  type MyInteger  : Integer;
  type MyString80 : String(80);

  table type MyStruct  
  {
    aNumber   : MyInteger;
    someText  : String(80);
    otherText : MyString80;
  };

};

But if you would like to use hdbtabletype to create the type, how can the same be achieved? I would like to continue using the derived type like following example rather than define the column type in every table type.

MyModel.hdbcds

namespace Pack1.Pack2; 

context MyModel
{
  type MyInteger  : Integer;
  type MyString80 : String(80);
};

MyStruct.hdbtabletype

TYPE "Pack1.Pack2::MyModel.MyStruct" AS TABLE (
   "aNumber" "Pack1.Pack2::MyModel.MyInteger", 
   "someText" "Pack1.Pack2::MyModel.MyString80", 
   "otherText" "Pack1.Pack2::MyModel.MyString80"
)

But this doesn't work.

Is this approach possible?

Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jul 04, 2019 at 04:48 PM

    HI Ashish Singh,

    As far as I can tell, you cannot mix the user-defined type from your Data Persistence Artifacts with CDS with the one in SQL DDL.

    In the end, the user-defined type from your Data Persistence Artifacts with CDS is never created as a database object of any sort. So the SQL DDL artifact cannot reference it.

    My advice to you (for what it worth) is actually to decide whether you want to use Data Persistence Artifacts with CDS or SQL DDL and stick to one approach only.

    Best regards

    @bdel

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.