cancel
Showing results for 
Search instead for 
Did you mean: 

Table UI element

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Prashant,

yeah now it is opening the file. But the problem is before clicking th link in the table, I have to select the row. Is it possible to open file if i directly click the link instead of selecting row first?

Regards,

Ravi

arjun_thakur
Active Contributor
0 Kudos

Hi Ravi,

Try setting the selection mode property of table to none. This will remove those selection buttons from the table and then you can simply click whatever link to want to without selecting that perticuler row.

I hope it helps.

Regards

Arjun

Former Member
0 Kudos

Hi Arjun,

If I change like that how WD will know that I have selected particular row link? I have tried doing the way you suggested but I'm getting following error when I click on any link.

Access via 'NULL' object reference not possible. ..

Regards,

Ravi

arjun_thakur
Active Contributor
0 Kudos

Ravi,

Please refer this thread: I think you'll understand what I meant to say.

Regards,

Arjun

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks a lot guys.. its done..

Regards,

Ravi.D

Answers (1)

Answers (1)

Former Member
0 Kudos

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