cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload/Download

Former Member
0 Kudos

Hi all,

I need to Upload/Download an DMS file on WebDynpro Application. What is the Function module used for uploading the file.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi if your requirement is to store the data in database server then u can use following code.

Layout and context changes:

create one file upload element.

create three atributes UPLOAD of type XSTRING

FILENAME of type string

MIMETYPE of type string

note: in this case i am using one CSV file with '|' as seperater.

Now in layout you have fileupload element bind the data property with UPLOAD attribute and name and mime type with FILENAME and MIMETYPE respc.

if you know the basics webdynpro abap then try to understand follwoing code it will solve your problem..

here in XCONTENT you were getting all the data in xstring form and finally u converted it into string and collected in variable

CONTENT which is of atring type .

so the file data is with you

WD_CONTEXT->GET_ATTRIBUTE( EXPORTING NAME = 'UPLOAD' IMPORTING VALUE = XCONTENT ).

WD_CONTEXT->GET_ATTRIBUTE( EXPORTING NAME = 'FILENAME' IMPORTING VALUE = NAME ).

WD_CONTEXT->GET_ATTRIBUTE( EXPORTING NAME = 'MIMETYPE' IMPORTING VALUE = MIME_1 ).

CONV = CL_ABAP_CONV_IN_CE=>CREATE( INPUT = XCONTENT ).

CONV->READ( IMPORTING DATA = CONTENT ).

DATA: ROWS TYPE STANDARD TABLE OF STRING ,

WA_ROWS(300) TYPE C .

SPLIT CONTENT AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE ROWS .

now do what ever you want to do with this data.

if any query feel free to ask

regards

panky

Edited by: Panky on Jul 28, 2008 3:00 PM

Former Member
0 Kudos

After using File Upload UI Element i can get the file path when i click the BROWSE button, my question is i want to upload that selected file to SAP system by clicking UPLOAD button, where i can use the file from other application using File Download Elemen.

Is there any Function Module for uploading the selected files to SAP system

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The file content will be uploaded on the next server event (regardless of what triggers it) and placed into the context attribute that you bound to the data property of the FileUpload UI element. You don't need to call anything to upload the content. Usually you just place a button next to the fileUpload UI element to trigger the server event and process the content that has been uploaded if necessary.

Once the data in the context, it is up to you to say what to do with it. It will remain in the context for the lifetime of the context. It can of course be used again right away in a file download taking the data right from the context. The data can also be stored in several different ways (database using SQL, MIME Repository using APIs, filesystem of the application server using DATASET commands).

Former Member
0 Kudos

Can u help me with some sample codes for storing the file in the database server

Edited by: Ramesh Vinay on Jul 28, 2008 11:15 AM

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

If you want to store it in the database, that is just normal SQL coding. First you probably want to create some custom table that has a column of type RAW STRING (XSTRING).

http://www.flickr.com/photos/tjung/2709635899

Then as I said, it is just normal SQL. The RAW STRING/XSTRING fields are treated like any other in the SQL statement:

clear isdemo_pd_img.
    isdemo_pd_img-product_guid = l_guid.
    isdemo_pd_img-filename = <wa_filelist>-filename.
    isdemo_pd_img-content = <wa_filelist>-filecontent.
    modify zsdemo_pd_img from isdemo_pd_img.

Former Member
0 Kudos

hi all:

If i want to store the file in servers .how can i use"filesystem of the application server using DATASET commands" do it.

i have to know the type,the file content and so on...how can i transfer ?

and , i want know when and where i can creat the file on servers?

thx a lot.

best wishes!

from zha

20080731

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> hi all:

> If i want to store the file in servers .how can i use"filesystem of the application server using DATASET commands" do it.

> i have to know the type,the file content and so on...how can i transfer ?

> and , i want know when and where i can creat the file on servers?

> thx a lot.

> best wishes!

> from zha

> 20080731

I'm not sure I completely understand your questions. The DATASET commands are ABAP keywords. There are OPEN DATASET, TRANSFER, CLOSE DATASET. They are well documented in the ABAP syntax and fairly easy to use.

What do you mean that you have to know the type, file content and so on? If you want to store metadata about the file, then I might suggest that the application server file system is not the correct location. Using the App. Server file system is storing a file on your local hard drive - except your are using the OS file system of the SAP server. You might consider storing it in a database table instead if you want to also keep extra data.

When and where you can create on the file server? I don't know, its your sever you can store stuff on it where you want.

Former Member
0 Kudos

Use upload / Download UI element.

For file upload, you can use File upload UI element.

For download, you can use file download UI element other wise you can use the fallowing method.

WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(

**path to the word file

I_FILENAME = 'TEST.pdf'

  • String Variable

I_CONTENT = pdf_data

  • File Type

I_MIME_TYPE = 'PDF' ).

You can specify the formate what you may want to download.

It will open the application.

-Gokul

Edited by: Gokulakrishnan Ramasamy on Jul 24, 2008 4:10 PM