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

Converting Binary to Text

Former Member
0 Likes
961

Hello,

I have a binary file with a structured format like <header>,<item>, <sub-item> etc. How do I convert it in to text ??? I want to post this data to R/3.

Thanks,

John

3 REPLIES 3
Read only

anversha_s
Active Contributor
0 Likes
657

hi,

SCMS_BINARY_TO_STRING .

if you want the resulting string to be in an itab.

declare a itab type string.

data: stringtab type standard table of string.

append <result string from FM> to stringtab .

or

Use below function module inorder to convert as string from a given internal table .

CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'

  • EXPORTING

  • FIRST_LINE = 0

  • LAST_LINE = 0

  • MIMETYPE = ' '

IMPORTING

BUFFER = lv_XSTRING

TABLES

TEXT_TAB = LT_TEXT_OUT

EXCEPTIONS

FAILED = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

rgds

anver

Read only

0 Likes
657

Hi,

I just have look at this FM. It needs INPUT_LENGTH as input. Wherre do I get it ?? Will strlen() works for byte stream ??

Thanks

John

Read only

Former Member
0 Likes
657

Hi,

u this function module like this

TYPES : BEGIN OF TY_TEXT,

TEXT_FIELD(1000) TYPE C,

END OF TY_TEXT.

TYPES : BEGIN OF TY_BINARY,

BINARY_FIELD(1000) TYPE C,

END OF TY_BINARY.

DATA : LT_BINARY type table of TY_BINARY with header line.

DATA : LT_TEXT_OUT type table of TY_TEXT with header line.

  • Convert binary to text.

CALL FUNCTION 'SCMS_BINARY_TO_TEXT'

EXPORTING

INPUT_LENGTH = 100

  • FIRST_LINE = 0

  • LAST_LINE = 0

  • APPEND_TO_TABLE = ' '

  • MIMETYPE = ' '

WRAP_LINES = 'X'

  • IMPORTING

  • OUTPUT_LENGTH =

TABLES

BINARY_TAB = LT_BINARY

TEXT_TAB = LT_TEXT_OUT

  • EXCEPTIONS

  • FAILED = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.