cancel
Showing results for 
Search instead for 
Did you mean: 

SPS6 Core Data Services - created catalog table column order different from hdbdd entity

former_member182500
Contributor
0 Kudos

Hi,

Implementing CDS DDL on AWS SPS6 and note that when activating the hdbdd the created table entity has columns in an order other than it's specification within the hdbdd - specifically multiple fields defined by a type in the hdbdd that are directly after the key fields are ordered last in the actual catalog table.

For example in the hdbdd I have :

type CreatedHistoryT {

                        CreatedBy                                                                                : UserT;

                        CreatedAt                                                                                : SDateT;

               };

context Purchase {

                     @Catalog.tableType : #COLUMN

Entity Header {

                                                   key PurchaseOrderId                               : PurchaseOrderIdT;

                                                   CreatedHistory                                                  : CreatedHistoryT;

                                                   SupplierId                                                            : SupplierIdT;

                                                   nullable SupplierRef                              : SupplierRefT;

                                                   Currency                                                            : CurrencyT;

                                                   nullable StatusId                                        : StatusIdT;

                                  };  

And despite the CreatedHistory being specified directly after the key, the two fields CreatedBy and CreatedAt show as last two columns in the catalog table.

This obviously does not help when for eample creating CSVs for master data load and the CSV matches the data definition column for column but fails upon load via the hdbti due to column mismatch with catalog object.  I can of course change column order in CSV to match catalog, however......

Interestingly I sway towards assuming this is a known "feature" of SPS6, as from the CDS unit video, presented by Thomas Jung on the OpenSAP Hana course, the table types ValidityT, used in the addresses entity for example, is given at the end of the entity specification.  Fortune would have it specification and catalog object will match.  I dont see an example where table type specified somewhere other than end of entity specification.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Jon-Paul,

I've started working with CDS just now and I encounter this problem as well. But I noticed that the fields are included in the end if you included them after the table creation probably because they do an ALTER TABLE.

For example: If I create an entity like

Entity Example1 {

     key ID: Integer;

           DESC: String(60);

}

It'll create a table like this:

ID

DESC

But, if I edit and activate the .hdbdd file like this:

Entity Example1 {

     key ID: Integer;

           TEST: String (50);

           DESC: String(60);

}

It'll alter the table like this:

ID

DESC

TEST

I think the "correct" way would be drop and create the table again if you changed the order of the columns. But if they did that the Data would be lost (unless they did some temp table to store the table during the activation).

So I think if you would like to change the order of the columns, you'd have to manage the data, drop the table and then activate the .hdbdd file again.

Regards,

Rodrigo P.

former_member182500
Contributor
0 Kudos

Hi Rodrigo,

See this thread, which details further. 

http://scn.sap.com/message/14269656#14269656

Word of warning - DO NOT drop the table manually in SQL console, otherwise catalog and repository will be out of sync and you will have issues recreating the catalog artefact again from the HDBDD.  Control it all from the HDBDD i.e. comment out the table definition, activate (to effectively drop within control of CDS), uncomment and activate.

Former Member
0 Kudos

Great post!

Thanks!