ABAP has 3 categories of Data Types:
- Predefined Data Type / ABAP Standard Type / ABAP Type:
- Complete ABAP standard types (Doesn't need to specify length)
- D - Date, YYYYMMDD, length 8 bytes, fixed.
- T - Time, HHMMSS, length 6 bytes, fixed.
- I - Integer, lenght 4 bytes, fixed.
- = 32 bits = 10 digits and 1 +/- sign, MinMax value is +- 2,147,483,647.
- F - Floating point number (F), 8 bytes.
- For scientific calculation purpose, it provides approximate value with rounding error.
- should avoid using this for any business calculation.
- STRING - dynamic length character string.
- XSTRING - dynamic length byte sequence (HeXadecimal String).
- Incomplete ABAP standard types (Length must be specified for the data objects)
- C - Character string
- N - Numerical Character
- This guy is odd, he is character that detects and accepts only numeric (0-9) value from Left Hand Side. Pattern King!
- X - Byte Sequence (HeXadecimal String)
- P - Packed Number
- This guy won't mess up with any rounding errors, because it's using fixed point arithmetic.
- Use it for any business calculation.
- But you have to specify the length and decimals for it.
- Valid Length is from 1 to 16.
- Valid Decimals ranged from 0 to 14. (Zero-decimals will convert it behave like Integral [auto round up and down])
- Local Type
- Apparently, you define and declare the Data Type, and use it to type data objects within the program.
- Global Type
- Obviously, you define your Data Type in ABAP Dictionary, and it can be used throughout the entire SAP system.
DATA: dataObject TYPE data type.
Example 1 with predefined data type:
DATA: lv_dataObjTYPE P LENGTH 5 DECIMALS 2.
Example 2 with local type:
Within your program,
TYPES: abc TYPE P LENGTH 5 DECIMALS 2.
DATA: lv_dataObj TYPE abc.
Example 3 with global type:
Go to ABAP Dictionary: Initial Screen with command SE11 and define your data type, for e.g. def.
In your program,
DATA: lv_dataObj TYPE def.
Please feel free to drop your comments!
No comments:
Post a Comment