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

Hexa decimal data type .

Former Member
0 Likes
5,713

Can anyone tell me exactly where to use and how to use Hexadecimal data type ?

4 REPLIES 4
Read only

Former Member
0 Likes
2,272

hi,

Hexadecimal Type

The 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 .

hope it is useful.

regards,

sreelakshmi

Read only

Former Member
0 Likes
2,272

just create any report and attach this code to it

you might have to some corrections in it

just see to it


DATA: itab_aux LIKE SOLI OCCURS 0 WITH HEADER LINE.
DATA: itab LIKE solix OCCURS 0 WITH HEADER LINE.
DATA: itab_tmp LIKE solix OCCURS 0 WITH HEADER LINE.

CLEAR itab_aux.

REFRESH itab_aux.

CONCATENATE 'Hello' 'How R' 'u!' INTO itab_aux-line separated by space.

APPEND itab_aux.
CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
EXPORTING
ip_solitab = itab_aux[]
IMPORTING
ep_solixtab = itab_tmp[].

clear itab.
loop at itab_tmp.
itab-line = itab_tmp-line.
append itab.
endloop.

CALL FUNCTION 'SO_SOLIXTAB_TO_SOLITAB'
EXPORTING
ip_solixtab = itab[]
IMPORTING
EP_SOLITAB = itab_aux[]
.
loop at itab_aux.
write itab_aux-line.
endloop.

reward points if useful

Edited by: Sumesh Nair on Feb 15, 2008 11:42 AM

Read only

Former Member
0 Likes
2,272

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.

Check this for Single Bit Processing in Hexadecimal Fields

http://help.sap.com/saphelp_nw04/helpdata/en/b6/e7d716f46711d195200000e8353423/content.htm

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.

Read only

Former Member
0 Likes
2,272

Hi,

Hexadecimal Type

The 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.

In a hexadecimal field (type X), you can process the individual bits. ABAP interprets the contents of hex fields byte by byte. A hexadecimal field with length n is n bytes long, and has a display length in ABAP of 2xn. The decimal values 0 - 255 are represented in hexadecimal by the characters ‘00’ to ‘FF’.

ABAP contains statements that allow you to read and set the individual bits in a type X field.

There are also special logical operators that you can use to compare bit sequences. Bit sequence processing allows you to process complex conditions and set operations more

efficiently.

In a hexadecimal field (type X), you can set or read individual bits.

Setting Bits

To set an individual bit, use the statement

SET BIT <n> OF <f> [TO <b>].

This statement sets the bit at position <n> of field <f> to 1 (or to the value of field <b>). The system must be able to interpret field <n> as a positive integer. The field <f> must have data

type X. The field <b> must contain the value 0 or 1. If the bit is set, SY-SUBRC is set to 0. If <n> is greater than the length of <f>, SY-SUBRC is unequal to zero. If <n> or <b> contain invalid values, a runtime error occurs.

Ex.

DATA HEX(3) TYPE X.

SET BIT: 09 OF HEX TO 1,

10 OF HEX TO 0,

11 OF HEX TO 1,

12 OF HEX TO 1,

13 OF HEX TO 0,

14 OF HEX TO 1,

15 OF HEX TO 0,

16 OF HEX TO 1.

WRITE HEX.

The bits of the second byte in the three-character hexadecimal field HEX are set to ‘10110101’, and the list output is as follows:

00B500

The decimal value of the second byte is 181.

Reading Bits

To read an individual bit, use the statement

GET BIT <n> OF <f> INTO <b>.

This statement reads the bit at position <n> of field <f> into field <b>. The system must be able to interpret field <n> as a positive integer. The field <f> must have data type X. If the bit is read, SY-SUBRC is set to 0. If <n> is greater than the length of <f>, SY-SUBRC is unequal to zero and <b> is set to zero. If <n> contains an invalid value, a runtime error occurs.

Ex.

DATA: HEX(1) TYPE X VALUE 'B5',

B(1) TYPE N.

DO 8 TIMES.

GET BIT SY-INDEX OF HEX INTO B.

WRITE B NO-GAP.

ENDDO.

Here, the eight buts of the single-character hexadecimal field HEX (value ‘B5’) are read and displayed as follows:

10110101

Regards,

Bhaskar