前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ABAP bit 操作

ABAP bit 操作

作者头像
Jerry Wang
发布2019-07-03 11:01:50
7000
发布2019-07-03 11:01:50
举报

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

测试代码:

代码语言:javascript
复制
REPORT  ZTEST_BOL.
data: lv0 type x length 1,
      lv1 type x length 1,
      lv2 type x length 1,
      lv3 type x length 1,
      lv4 type x length 1,
      lv5 type x length 1,
      lv6 type x length 1,
      lv7 type x length 1,
      lv8 type x length 1.
lv0 = boolx( bit = 0 bool = ( 1 < 2 ) ).
lv1 = boolx( bit = 1 bool = ( 1 < 2 ) ).
lv2 = boolx( bit = 2 bool = ( 1 < 2 ) ).
lv3 = boolx( bit = 3 bool = ( 1 < 2 ) ).
lv4 = boolx( bit = 4 bool = ( 1 < 2 ) ).
lv5 = boolx( bit = 5 bool = ( 1 < 2 ) ).
lv6 = boolx( bit = 6 bool = ( 1 < 2 ) ).
lv7 = boolx( bit = 7 bool = ( 1 < 2 ) ).
lv8 = boolx( bit = 8 bool = ( 1 < 2 ) ).
FIELD-SYMBOLS: <lv_c> TYPE char1.
data: lv type char1.
lv = '1'.
DATA: len TYPE i,
      res TYPE i,
      hex TYPE xstring,
      lv_name TYPE string.
FIELD-SYMBOLS: <lv_temp> TYPE x." length 1.
DO 9 TIMES.
   DATA(lv_index) = sy-index - 1.
   lv_name = 'LV' && lv_index.
   ASSIGN (lv_name) TO <lv_temp>.
   ASSERT sy-subrc = 0.
   WRITE: lv_name COLOR COL_NEGATIVE.
   len = xstrlen( <lv_temp> ) * 8.
   WHILE sy-index <= len.
     GET BIT sy-index OF <lv_temp> INTO res.
     WRITE (1) res NO-GAP.
   ENDWHILE.
   ULINE.
ENDDO.

输出:

clipboard1
clipboard1

debugger里观察到的value:( Any byte values, 00 to FF )

clipboard2
clipboard2
clipboard3
clipboard3

新建一个记事本文件,输入字符1,save as成ANSI:

clipboard4
clipboard4

则其hexadecimal value如下:

clipboard5
clipboard5

save as UTF-8:

clipboard6
clipboard6
clipboard2
clipboard2

save as Unicode:

clipboard2
clipboard2
clipboard2
clipboard2
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年07月01日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Created by Jerry Wang, last modified on Dec 27, 2014
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档