on 02-27-2009 7:22 AM
Hi,
I have one file upload UI element and Upload button.Once I select the file and click upload, Im appendig it to a table. So each file uploaded will be a row in the table. Now, I would like to have link for each row for one column called filename. Once I click on that link I should be able to open the file.
can any one tell me how to get links for each file in the table?
Regards,
Ravi
take LinkToAction as Cell editor instead textView and bind the file_name attribute to the text
create action handler for the LinkToAction, and code to view the file
CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE(
EXPORTING I_FILENAME = LV_FILENAME
I_CONTENT = LS_ATTACH-FILE_CONTENT
I_MIME_TYPE = LV_CTYPE
I_IN_NEW_WINDOW = ABAP_TRUE ).
Abhi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys,
Thank you for the reply. I have implmented the same way. I'm getting links in the table. But when I click the link to open uploaded document, a pop up blocker is coming once I accept that it is navigating to my first view instead of opening the file.
I'm passing proper parameters like file name, mime type etc..
What could be the reason?
Appreciate your help
Regards,
Ravi
HI Ravi
as i wrote before
IE you would get a pop-up blocker message, accept it before you can see saves/open promt.
its browser thing. Once you accept , "allow blocked content to execute" NEW request gets send to your SAP application server and you end up on the First view
The easiest way is to disable pop-up blocker from IE, it is pretty simple if you refer its help when BLOCK comes UP.
Greetings
Prashant
Hi Ravi,
There are several ways to get the file name when user click on the FileName. Below is case where i read the entire line of the Table on which the user clicked, i have a buttons on each line...just put the source on the OnClick action of the LTA of your file name in table.
Getting the context value when a button is clicked on the row.
Method OnClick
"CONTEXT_ELEMENT
Data : lr_elem type ref to if_wd_context_element,
ls_data type ZST_My_struct.
CALL METHOD WDEVENT->GET_CONTEXT_ELEMENT
EXPORTING
NAME = 'CONTEXT_ELEMENT'
RECEIVING
VALUE = lr_elem.
CALL METHOD LR_ELEM->GET_STATIC_ATTRIBUTES
IMPORTING
STATIC_ATTRIBUTES = ls_data.
ls_data is esentially the entire data of the Table Row where the click was Made.
EndMethod.
Greetings
Prashant
Hi Ravi,
Each row of your table effectively has all the content of one completely uploaded file, you need to read all this content into a STRING or XSTRING variable.
You can read the entire row where the filename was clicked , by using the below code in
onAction of LTA
Data : lr_elem type ref to if_wd_context_element,
ls_data type ZST_MYDATA.
CALL METHOD WDEVENT->GET_CONTEXT_ELEMENT
EXPORTING
NAME = 'CONTEXT_ELEMENT'
RECEIVING
VALUE = lr_elem.
CALL METHOD LR_ELEM->GET_STATIC_ATTRIBUTES
IMPORTING
STATIC_ATTRIBUTES = ls_data.
move this ls_data to you single STRING variable lets call it data_string.
convert this to xstring type
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = data_string
importing
buffer = data_xstring.
depending on the MIME type of initial file uploaded change the value of i_mime_type parameter
before calling.
cl_wd_runtime_services=>attach_file_to_response( i_filename = lv_file_name
i_content = data_xstring
i_mime_type = 'EXCEL' ).
on IE you would get a pop-up blocker message, accept it before you can see saves/open promt.
Greetings
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.