cancel
Showing results for 
Search instead for 
Did you mean: 

cl_wd_runtime_services=>attach_file_to_response

Former Member
0 Kudos

Hi all,

I have a question regarding method attach_file_to_response of class cl_wd_runtime_services.

I'd like to develop a webdynpro application without graphical user interface that works like a file server.

If the application is called, it reads a file of a archive-system an send it back to the caller (browser).

I implemented the necessary code in the default inbound plug of the component's window, where I use cl_wd_runtime_services=>attach_file_to_response.

The code is processed without error but the caller do not get the attached file.

The code works fine, if it is called due to an (gui-)action (click on a link or button).

But in this case I have to implement a graphical user interface...

Has anybody an idea what goes wrong here? Or has anybody an different idea how to implement such a file-server-like WD4A-application?

Regards

Daniel

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hmmm never tried an attach before any output.

Why use WDA if there is never any interaction.

You do know you can create a simple ABAP OO class that implements a specific

interface and hang in on a new service in SICF.

Here a simple piece of code that shows set the response.

You might find this useful.

Im interested if you get attach to reponse working on the initial app call.

(BTW where did you put the call ?)

method IF_HTTP_EXTENSION~HANDLE_REQUEST.

* this piece of code is a generic OUTPUT in
* HTML format, of ABAP LISTs.
* ALV NOT SUPPORTED. Use ITS service  for that.
* variants also supported etc.
*
* HOW TO:
* create a class using interface IF_HTTP_EXTENSION
*Place this code in the HANDLE_REQUEST METHOD.
*create a new service in SICF entering your new class
*as the handler.

* Known Restrictions:
*   NO CALL SCREENS etc that cause SAPGUI dialog.


* Nice test reports  RSUSR003 or RSUSR005
data: lv_variant type char30.
data: lv_repname type sy-repid.
data: output_str type string.

data: html type table of w3html.
data: html_wa type w3html.
data: listobject type table of abaplist.


* to call
*http://host:port/this_service?report=rxxxxxxx&variant=vxxxxxxxx

lv_repname = server->request->get_form_field('report').
lv_variant = server->request->get_form_field('variant').

if lv_variant = space.
* the abap output section
    submit (lv_repname) and return exporting list to memory.
else.
    submit (lv_repname) using selection-set lv_variant
    and return exporting list to memory.

endif.
    call function 'LIST_FROM_MEMORY'
       tables
            listobject = listobject.

     call function 'WWW_HTML_FROM_LISTOBJECT'
       exporting
            report_name = lv_repname
            tables
            html        = html
            listobject  = listobject.

     clear output_str.
     loop at html into html_wa.
       concatenate output_str html_wa into output_str.
     endloop.



 call method server->response->set_cdata( data = output_str ).

endmethod.

regards

Phil

Former Member
0 Kudos

Hi Phil,

thank you very much for your answer! It was very helpful.

I implemented a simple ABAP OO class as you described and it works great.

I didn't know this possibility.

The new SICF-service is called by a browser-plugin which is used to display TIFF files.

I tried to attach a file in WD4A on the initial app call once more. But it seems that this

basically not works. I monitored the initial app call with HttpWatch and it seems that this call

is used to send some basic javascript (like SAPWebFramework.js) etc. to the browser.

Regards

Daniel