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

Function module to convert Binary data to Text

Former Member
0 Likes
8,452

Hello everybody,

    As a part of my requirement, I am getting the bianry data from the FM 'SO_ATTACHMENT_READ_API1'  . This binary data need to be converted to text. I used FMs 'SCMS_BINARY_TO_TEXT', 'SCMS_BINARY_TO_FTEXT'. But, getting junk data into binary data itab. Please, suggest a better approach.

Regards,

Srinivas

12 REPLIES 12
Read only

Kartik2
Contributor
0 Likes
3,727

Hi,

Try using the function module 'SO_ATTACHMENT_READ' to read the attachments. Thank you.

Regards,

kartik

Read only

Former Member
0 Likes
3,728

Hi Karthik,

      Small correction to my question. The Binary data is being pulled but, while conerting to text , junk characters are coming. The FM 'SO_ATTACHMENT _READ' do not have necessary parameters/tables to hold the converted data. Thank you for reply.

Regards,

srinivas

Read only

Former Member
0 Likes
3,728

Check your internal table

Read only

Former Member
Read only

Former Member
0 Likes
3,728

Hi Srinivasa

Have you tried using the CL_DOCUMENT_BCS Class at all?

It contains a couple of Methods that deal with Attachment reads.

Hope this helps.

Regards

Vic

Read only

0 Likes
3,728

Hi Suresh,

    Thank you for the reply. I tried calling the methods. But, for this class instance can not be created out side the class(Private instantiation). The class CL_DOCUMENT_BCS do not suite for this requirement.

I checked the class CL_ABAP_STRING_X_WRITER has two methods 'get_result_string()' and 'write_internal()'. These are also not converting data.

Please, suggest any other approach. Your suggestion would be more helpful.

Regards,

Srinivas

Read only

0 Likes
3,728

Hi Srini,

Try to call the method like CL_ABAP_CONV_IN_CE=>CONVERT

Thanks & Regards,

Suresh M

Read only

Former Member
0 Likes
3,728

Hi,

Can try with the CL_ABAP_CONV_IN_CE class.

In this class use the CONVERT_STRUC method can conver the structure data.

And CONVERT method can convert the field data.

Thanks & Regards,

Suresh M

Read only

Former Member
0 Likes
3,728

You can try with:

SCMS_BINARY_TO_TEXT

* 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

          .

you can modify input length...

Ciao

Read only

Former Member
0 Likes
3,728

What precisely do you mean by "junk into binary data itab"?  If the input is junk why proceed to try to convert it to text?

Read only

Former Member
0 Likes
3,728

you can insert binary content in lt_binary and the function give you the text content in lt_text_out.

....

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_TEXT type table of TY_TEXT with header line.
DATA : LT_TEXT_OUT type table of TY_TEXT with header line.

DATA : LT_BINARY type table of TY_BINARY with header line.

...

You need to run some tests because I have never used this FM...

Let me know!

Ciao

Read only

Former Member
0 Likes
3,728

Hi Srini,

If you are reading the file from application server

class : CL_RSAN_UT_APPSERV_FILE_READER

in this class static method  : APPSERVER_FILE_READ

call this method in your code.

All the data comes into internal table take it as each line as one record.

Thanks & Regards,

Suresh M