Skip to Content
0
Jul 04, 2019 at 01:30 PM

How to reference user defined data types in .hdbtabletype?

128 Views Last edit May 21, 2020 at 05:56 PM 2 rev

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