Application Development 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: 

Doubt in ABAP Data types

Former Member
0 Kudos
489

Hi friends,

I want a clear idea of what is the diference between data type 'f' and 'p' with examples and in what situation which should be used.

Similary what and where is 'x' and 'xstring' is used .. In what situations we 'll handly BYTE data ?????

Iam not at all clear ... so eagerly waiting for ur responses with sample examples and clear explanations

thanks in advance

Cheers,

R.Kripa.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
226

Data Type: P

Size : 1 – 16

Description: Each byte stores 2 digits so a pack field of size 2 actually stores 4 digits.The range would depend on the size of the field and the number of decimal place defined.

Data Type: F

Size : 8

Description:Floating point number.Errors occur while rounding hence not very widely used.

Data Type: X

Size: 1 – 65535

Desc:Hexadecimal – first character is an X.

for more detail info please visit the link

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/frameset.htm

please reward points if it helps you

8 REPLIES 8

Former Member
0 Kudos
227

Data Type: P

Size : 1 – 16

Description: Each byte stores 2 digits so a pack field of size 2 actually stores 4 digits.The range would depend on the size of the field and the number of decimal place defined.

Data Type: F

Size : 8

Description:Floating point number.Errors occur while rounding hence not very widely used.

Data Type: X

Size: 1 – 65535

Desc:Hexadecimal – first character is an X.

for more detail info please visit the link

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/frameset.htm

please reward points if it helps you

Former Member
0 Kudos
226

F is floating point, exponential format

very large number is possible.

ex:) F = '3.141592' ==> 3.1415920000000002E+00

P is packed decimal, maximum digit is 15.

1 byte = 2 nibbles = 8 bits

Type P is b bytes ( = 16 nibble )

the last nibble is sign(+ or -).

ex:) P = 3000 ==> 000000000003000C (hex format)

last nibble = C : plus value, D : minus value.

Message was edited by: Min Seob Lee

Former Member
0 Kudos
226

Hi Friends,

Thanks for the replies .... i ve provided 2 points each .....

But i dont want any basic descriptions .... i want some explanations of the usage of these data types ..

thanks in advance

chers,

R.Kripa

0 Kudos
226

As explained earlier, type f is exponential representation: Not used at all for any business purposes because depending on the actual value of the number unexpected rounding may occur as a result of the internal exponential representation.

Type P is a little bit slower in calculation, but it is the typical representation of numeric values in database systems: Two digits fit in one byte. SAP always uses Type P for internal representation of business values connected to currencies (money) or units (weight, amount...).

Type X is hexadecimal, rarely used but sometimes not to avoid. When communicating from ABAP to the outside world via files, Type X is used for control characters like Linefeed (Hex 0A) or Carriage Return (Hex 0D).

Don't know what kind of answer you expect - hope it helps a little.

C.

0 Kudos
226

Lets talk about the "0.2".

In floating point variables, this value cant be stored exactly. Its internal value is like "0.1999999999999" or "0.20000000001" ause of binary translation. Only numbers like 0.5 0.25 (fractions of 1/2) can be stored exactly.

In Packed decimal it is stored exactly as "0.2" cause there is no binary translation. There is no rounding necessary to show the exact value.

In Integer you cant store "0.2" cause Integer can only hold natural numbers like 1,2,3,4... in poisitive and negative.

In business programms P is used e.g. for prices, Integer for counting. f is very seldomly used.

Former Member
0 Kudos
226

Hi Li,

Yes the reply helped me a bit ......... but still i want some more areas where 'X' and 'XSTRING' used....

thanks

cheers,

R.Kripa

Former Member
0 Kudos
226

Hi Kripa,

Types X and XSTRING are for binary data. For type X, the length of the data is specified at declaration, whereas for XSTRING, it can arbitrarily grow as for STRING.

X binary octets RAW base64 string

Type X is used for binary octets. The length of the octets sequence must be specified at declaration. The initial value of each octet is 0.

The lexical representation of binary octets is a sequence of characters in the MIME base64 format.

There are two possible representations of data of type X, namely base64 and hex. base64 is a preferred binary coding scheme in the Internet community. There are standard libraries for encoding and decoding. base64 uses about 33% less space over hex coding. Although ABAP MOVE uses hex coding for binary to character conversion, base64 will be used to represent data of this type in XML.

Note that the sequence of octets is transformed by the base64 encoding. The result, interpreted as a sequence of US-ASCII characters, appears as a sequence of Unicode characters in the content of that element.

Dictionary type RAW corresponds to this type.

XSTRING variable length binary octets RAWSTRING base64 string

Type XSTRING is used for a variable length binary octets. The initial value is ''. The length can vary as the string grows.

The lexical representation of this type is the same as Type X.

This type corresponds to the binary type.

Dictionary type RAWSTRING corresponds to this type.

Regards,

Raj

Former Member
0 Kudos
226

Hi,

Thanks anyway...... but iam sorry i could'nt get half of ur reply

Could u please give me an example....

...

Data : test1 type x.

data : test2(50) type xstring.

test1 = aaa222333.

test2 = '78678fsjfblkjn9r0'.

write : test1, test2 .

what will be my output...

hey the sample i ve given may be very simple.... but i need some codes like this with the scnario and the output.....

Thanks In advance

Cheers,

R.Kripa.