0

so my company wants me to learn ABAP for SAP and I have started on the road to learn this. My background is mainly VB.net and sqlserver with T-SQL but also have experience in c#.

With ABAP though I am needing some clarification or confirmation on the understanding of Data Types and Domain. If anyone can help.

My understanding currently is we have a table, in the table we have fields and the fields have data types and lengths if needed. Example: We have a table Customer, I could have a customerNumber field with the data type of char(10). To me this mean in the table customer we have a field called CustomerNumber that will have 10 characters.

However with ABAP we have Domains, Data elements then the field, does this mean we have a field named whatever we want. As the field could mean anything we assign a data element which has the descriptions of the sort of data stored within the field. However to store the format and data type we need to assign the Domain to the Data element.

For example I call a field ZCUSNO, currently this means nothing however if I assign the ZCTNMR (with description of customer number) Data element this tells us that the field ZCUSNO is ZCTNMR so ZCUSNO is a customer number field.

Now within the data elements we would have a domain and for our example ZCTNMR data element (the customer number) we could assign ZCTDOM as the domain which would be what I recognise as the data types so Char 20, Char 100 or integer field etc.

Is my understanding correct on this? and could someone give me a clear indication of what the difference between a Domain > Data Element is against what I would know as data types in sqlserver.

Thanks

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
altaaf.hussein
  • 274
  • 2
  • 13
  • I have 2 remarks. **1)** In your example, your table has the column `ZCUSNO`. Its Z prefix is useless/incorrect. If it's in a custom table, the Z prefix is useless (and so not recommended). If it's appended to the columns of a standard table, then the prefix should be ZZ (or YY) according to the SAP naming recommendations. **2)** Both the data element and domain are not mandatory anymore but they should be used most of the time to achieve a good modeling **PS:** the answer by I.B.N. is the best according to me because it answers clearly your question. – Sandra Rossi Aug 10 '18 at 17:22
  • also answers there : https://answers.sap.com/questions/593605/abap-domain-and-data-types-understanding.html – Sandra Rossi Aug 11 '18 at 12:21

3 Answers3

5

I don't know if it's 100% correct, but that's is the way I use, like you say.

You can reuse the Domain, If you don't plan to reuse you can use direct the Data Element and refer this to a built-in-type.

  • Data Element is to define semantic of the field, like label, translation, etc
  • Domain is to define techinical info of the field, like Type, conversions, predefined Values,e tc

E.G.

Domain:

  • DOM_VALUE you define it's 10 position and 2 Decimals

Data Element:

  • UNIT_VAL you refer it to DOM_VALUE and define label as "Unit Value"
  • TOTAL_VAL you refer it to DOM_VALUE and define label as "Total Value"
Community
  • 1
  • 1
I.B.N.
  • 992
  • 4
  • 15
2

Your understanding is pretty correct and not much can be added here.

You should clearly get the main thing.

  1. Domains store technical data (decimal points, length, type, predefined values and so on)
  2. Data elements store semantic data (labels, texts, search help binding, etc.)

Not every table field has data element (they can possess builtin type) but every field has type (either primitive or wrapped in data element).

enter image description here

If you wanna use your field in screens (Dynpros), ALV grids or other reports, then create data elements that will bear business meaning of your field.

If you use this field just for calculations or other utility internal tasks, then don't bother yourself.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
0
  1. As usual table date field (type of variable) uses data element which uses domain.
  2. When you create fields in table and use predefined types instead of data elements you will have some problems in future, when you'll need to see the data on alv_grid. Actually, you will see that you have some problems even before this (when you will try to make a maintenance view the header will have something like "+" symbol).
  3. And of course we usually try to create 1 domain for 2 and more Data Elements.
  4. In domain you talk about main logic. In Data Element I always talk about Field label settings (how it'll show in future and some other things)

Final: Actually, the good practice, as I think to create a domain for data element, it may help you in future.

I hope that it helps you. Good luck!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
letronas
  • 145
  • 1
  • 13