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

How to upload files directly into string or xstring format?

Former Member
0 Likes
6,668

Hi ABAP Experts,

I need to upload files (all types) from Presentation Server.. I cannot use CL_GUI_FRONTEND_SERVICES->GUI_UPLOAD since it gives the data in the form of table. I need the file content in STRING OR XSTRING format directly depending on the type of files. How can I directly upload the content in such formats. I could upload in table & then convert table content into string. When I do that, I lose the actual formatting of data in the file.

Please advise.

Thanks,

Geetha

Hi ABAP Experts,

I need to upload files (all types) from Presentation Server.. I cannot use CL_GUI_FRONTEND_SERVICES->GUI_UPLOAD since it gives the data in the form of table. I need the file content in STRING OR XSTRING format directly depending on the type of files. How can I directly upload the content in such formats. I could upload in table & then convert table content into string. When I do that, I lose the actual formatting of data in the file.

Please advise.

Thanks,

Geetha

6 REPLIES 6
Read only

Former Member
0 Likes
3,876

Hi,

Get the input file in the form of a table and then use func module: CONVERT_TABLE_TO_STRING or LXE_COMMON_TABLE_TO_XSTRING to convert the table to string or xstring.

Regards,

Subbu

Read only

0 Likes
3,876

Hi Subbu

I did that by converting table into string using CONVERT_TABLE_TO_STRING. But when I do this, formatting gets disturbed when the attachment is rendered finally. Thats why I'm looking for a way to achieve this without losing the formatting.

Appreciate your response. Please let me know if you have better ideas.

Thanks

Geetha

Read only

0 Likes
3,876

You can upload the content in binary format using GUI_UPLOAD and convert the binary content to XSTRING using FM SCMS_BINARY_TO_XSTRING. I think it will work....

Read only

Former Member
0 Likes
3,876
Read only

Former Member
0 Likes
3,876

Hi Geetha,

Pass the table entries in to string variable as shown below



CLASS cl_abap_char_utilities DEFINITION LOAD.

 CONSTANTS : c_tab(1)       TYPE c               VALUE cl_abap_char_utilities=>horizontal_tab  " For tab
                       , c_cret(1)      TYPE c               VALUE cl_abap_char_utilities=>cr_lf                  " for enter
                       .


  DATA : w_str   TYPE string
            , w_wa   TYPE string
            , w_xstr  TYPE xstring
            .
loop at it_tab into e_data_pb.

                CONCATENATE e_data_pb-mmbelnr
                  e_data_pb-inv_item
                  e_data_pb-inv_type
                  e_data_pb-vendor
                  e_data_pb-ekgrp
                  e_data_pb-plant
                  e_data_pb-xblnr
                  e_data_pb-zduedate
                  e_data_pb-dis_due
                  e_data_pb-matnr
                  e_data_pb-amount
                  e_data_pb-zstatus
                  e_data_pb-stat_desc
                  e_data_pb-stat_age
                  e_data_pb-pb_age
                  e_data_pb-wi_agent
                  e_data_pb-agent_name
                  e_data_pb-cpo_grp_cod
                  e_data_pb-cpo_recom
                  e_data_pb-cpo_comments
             INTO w_wa SEPARATED BY c_tab.

CONCATENATE w_str  w_wa  INTO w_str SEPARATED BY c_cret.

endloop.

  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text   = w_str
    IMPORTING
      buffer = w_xstr
    EXCEPTIONS
      failed = 1.

I hope this will solve your problem... Have a try....

Thanks and Regards,

Senthil Kumar Annatham.

Read only

Former Member
0 Likes
3,876

SO_DOCUMENT_REPOSITORY_MANAGER may be of some help