Application Development 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: 

Convert Internal table of(Binary) to XSTRING

former_member219737
Participant
0 Kudos

Hi Team,

Can i know the Function Module that converts Internal Table Binary format to XSTRING in sap abap .

So that I can convert to other Format like PDF .

Regards,

Karthik S

17 REPLIES 17

Former Member
0 Kudos

Hi Karthik,

You can use the following method for each line in your internal table:

DATA: conv TYPE REF TO cl_abap_conv_in_ce,

       l_tmp_string TYPE string.

  conv = cl_abap_conv_in_ce=>create(

            encoding = 'UTF-8'

            endian = 'L' ).

  conv->convert(

    EXPORTING input = xml_result

    IMPORTING data = l_tmp_string ).

  APPEND l_tmp_string TO e_tab_xmltab.

Here xml_result will be your binary string and l_tmp_string will give you the converted XML.

Thanks,

Sowbhagya

Ashg1402
Contributor
0 Kudos

Hi,

check this function module - NLS_STRING_CONVERT_FROM_SYS

Former Member
0 Kudos

Hi Kathik,

You need to convert internal table to string. Then string to xstring, then xstring to binary, then binary to any format such as PDF,XLS, Try this

Regards,

Srinath

horst_keller
Product and Topic Expert
Product and Topic Expert

DATA result TYPE xstring.

CALL TRANSFORMATION ID SOURCE itab = itab

                                               RESULT XML result.

0 Kudos

Hi Horst,

We need to create a simple transformation if we have to use the CALL TRANSFORMATION statement, right?

Thanks,

Sowbhagya

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Either ST, XSLT, or the predefined ID.

Horst

0 Kudos

Hi All,

Thank you all for the reply .

I have converted the Binary(Table format) to XSTRING and can i know , how to convert from XSTRING to PDF format .

Regards,

KArthik S

Attila
Active Participant
0 Kudos

Hi,

xstring and binary are different way to store the same document content in memory. PDF however is a document format/schema ,not a variable type. So I assume you might uploaded the file and want to do sg. with it or sg. like this. It depends on the document consumer whether you need to convert in further to a different representation so that it can understand your content with type application/pdf.

What would you like to do with it?

Attila

0 Kudos

Hi Attila,

I have converted the format like below and my final one should be PDF format which has to be displayed in PHP End...

Binary(Table format) to XSTRING.

I want to convert this XSTRING to PDF base 64 , so that PHP team will decode and get the document in PDF

Can u suggest an idea on it .

Regards,

Karthik s

Attila
Active Participant

Hi,

I'm on way but as far as I remember you can call SCMS_BINARY_TO_XSTRING.

R3gards

Attila

0 Kudos


convert itab to string and then string to xstring


LOOP AT lt_emp2 INTO  ls_emp .

       CONCATENATE lv_emp_string

       ls_emp-emp_id         cl_abap_char_utilities=>horizontal_tab

       ls_emp-emp_type        cl_abap_char_utilities=>horizontal_tab

       ls_emp-first_name        cl_abap_char_utilities=>horizontal_tab

       ls_emp-midle_name       cl_abap_char_utilities=>horizontal_tab

       ls_emp-last_name       cl_abap_char_utilities=>horizontal_tab

       cl_abap_char_utilities=>newline

       INTO lv_emp_string.

     ENDLOOP.

     CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

       EXPORTING

         text   = lv_emp_string

       IMPORTING

         buffer = lv_emp_xstring.



or u can use another fm

   CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

  EXPORTING

  input_length = filesize

  IMPORTING

  buffer =  xstring

  TABLES

  binary_tab = itab

  EXCEPTIONS

  failed = 1

  OTHERS = 2.

Former Member
0 Kudos

Hi ,

    Use the FM's  'GUI_DOWNLOAD' and 'GUI_UPLOAD' to convert the format of your internal tables to required format. Refer F1 documentation of these two FM's to see how to use them.

Regards,

Junas Pious.

0 Kudos

Hi,

Thanks for your reply .

(As I am using odata concept, I need to send the data to PHP system in pdf format  )


I have converted the format to XSTRING and can i know , how to convert to PDF format to PHP system .

Regards,

Karthik S

0 Kudos

Hi,

if you access the file in through an OData service implemented by an ABAP system,then you need to implement the get_stream method in your data provider class extension and set the content type application/pdf. If you want to proceed this way,just let me know and I can help you in further. You need to create a project in SEGW transaction,create an entity and redefine some methods to expose the pdf to a client...

Attach_file_TO_RESPONSE above works only in ABAP wd  and FPM stateful applications,but nothing to do with OData.

Attila

0 Kudos

Hi Attila,

Thanks for your valuable reply .

I have implemented my piece of code in GET_STREAM method only .

I have converted the data to RTF format and can u tell me , how to convert to PDF format .

Regards,

KArthik S

0 Kudos

Hi Karthik,

you might get an idea from above. Where is your RTF coming from? I would convert it to PDF before loading to SAP,and accessing it from the get_stream method if the above not work,I've never tried it. On client side you can install PDF prinrer before upload,or if you load it from the server file system,then you can install a PDF printer on the server and command that printer from ABAP. You just need to register the executable. Such way you can convert on server before reading it.

How do you get the data in SAP and what is the original format?

Regards

Attila

alessandroieva
Active Participant
0 Kudos

Hi,

this FM is perfect for you SCMS_BINARY_TO_XSTRING.


Let me know,

AI