on 2024 Jul 17 12:31 PM
Dear community,
I tried out a tutorial to define a foreign key definition) (until step 11). The defined table looks like this:
@EndUserText.label : 'Table of Bank Accounts'
@AbapCatalog.enhancementCategory : #EXTENSIBLE_CHARACTER_NUMERIC
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #NOT_ALLOWED
define table zaccounts {
key client : abap.clnt not null;
key account_number : abap.numc(8) not null;
@AbapCatalog.foreignKey.keyType : #KEY
@AbapCatalog.foreignKey.screenCheck : false
bank_customer_id : /dmo/customer_id not null
with foreign key [0..*,1] /dmo/customer
where customer_id = zaccounts.bank_customer_id;
bank_name : z_bank_name;
city : /dmo/city;
@Semantics.amount.currencyCode : 'zaccounts.currency'
balance : abap.curr(16,2);
currency : /dmo/currency_code;
account_category : abap.numc(2);
lastchangedat : timestampl;
}
The foreign key-related table /dmo/customer is empty in my system. Thus I should not be possible to insert a new line to zaccounts. However, I can add a line with the following code:
DATA myzaccounts type zaccounts.
DELETE FROM zaccounts.
myzaccounts-account_number = `myaccount`.
myzaccounts-bank_customer_id = 12345.
INSERT zaccounts FROM @myzaccounts.
The code runs without an error and I can see the new line in zaccounts. Shouldn't the insert fail with a foreign key constraint violation?Am I missing something?
Thanks for your help!
Let me try to explain some basic facts.
In ABAP we have two levels of metadata definitions:
In the tutorial, you were working on a DDIC database table, whose properties are described here:
CDS entities are described here:
https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_entities.htm
And finally, RAP is a programming model based on CDS described here:
https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_rap.htm
BTP is a SAP product using these technologies.
ADT is just a tool. It does not make sense to speak about "ADT database tables" or to say "access the ABAP dictionary when developing with ADT". You can edit DDIC objects with ADT and access those in ABAP CDS, ABAP language and with frameworks built with ABAP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for my late reply and thanks for your extensive answer:
So means in a nutshell, when I create a database table in ADT, it is created using DDIC, correct?
If so this would mean when using ADT I do use DDIC but - however, can not make use of the foreign key relationship feature of DDIC. Is this correct?
You still mix the things up.
DDIC (short for ABAP Dictionary) is a metadata repository.
There are two tools for editing metadata such as DDIC database tables of the ABAP Dictionary:
"when I create a database table in ADT, it is created using DDIC," is not correct.
Correct is: "you can use ADT (as well as SE11) to create a DDIC database table".
In fact, the source code that you see in ADT isn't even stored as such but created temporarily from the metadata in the ABAP Dictionary.
And also " using ADT I do use DDIC but - however, can not make use of the foreign key relationship feature of DDIC" simply makes no sense,
ADT is a tool for creating repository objects, not for using them. You use a DDIC database table in ABAP language, in ABAP CDS, in classic dynpros, etc. It depends on the usage in these frameworks, whether a foreign key relationship is considered, not on ADT.
There is no name of the source code to define a DDIC database table in ADT. The source code is created on the fly when you call the editor and deleted after editing.
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenddic_tools.htm
User | Count |
---|---|
69 | |
11 | |
10 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.