cancel
Showing results for 
Search instead for 
Did you mean: 

Need Info about FileUpload

Former Member
0 Kudos

Hi Experts,

Iam new to WD ABAP.

Iam uploading one file from my local system using FileUpload.

i need to do following things.

1: I should get Only name and type of file ( when getting from context that is binded, It's giving full path of file )..

2: I should upload this file from context to specified directory (say 'TEST' )location at server.

Could anybody please guide me in this regard..

Please share some code.. because Iam new to WDABAP

Regards

Narayana

Accepted Solutions (1)

Accepted Solutions (1)

former_member342104
Participant
0 Kudos

hi,

what properties you use in layout.

use fileupload.

bind filename to FILE_NAME (type xstring).

bing data to DATA( type string)

Edited by: kk on Oct 24, 2008 2:15 PM

Former Member
0 Kudos

Hi All,

I have one issue. I should get size of file that is uploaded.

Based on that size, I should do some operations.

Please suggest me to do this or share some code.

Thanks in advance

Narayana

Former Member
0 Kudos

By using the method

FILE_GET_SIZE

of class

CL_GUI_FRONTEND_SERVICES

you will get file size.

Thanks,

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> By using the method FILE_GET_SIZEof class CL_GUI_FRONTEND_SERVICES you will get file size.

>

> Thanks,

This absolutely will NOT work! Abap WD please not suggest solutions unless you have have tried them yourself. The frontend services will not work from Web Dynpro because they require a connection to the SAPGUI. They use the control framework to access the frontend. We have no such capabilities when running inside a browser.

For Web Dynpro ABAP you would use the fileUpload. Once the content is available in the context attribute (of type XSTRING), just read the context attribute into a local variable of type XSTRING like normal. To get the lenght use the ABAP keyword XSTRLEN. This will return the lenght in bytes of the uploaded file content.

Former Member
0 Kudos

Hi ,

Can you post sample statement here..

for example my content is stored in a variable 'FILECONTENT' of type XSTRING.

Thanks in advance

Narayana

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi ,

>

> Can you post sample statement here..

> for example my content is stored in a variable 'FILECONTENT' of type XSTRING.

>

> Thanks in advance

> Narayana

Ok, there isn't much to it but here is an example:

data filecontent type xstring.
data numbytes type i.
numbytes = xstrlen( filecontent ).

Former Member
0 Kudos

Hi Thomas,

My problem is solved. Thank you.

Thanks to all of you for suggestions.

Regards

Narayana

Answers (2)

Answers (2)

former_member342104
Participant
0 Kudos

hi use this code

types: begin of t_header_text,

text0 type string,

text1 type string,

text2 type string,

end of t_header_text.

data: it_header_text type standard table of t_header_text.

data: wa_header_text like line of it_header_text.

data: node_file type ref to if_wd_context_node.

node_file = wd_context->get_child_node( 'FILE_UPLOAD' ).

node_file->get_attribute( exporting name = 'DATA' Importing value = value ).

node_file->get_attribute( exporting name = 'FILE_NAME' Importing value = FILE_NAME ).

node_file->set_attribute( name = 'FILE_NAME' value = FILE_NAME ).

conv = CL_ABAP_CONV_IN_CE=>CREATE( input = value ).

conv->READ( importing data = content ).

split content at cl_abap_char_utilities=>cr_lf into table rows .

read table rows into wa_rows index 1.

split wa_rows at '|' into:

wa_header_text-text0

wa_header_text-text1

wa_header_text-text2

uday_gubbala2
Active Contributor
0 Kudos

Hi Narayana,

Chek this standard document

[http://help.sap.com/saphelp_nw70/helpdata/EN/b3/be7941601b1d09e10000000a155106/frameset.htm|http://help.sap.com/saphelp_nw70/helpdata/EN/b3/be7941601b1d09e10000000a155106/frameset.htm]

Also check these forum threads

[|]

[|]

[|]

[|]

for file upload control you can look at WDR_TEST_EVENTS component

Regards,

Uday

Former Member
0 Kudos

Hi Uday and kk ,

I already checked all these threads and tutorial.

But how can I specify the path in server , to which file should be uploaded?

Iam not in need of FileDownload now.

Regards

Narayana

Edited by: Lakshmi Narayana Chowdary Namala on Oct 24, 2008 1:44 PM

uday_gubbala2
Active Contributor
0 Kudos

Hi Narayana,

The file content will be uploaded and placed into the context attribute that you bind to the data property of the FileUpload UI element. Once the data in the context, you should take care of handling the data. You can then try save it in the location that you want. If you intend you may try having another input field where the user can enter the path to save the file in. You can then try save the data from the context attribute in that specified path.

Regards,

Uday