cancel
Showing results for 
Search instead for 
Did you mean: 

download a file

Former Member
0 Kudos

hi i i've the following problem, i need download i fiel into web dynpro application i'm using file download action but thios action request me a node with suply file and a component of type xstring but when i invoke the follow code i can't insert the context from a internal an d i need download the context of the table from webdynpro

data conv_out type ref to cl_abap_conv_out_ce.

data struct type if_main=>element_file_suply.

  • fill the file content

conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

conv_out->convert(

exporting

data = here data

importing

buffer = struct-file ).

node->bind_structure( struct ).

so i need download a table with all the column inside anyone know how i can do it

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Well what kind of file are you wanting to create? You have the correct logic to convert a string to a Unicode UTF-8 binary string, but that isn't going to accpet an internal table. Usually if you are starting with an internal table, you need to format it into a string in some way. Most people loop through the data and convert it to a text tab delimited or something like that which Excel can open. It really depends upon how you want to work with the data once it is downloaded.

Answers (2)

Answers (2)

Former Member
0 Kudos

thank your answers were very helpful thanks

Former Member
0 Kudos

i need download the file in txt format

Former Member
0 Kudos

Hi John

You can use following funcntions. First one to create internal table to string and second FM SCMS_STRING_TO_XSTRING to convert String to XSTRING. Then this XSTRING value you can pass to CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE. here i created small test code. may be helpful for you.



 data: tab_str type string.
  data: begin of it_tab1,
       name(20),
       age(10) ,
      end of it_tab1.
data : lv_name type xstring.
         data it_tab like STANDARD TABLE OF it_tab1.
         data: wa like line of it_tab.
         wa-name = 'naresh'.
         wa-age = '30'.
         append wa to it_tab.
         wa-name = 'naresh1'.
         wa-age = '31'.
         append wa to it_tab.
CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'

 IMPORTING
   TEXT                      = tab_str
  TABLES
    TEXT_TAB                  = it_tab
          .
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
  EXPORTING
    TEXT           = tab_str

 IMPORTING
   BUFFER         = lv_name
          .

CALL METHOD CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE
  EXPORTING
    I_FILENAME      = 'c:\test.txt'
    I_CONTENT       = lv_name
    I_MIME_TYPE     = 'TXT'

Regards

Naresh