Skip to Content
-3

SCMS_TEXT_TO_BINARY addding '0'.

Apr 06, 2017 at 09:32 AM

162

avatar image
Former Member

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'
importing
output_length = filesize
tables
text_tab = t_dwn[]
binary_tab = lt_bin
exceptions
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.

10 |10000 characters needed characters left characters exceeded

The zeroes at the end represent the "blank" spaces.

What is exactly the problem you are facing with the trailing zeroes?

1

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

1

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?

0
Former Member

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

Eg :

Suppose my File has two line items..

Hello

Hello India

When my file is sent in mail..the extra zeroes..we got on converting text to binary....add up as space ..in 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 uploaded..so extra 3rd line space...is creating problem

Thanks in Advance.

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Horst Keller
Apr 06, 2017 at 10:41 AM
2
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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hello Horst,

Do we have any alternative to the FM SCMS_XSTRING_TO_BINARY ?

Thanks,

K.Kiran

0

WYCIWYG

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.
  SHIFT xstr BY len PLACES LEFT IN BYTE MODE.
  length = xstrlen( xstr ).
ENDWHILE.
IF length > 0.
  APPEND xstr TO binary_tab.
ENDIF.
cl_demo_output=>display( binary_tab ).
0
Sandra Rossi Apr 07, 2017 at 11:54 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded