728x90
반응형
DATA: hex1(1) TYPE x VALUE 'A0'.
DATA: hex2(1) TYPE x VALUE '20'.
DATA: uhex1(2) TYPE x VALUE '00A0'.
DATA: uhex2(2) TYPE x VALUE '0020'.
DATA: char1(1) TYPE c.
DATA: test_string TYPE string VALUE 'Stuff in here'.
DATA: test_xstring TYPE xstring.
****Convert the Character String to Binary String
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = test_string
IMPORTING
buffer = test_xstring.
IF cl_abap_char_utilities=>charsize = 1.
REPLACE ALL OCCURENCES OF hex1 IN test_xstring WITH hex2 IN BYTE MODE.
ELSE.
REPLACE ALL OCCURENCES OF uhex1 IN test_xstring WITH uhex2 IN BYTE MODE.
ENDIF.
CLEAR test_string.
DATA:
convin TYPE REF TO cl_abap_conv_in_ce.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
input = test_xstring
RECEIVING
conv = convin.
CALL METHOD convin->read
IMPORTING
data = test_string.
WRITE: / test_string.
DATA: hex2(1) TYPE x VALUE '20'.
DATA: uhex1(2) TYPE x VALUE '00A0'.
DATA: uhex2(2) TYPE x VALUE '0020'.
DATA: char1(1) TYPE c.
DATA: test_string TYPE string VALUE 'Stuff in here'.
DATA: test_xstring TYPE xstring.
****Convert the Character String to Binary String
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = test_string
IMPORTING
buffer = test_xstring.
IF cl_abap_char_utilities=>charsize = 1.
REPLACE ALL OCCURENCES OF hex1 IN test_xstring WITH hex2 IN BYTE MODE.
ELSE.
REPLACE ALL OCCURENCES OF uhex1 IN test_xstring WITH uhex2 IN BYTE MODE.
ENDIF.
CLEAR test_string.
DATA:
convin TYPE REF TO cl_abap_conv_in_ce.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
input = test_xstring
RECEIVING
conv = convin.
CALL METHOD convin->read
IMPORTING
data = test_string.
WRITE: / test_string.
728x90
반응형
'ERP-SAP > ABAP' 카테고리의 다른 글
se16n 처럼 동적 DB 조회 스크린을 포함한 동적DB 생성/삭제/조회/변경 CRUD 프로그램 만들기. (0) | 2021.01.08 |
---|---|
MATCH_RESULT_TAB 만들어쓰기..구조도 (1) | 2019.05.20 |
(abap) 문자속 특수문자 찾기 숫자속 문자 찾기 find character in string or in number (0) | 2018.03.15 |
<ABAP> 1byte 를 2byte 로 인식해서 문자를 잘라내는 방법( open dataset 등등)-결과 코딩 (0) | 2016.10.14 |
<ABAP> 1byte 를 2byte 로 인식해서 문자를 잘라내는 방법( open dataset 등등) (2) | 2016.09.22 |