‎2008 Feb 06 2:59 AM
What is the difference between text field(C) and numeric text field (N), and hexadecimal type(X) ?
what is the difference between packed number and floating number?
what is meaning of field length?
‎2008 Feb 06 3:20 AM
Float Data Type: It cannot be declared in Parameters.
Packed Number: It can be declared in Parameters.
For e.g.
PARAMETERS : A(4) TYPE P DECIMALS 2,
B(4) TYPE P DECIMALS 2.
DATA : C(4) TYPE P DECIMALS 2.
C = A + B.
WRITE : / �THE SUM IS� , C.
Packed numbers - type P
Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.
You can use type P data for such values as distances, weights, amounts of money, and so on.
Floating point numbers - type F
The value range of type F numbers is 1x10*-307 to 1x10*308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating point arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.
You use type F fields when you need to cope with very large value ranges and rounding errors are not critical.
Using I and F fields for calculations is quicker than using P fields. Arithmetic operations using I and F fields are very similar to the actual machine code operations, while P fields require more support from the software. Nevertheless, you have to use type P data to meet accuracy or value range requirements.
Also check this link for more details.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/content.htm
‎2008 Feb 06 3:20 AM
Hi,
Predefined ABAP Types
These data types are predefined in the R/3 System kernel, and are visible in all ABAP programs. You can use predefined types to define local data types and objects in a program and to specify the type of interface parameters and field symbols.
Predefined Elementary ABAP Types with Fixed Length
These predefined elementary data types are used to specify the types of individual fields whose lengths are always fixed at runtime. The following table shows the different fixed-length data types. All field lengths are specified in bytes.
Data Type
Initial
field length
Valid
field length
Initial value
Meaning
Numeric types
I
4
4
0
Integer (whole number)
F
8
8
0
Floating point number
P
8
1 - 16
0
Packed number
Character types
C
1
1 - 65535
' '
Text field
(alphanumeric characters)
D
8
8
'00000000'
Date field
(Format: YYYYMMDD)
N
1
1 - 65535
'0 0'
Numeric text field
(numeric characters)
T
6
6
'000000'
Time field
(format: HHMMSS)
Hexadecimal type
X
1
1 - 65535
X'0 0'
Hexadecimal field
Data types D, F, I, and T describe the technical attributes of a data object fully. Data types C, N, P, and X are generic. When you use a generic type to define a local data type in a program or a data objet, you must specify the field length and, in the case of type P, the number of decimal places. When you user generic types to specify the types of interface parameters of field symbols, you do not have to specify the technical attributes.
The initial value (and initial field length in the case of the generic types), are values that are used implicitly in short forms of the TYPES and DATA statements.
The fixed-length predefined types are divided into:
Numeric Types
As well as the five non-numeric types (text field (C), numeric text field (N), date field (D), time field (T), and hexadecimal field (X)), there are three numeric types, used in ABAP to display and calculate numbers. Data type N is not a numeric type. Type N objects can only contain numeric characters (0...9), but are not represented internally as numbers. Typical type N fields are account numbers and zip codes.
integers - type I
The value range of type I numbers is -2*31 to 2*31-1 and includes only whole numbers. Non-integer results of arithmetic operations (e.g. fractions) are rounded, not truncated.
You can use type I data for counters, numbers of items, indexes, time periods, and so on.
Packed numbers - type P
Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.
You can use type P data for such values as distances, weights, amounts of money, and so on.
Floating point numbers - type F
The value range of type F numbers is 1x10*-307 to 1x10*308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating point arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.
You use type F fields when you need to cope with very large value ranges and rounding errors are not critical.
Using I and F fields for calculations is quicker than using P fields. Arithmetic operations using I and F fields are very similar to the actual machine code operations, while P fields require more support from the software. Nevertheless, you have to use type P data to meet accuracy or value range requirements.
Character types
Of the five non-numeric types, the four types C, D, N, and T are character types. Fields with these types are known as character fields. Each position in one of these fields takes up enough space for the code of one character. Currently, ABAP only works with single-byte codes such as ASCII and EBCDI. However, an adaptation to UNICODE is in preparation. Under UNICODE, each character occupies two or four bytes.
Hexadecimal Type
The remaining non-numeric type - X - always interprets individual bytes in memory. One byte is represented by a two-digit hexadecimal display. The fields with this type are called hexadecimal fields. In hexadecimal fields, you can process single bits.
Predefined Elementary ABAP Types with Variable Length
These predefined elementary data types are used to specify the types of individual fields whose lengths are not fixed until runtime. There are two predefined ABAP data types with variable length that are generically known as strings:
STRING for character strings
A string is a sequence of characters with variable length. A string can contain any number of alphanumeric characters. The length of a string is the number of characters multiplied by the length required for the internal representation of a single character.
XSTRING for byte strings
A byte string is a hexadecimal type with variable length. It can contain any number of bytes. The length of a byte string is the same as the number of bytes.
When you create a string as a data object, only a string header is created statically. This contains administrative information. The actual data objects are created and modified dynamically at runtime by operational statements.
The initial value of a string is the empty string with length 0. A structure that contains a string is handled like a deep structure. This means that there are no conversion rules for structures that contain strings.
Predefined Complex Data Types
ABAP contains no predefined complex data types that you can use to define local data types or data objects in a program. All complex data types are based on elementary ABAP
types, and are constructed in ABAP programs or in the ABAP Dictionary.
Field length specifies amount of memory space needed for data type
Regards
‎2008 Feb 06 3:36 AM
hi,
the five non-numeric types (text field (C), numeric text field (N), date field (D), time field (T), and hexadecimal field (X)), there are three numeric types, used in ABAP to display and calculate numbers. Data type N is not a numeric type. Type N objects can only contain numeric characters (0...9), but are not represented internally as numbers. Typical type N fields are account numbers and zip codes.
integers - type I
The value range of type I numbers is -2*31 to 2*31-1 and includes only whole numbers. Non-integer results of arithmetic operations (e.g. fractions) are rounded, not truncated.
You can use type I data for counters, numbers of items, indexes, time periods, and so on.
Packed numbers - type P
Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.
You can use type P data for such values as distances, weights, amounts of money, and so on.
Floating point numbers - type F
The value range of type F numbers is 1x10*-307 to 1x10*308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating point arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.
You use type F fields when you need to cope with very large value ranges and rounding errors are not critical.
Using I and F fields for calculations is quicker than using P fields. Arithmetic operations using I and F fields are very similar to the actual machine code operations, while P fields require more support from the software. Nevertheless, you have to use type P data to meet accuracy or value range requirements.
C ---> character
D ---> date
P ---> packed
T ---> time
X ---> hexadecimal
I ---> integer.
N ---> Numeric.
cheers,
Hema.
‎2008 Feb 06 3:44 AM
hi,
plz check this link:
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb2fd9358411d1829f0000e829fbfe/content.htm
plz reward points if helpful..
‎2008 Feb 06 7:37 AM
hi,
The following predefined ABAP types are complete:
d - Date: (YYYYMMDD)
t - Time: HHMMSS)
i - Integer
f - Floating Point Number
string -character String (string, of variable length)
xstring -byte sequence (heXadecimal string, of variable length)
You must define the length for these types.
c - Character
n - Numeric text (Numeric Character)
x - Byte (heXadecimal)
p - Packed number (= Binary Coded Decimals). You must enter the number of decimal places.
You can define an elementary data object as follows:
DATA <do name> TYPE <predefined ABAP Type>.
if you want to define an object with the type d,t,i,f,string or xstring. These predefined ABAP types
are complete.
TYPES <type name>(<length>) TYPE <predefined ABAP Type>. DATA <do name> TYPE <type
name>.
if you want to defined an object with the type c, n, p, or x. You must define the length for these types.
For type p objects, you can also define the number of decimal places using the DECIMALS <nn>
addition.
DATA <do name> TYPE <global type>.
if there is a suitable global type defined in the Dictionary.
For compatibility reasons, you can still construct data objects in the DATA statement without first having
to define the type locally in the program with a TYPES statement. Default values are also defined in
addition to the type information for the following generic types:
With data types p, n, c, and X you can enter a length in parentheses after the type name. If no length
is entered, the default length for this data type is used. You can find the standard lengths in the
keyword documentation for TYPES and DATA.
With data type P you can use the DECIMALS addition to determine the number of decimal places that
should be used (up to a maximum of 14). If this addition is missing, the number of decimal places is
set to zero.
If you do not specify a type, then the field is automatically type C.
Hope this is helpful,Do reward.
‎2008 Feb 06 8:04 AM
Hi,
Please go through the below description i hopw it will help u.
**********************************************************************************************************
The data types that can be interpreted as character-type in a UP include:
C: Character (letters, numbers, special characters)
N: Numeric character (numbers)
😧 Date
T: Time
STRING: Character string
Character-type structures: Structures which either directly or in substructures contain only fields of types C, N, D or T
In an NUS, a character of this type has a length of 1 byte, and in a US a length corresponding to the length of one character on the relevant platform. The data type W is no longer supported.
Variables of the types X and XSTRING are called byte-type. The main characteristics of the different kinds of structures are:
Flat structures contain only fields of the elementary types C, N, D, T, F, I, P, and X, or structures containing these types.
Deep structures contain strings, internal tables and field or object references in addition to the elementary types.
Nested structures are structures that contain substructures as components.
Non-nested structures are structures that do not contain any substructures.
********************************************************************************************
DESCRIBE FIELD f.
Effect
Supplies the attributes of the field f . You must specify at least one of the additions:
Additions
1. ... LENGTH len
2. ... TYPE typ
3. ... TYPE typ COMPONENTS n
4. ... OUTPUT-LENGTH len
5. ... DECIMALS n
6. ... EDIT MASK mask
Addition 1
... LENGTH len
Effect
Returns the length of the field f in the field
len .
Example
DATA: FLD(8),
LEN TYPE P.
DESCRIBE FIELD FLD LENGTH LEN.
Result: LEN contains the value 8.
Addition 2
... TYPE typ
Effect
Returns the data type of f in the field typ
Example
DATA: FLD(8) TYPE N,
F_TYPE.
DESCRIBE FIELD FLD TYPE F_TYPE.
Result: F_TYPE contains the value 'N' .
Note
Along with the elementary data types you can specify under
DATA (C, N, etc.), several other data types are created either
with reference to Dictionary fields or during generation. These data
types, which are also returned by DESCRIBE , have the following
type IDs:
h Internal table s 2-byte integer with leading sign b 1-byte integer without leading sign u Structure without internal table v Structure containing at least one internal table
For compatibility reasons, ... TYPE typ returns C rather than u or v with structures.
Addition 3
... TYPE typ COMPONENTS n
Effect
Similar to ... TYPE typ except that, with structures in typ , u or v are returned and in the number of structure components is set in n . If f is not a structure, n is set to 0.
Example
Recursive processing of the pages of an ABAP/4 data structure:
FORM TEST USING F.
DATA: TYP(1) TYPE C, N TYPE I.
FIELD-SYMBOLS: <F>.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE F TO <F>.
IF SY-SUBRC <> 0. EXIT. ENDIF.
DESCRIBE FIELD <F> TYPE TYP COMPONENTS N.
IF N > 0. " Equivalent is TYP = 'u' OR TYP = 'v'
PERFORM TEST USING <F>.
ELSE.
PERFORM DO_SOMETHING USING <F>.
ENDIF.
ENDDO.
ENDFORM.
Addition 4
... OUTPUT-LENGTH len
Effect
Enters the output length of the field f in the variable len .
Example
DATA: FLD(4) TYPE P,
O_LEN TYPE P.
DESCRIBE FIELD FLD OUTPUT-LENGTH O_LEN.
Result: O_LEN contains the value 8.
Addition 5
... DECIMALS n
Effect
Enters the number of decimal places for the field f (defined in addition ... DECIMALS of the DATA statement or in the ABAP/4 Dictionary ) in the variable n .
Example
DATA: FLD(8) TYPE P DECIMALS 2,
DEC TYPE P.
DESCRIBE FIELD FLD DECIMALS DEC.
Resultat: DEC contains the value 2.
Addition 6
... EDIT MASK mask
Effect
If the field f has a conversion routine in the ABAP/4 Dictionary , this is placed in the field mask in the form " ==conv ". " conv " stands for the name of the conversion routine, e.g. " ==ALPHA " in the conversion routine " ALPHA ". In this form, mask can then be used in the addition USING EDIT MASK mask of the WRITE statement.
Example
Check whether there is a conversion routine for the field "customer number" in the table SBOOK :
TABLES SBOOK.
DATA: CONV_EXIT(10).
DESCRIBE FIELD SBOOK-CUSTOMID EDIT MASK CONV_EXIT.
IF CONV_EXIT <> SPACE. ... ENDIF.
Result: CONV_EXIT contains the value " ==ALPHA ".
Note
If the required field is only known at runtime, this field can also be assigned dynamically to a field symbol (see FIELD-SYMBOLS , ASSIGN ).
Regards.