Search code examples
t-sqlplsqlabapsap-data-dictionary

ABAP Domain and Data Types Understanding


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


Solution

  • 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"