Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

data typs

Former Member
0 Likes
1,760

hi

dEFINE

C,P,F,X,N,I DATA TYPES

GIVE ME EXP. ALSO

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,045
C =  Character        = 'ABD123'
P =  Packed Decimal   =  1.512
F =  Float            =  0000000000000001.1E
X =  Hex              =  X0A
N =  Numeric          =  0004
I =  integar          =  1

Regards,

Rich Heilman

Read only

Former Member
Read only

Former Member
0 Likes
1,045

let your variable be of name var.

(1)C - CHAR

data: var(3) type c. OR

data: var(3). means var can be of length 3 and can have any value consisting of 0 - 9, A - Z , and special characters like @,# etc.

The value should be assigned inside single quotes

for eg var = 'ABC'.

(2)P - PACK

data: var(3) type p decimals 1.

This means var can have value in the format '00.0'. This is the type used to define decimal values. The value range is 0 - 9. Don't forget to give single quotes.

(3)F - FLOAT

data:var type f.

value in var will be in the float or the exponential form.

for eg var = 0.00000000001 E 2 means the number into E squared (E raised to 2).

(4)X - HEXADECIMAL

data:var type x.

This means var can contain values which contain 0 - 9 and A - E. eg B in hex = 11 in normal decimal.

(5)N - NUMERIC

data:var(3) type n.

This means var is of length 3 and contain numeric values .

Here it ranges from 000 - 999.

(6)I - INTEGER

data: var type i.

var contains an integer value i.e. from negative range to positive range.

Regards

Binoo

NB:Award points if found useful.

Read only

Former Member
0 Likes
1,045

U can check this

<b>ABAP/4 Data Types</b>

There are two main categories of data in ABAP/4: character and numeric. Variables receive special treatment by the ABAP/4 processor based on their category that goes beyond the usual treatment given by other languages. Therefore, it is especially important for you to be able to recognize and distinguish between the character and numeric data types.

Character Data Types

The character data types are shown in Table 7.2. Notice that they include type n. Internal lengths are given in bytes. A dash in the Max length column appears for fixed length data types.

Table 7.2 List of Character Data Types

Data

Type Internal

Description Default

Internal

Length Max

Internal

Length

Valid

Values Default

Initial

Value

c character  1 65535 Any char Blank 
n numeric text  1 65535 0-9 0 
d date  8 (fixed) - 0-9 00000000 
t time  6 (fixed) - 0-9 000000 
x hexadecimal  1 65535 Any 

The Default Initial Value column indicates the value given to the variable by default if you do not specify one using the value addition.

Internal Representation of Variables

Numeric text variables are called numeric character variables and hold unsigned positive integers. Each digit occupies one byte, and internally each is stored as a character. This is a character data type. It can only contain the characters 0-9.

Use numeric text to hold numbers that are used as unique identifiers, such as document numbers, account numbers, and order numbers. Also, use it for variables that hold a numeric extracted from a character data type. For example, if you were to extract the two-character month from a date field and needed a variable to store it, you should use a type n field.

Date and time are fixed length data types. You should not specify a length on the data statement for them. Values for date and time variables are always stored internally as YYYYMMDD and HHMMSS, respectively. The current date is available in the system field sy-datum and the current time in sy-uzeit.

NOTE

The values of sy-datum and sy-uzeit are set at the beginning of program execution and do not change until the program ends. If you need access to the most current date and time during execution of a long-running pro-gram, use the statement get time. It updates the values of sy-datum and sy-uzeit to reflect the current date and time.

Absolute time values that have millisecond precision are not used in R/3. However, relative time values are available to millisecond precision. To obtain these, use the get run time statement and store them using data type i. See the chapter on runtime analysis for more details.

Numeric Data Types

The numeric data types are shown in Table 7.3. A dash in the Max Length column indicates the length cannot be changed. An asterisk indicates the attribute is machine-dependent.

Table 7.3 Numeric Data Types

Data

Type

Description Default

Internal

Length

Max

Length

Max

Decimals

Valid

Values Default

Initial

Value

i integer  4(fixed) - 0 -231 to +231  0 
p packed decimal  8 16 14 0-9 . 0 
f floating-point  8 8 15* -1E-307 to 1E308  0.0

All of the variables in Table 7.3 are signed. In floating-point variables, the exponent is also signed.

Use integers for variables that will be involved in simple computations or when no decimal points are required. Variables such as counters, indexes, positions, or offsets are good examples.

A decimal variable stores (L*2)-1 digits, where L is the length of the variable in bytes. Decimal values are stored two digits per byte, except the end byte, which contains a single digit and a sign. The decimal point itself is not stored; it is an attribute of the definition. For example, data f1(4) type p defines a variable f1 that is four bytes long and can hold seven digits (plus a sign), as shown in Figure 7.2. data f2(3) type p decimals 2 defines a variable f2 that is three bytes long and can hold five digits (plus a sign). The definition data f3 type p defines a variable f3 capable of holding 15 digits because the default length for type p is 8.

Refer this link for the above and some sample programs

http://cma.zdnet.com/book/abap/ch07/ch07.htm