天天看点

ABAP Characterc and HEX

Created by Wang, Jerry, last modified on Dec 20, 2014

ABAP Characterc and HEX

bit processing:

http://help.sap.com/saphelp_nw04/helpdata/en/b6/e7d716f46711d195200000e8353423/frameset.htm
ABAP Characterc and HEX

Setting Bits

To set an individual bit, use the statement

SET BIT OF [TO ].

This statement sets the bit at position of field to 1 (or to the value of field ). The system must be able to interpret field as a positive integer. The field must have data type X. The field must contain the value 0 or 1. If the bit is set, SY-SUBRC is set to 0. If is greater than the length of , SY-SUBRC is unequal to zero. If or contain invalid values, a runtime error occurs.

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.

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.

0A

ABAP Characterc and HEX

00 是一个字节

32是一个字节

31 00 20 00 一共4个字节

x length 4 4个字节。

字符串变量char1的1对应3100

char2 的1对应31002000

2000代表空格

ABAP Characterc and HEX

char1 : UTF16 两个字节代表1个字符。 1个字节8位,2个16位

ABAP Characterc and HEX
ABAP Characterc and HEX

Byte order

Determines the order in which a number of the data types i, decfloat16, decfloat34, f, s or a character in a Unicode system is stored in the memory. A distinction is made between big and little endian. In the former case, the system writes the byte with the highest level, and in the second case the byte with the lowest level, to the first position in the memory. The byte order on the current application server can be derived from the static attribute ENDIAN in the system class CL_ABAP_CHAR_UTILITIES.

ABAP Characterc and HEX
ABAP Characterc and HEX
ABAP Characterc and HEX

继续阅读