Skip to Content
avatar image
Former Member

SCMS_TEXT_TO_BINARY addding '0'.

I want to convert Text to binary..which is further added into mail attachment and sent to mail..

But when I am using SCMS_TEXT_TO_BINARY , it adds up zeros in the back

Test example .

data : begin of t_dwn occurs 0,
text1(30) type c,
end of t_dwn .

data: filesize type i,
lt_bin type solix_tab .

t_dwn-text1 = 'AB'.
append t_dwn.

call function 'SCMS_TEXT_TO_BINARY'
output_length = filesize
text_tab = t_dwn[]
binary_tab = lt_bin
failed = 1
others = 2.

HERE t_dwn having AB is converted into binary...41420D0A but its add up zeroes into

lt_bin : looks like .41420D0A000000000000000000000000000000000000000000000

I don't want zeros at the back .

.I tried looking at other solution which suggested to use SCMS_STRING_TO_XSTRING and SCMS_XSTRING_TO_BINARY ..but was not able to do that.

Please suggest.

Add comment
10|10000 characters needed characters exceeded

  • Are you sure? Shouldn't bLank spaces be something like 200020002000200020002000200020002000200020002000...

  • My wording was incorrect, thanks for pointing it out.

    I meant SOLIX line of length 255 bytes, the trailing zeroes are because of the empty bytes. Is "empty byte" the correct term here?

  • Former Member

    I want to remove...the zeros which are creating extra space...

    Eg :

    Suppose my File has two line items..


    Hello India

    When my file is sent in mail..the extra zeroes..we got on converting text to binary....add up as space 3rd line and cursor goes

    1 line Hello

    2 line Hello India

    3 line (this will be the blank line with cursor at some random place..generated due to extra 000 creating blank space)

    So my problem is ..The cursor should stop exactly on 3rd line staring ..or second line end at HELLO INDIA .

    This format is further extra 3rd line creating problem

    Thanks in Advance.

  • Get RSS Feed

2 Answers

  • Apr 06, 2017 at 10:41 AM
    begin of t_dwn occurs 0

    Oh please, pretty please, not in 2017!

    And if you'd used contemporary instead of obsolete ABAP you might also find classes as CL_ABAP_CODEPAGE instead of (undocumented) function modules

    Add comment
    10|10000 characters needed characters exceeded


      DATA xstr TYPE xstring VALUE '0123456789ABCDEF'.
      DATA binary_line TYPE xstring.
      DATA binary_tab LIKE TABLE OF line.
      data(len) = 3.
      DATA(length) = xstrlen( xstr ).
      WHILE length >= len.
        APPEND xstr(len) TO binary_tab.
        length = xstrlen( xstr ).
      IF length > 0.
        APPEND xstr TO binary_tab.
      cl_demo_output=>display( binary_tab ).
  • Apr 07, 2017 at 11:54 AM

    you can send text via the email standard features, why do you need to convert into binary? Maybe it is for getting it in a given code page, but otherwise it's not needed.

    Add comment
    10|10000 characters needed characters exceeded