ABAP Characterc and HEX

284 阅读1分钟

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

clipboard1

bit processing: help.sap.com/saphelp_nw0…
clipboard2
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
clipboard3
clipboard4
00 是一个字节

32是一个字节

31 00 20 00 一共4个字节

x length 4 4个字节。

字符串变量char1的1对应3100

char2 的1对应31002000

2000代表空格
clipboard5
char1 : UTF16 两个字节代表1个字符。 1个字节8位,2个16位
clipboard6
clipboard7
clipboard8
clipboard9

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.
clipboard10
clipboard11
clipboard12
clipboard13
clipboard14