File upload in webdynpro java

Hi, I have a reqirement where I have to upload the file ino server, and later user can down load the same from server.
i have seen file upload and down load  example in SDN /docs/DOC-8061#15
but here they are just displaying the name and other details of the file that is trying upload but they are not really uploading the file in to the server. can any one guide me how to upload the file and where does the uploaded file resides in the server once it is succeefully uploded.
Regards,
Venki.

Hi Venki,
The following is the Procedure to DownLoad File from the Server Path.
1.) Take One Context Attribute named as "Texts" with Cardinality 0..n & Selection 0..1 & singleton = true .
2.) Take Two Context Attributes named " FileName " & " urlValue " of type String Under above Node "Texts".
3.) Bind Table UI Element & bind it's dataSource Property to the taken Context Node. Here it is "Texts".
4.) Insert One Column to The Table UI Element.
5.) Insert TableCellEditor( Take LinkToURL UI Element ).
6.) Bind " Texts.urlValue " to the references Property of the LinkToURL UI Element.
7.) Bind " Texts.FileName " to the text Property of the LinkToURL UI Element.
8.) All The UpLoaded Files in the Folder "FolderXYZ" are appeared as rows in the Table.
9.) Write the following code In the wdDoInit() Method of DownLoad View/After Upload Operation Performed.
     int count=0;
     WDWebResourceType obj=null;
     File folder=null;
     IWDMessageManager objMessageManager=wdComponentAPI.getMessageManager();
     folder=new File("FolderXYZ");  // The Folder Name which we gave in the Upload Code.
     File arr[]=folder.listFiles();
    if(arr==null)
          objMessageManager.reportWarning("No files exist in server.. Please Upload ");
          return;
     String str[]=new String(arr.length);
Put Array brackets as it is a Array.
     String names[]=new String(arr.length);
Put Array brackets as it is a Array.
     int c=0;
     for(int k=0;k<arr.length;k++)
       if(!(arr[k].isDirectory()))
           c++;
     int j=0;
     for(int i=0;i<arr.length;i++)
       try {
          if(!arr<i>.isDirectory())
               FileInputStream fis = new FileInputStream(arr<i>);
              FileChannel fc = fis.getChannel();
               byte[] data = new byte((int)(fc.size()));
Put Array  brackets as it is a Array.
               ByteBuffer bb = ByteBuffer.wrap(data);
               fc.read(bb);
               IWDCachedWebResource objCachedWebResource = null;
               if (data != null)
                 String sr[]=arr<i>.getName().split("
                 obj=new WDWebResourceType(sr[1],"html/"+sr[1],true);
                 objCachedWebResource = WDWebResource.getWebResource(data,obj);
                 objCachedWebResource.setResourceName(arr<i>.getName());
               str[j]= objCachedWebResource.getAbsoluteURL();
               names[j]=arr<i>.getName(); j++;
               count++;
        }catch(Exception e)
               objMessageManager.reportException("Unable to  get files from server "+e,false);
               return;
     ArrayList al=new ArrayList();
     for(int k=0;k<count;k++)
          IPrivateHeaderDisplayView.ITextsElement test=wdContext.createTextsElement();
          test.setFileName(names[k]);
          test.setUrlValue(str[k]);
          al.add(test);
     wdContext.nodeTexts().bind(al);
     wdContext.currentContextElement().setVisibleCount(count);  
With Regards,
Roop Kumar.
Edited by: Roop kumar Annavarapu on Sep 5, 2008 6:14 PM
Edited by: Roop kumar Annavarapu on Sep 5, 2008 6:16 PM

Similar Messages

  • How to Save a file uploaded in WebDynpro Java to Windows server

    Hi Guys,
    I need to save a file uploaded in WebDynpro Java to a location on one of my companys many internal Window servers but I cannot get it to work.  I do not get any errors with the following code, but NOTHING happens...  And when I check the folder it is still emply...  Please advise.  I am particularly not sure about specifying the Path syntax.  Also, I do have permission to write to this server.  Is it even possible to save to a Windows server from WebDynpro??
    //uploaded document already in context...
    byte[] file = element.getFileResource();
                //    get the size of the uploaded file  
                element.setFileSize(this.getFileSize(file));
                wdContext.currentContextElement().setFSize(this.getFSize(file)); 
                //    get the extension of the uploaded file       
                element.setFileExtension(binaryType.getMimeType().getFileExtension());
                String fName = wdContext.currentContextElement().getFName();
                String fExt = wdContext.currentContextElement().getFileExtension();
                String foName1 = "
    server01.w9\Files\P
    HRP_Attachments\" + fName + ".pdf";
                File f1 = new File(foName1);
                DataOutputStream dos1;
                dos1 = new DataOutputStream(new FileOutputStream(f1));
                dos1.write(file);
                dos1.flush();
                dos1.close();
    Edited by: christiaanp on Sep 30, 2011 8:07 AM

    Hi Christiaan,
    When specifying the path, make sure you escape the slashes
    So, when you would normally use something like
    \\server\path\file.txt
    in your code you must use it in the form:
    String fileName = "\\\\server\\path\\file.txt";
    Hope this helps!
    Robin van het Hof

  • Excel File Upload In Webdynpro For ABAP

    Hi All,
    I have a doubt regarding EXCEL file upload for Webdynpro for ABAP.
    I am able to get the path of file using 'FILEUPLOAD' UI element.Now I need to upload the EXCEL file into ALV.I have tried out with GUI_UPLOAD and other excel upload function module.But these Function Module throws Dump.
    Can you please suggest how to go about it.It will be a great help if u can suggest any function module or method.

    Hi Amita,
    Insetad of using GUI_UPLOAD use 'HR_KR_XSTRING_TO_STRING'
    Here is the sample code,
    TYPES :BEGIN OF str_itab,
                  name(10) TYPE c,
                  age(10) TYPE c,
                 END OF str_itab.
    DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
           i_data TYPE STANDARD TABLE OF string,
                   lo_nd_sflight TYPE REF TO if_wd_context_node,
                    lo_el_sflight TYPE REF TO if_wd_context_element,
                    l_string TYPE string,
            fs_table TYPE str_itab,
                    l_xstring TYPE xstring,
    fields TYPE string_table,
    lv_field TYPE string.
    DATA : t_table TYPE if_main=>elements_data_tab,
    data_table TYPE if_main=>elements_data_tab.
      * get single attribute
    wd_context->get_attribute(EXPORTING name =  `DATASOURCE`  
                              IMPORTING value = l_xstring ).
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
    EXPORTING
    in_xstring = l_xstring
    IMPORTING
    out_string = l_string.
    SPLIT l_string  AT
    cl_abap_char_utilities=>newline INTO TABLE i_data.
      * Bind With table Element.
    LOOP AT i_data INTO l_string.
    SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE
    fields.
    READ TABLE fields INTO lv_field INDEX 1.
    fs_table-name = lv_field.
    READ TABLE fields INTO lv_field INDEX 2.
    fs_table-age = lv_field.
    APPEND fs_table TO t_table1.
    ENDLOOP.
    lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
    lo_nd_sflight->bind_table( t_table1 ).
      ENDMETHOD.
    if correct give correct answer
    Thanks & Regards,
    Meenachi.R

  • File Upload Using WebDynpro

    Hi All,
    I want to upload single or multiple CSV files using a user interface written in WebDynpros. The files will then be parsed and converted to XML.
    I did something similar with jsps earlier but am not sure how to go about it with WebDynpros.
    If anyone has already done something similar then please share your views.
    Thanks in advance.
    Noaman

    Hi,
    check this link
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/web dynpro sample applications and tutorials.htm#ui
    File Upload/Download 23/30
    Tutorials will help you.
    Regards,
    RK

  • Problem facing with file upload in webdynpro

    hi
    this is sathya, i very thank ful  to your answers, coming to my problem
    i have written the code for file upload action method, in this below code there is no syntax problem.
    but there is a run time error , i.e convt_no_number
    kindly rectify that.
      data:  lt_final type table of zalvtab,
             ls_final type zalvtab,
             "t_table1 TYPE STANDARD TABLE OF str_itab,
             "fs_table TYPE str_itab,
             i_data TYPE STANDARD TABLE OF string,
             lo_nd_zalvtab TYPE REF TO if_wd_context_node,
             lo_el_zalvtab TYPE REF TO if_wd_context_element,
             l_string TYPE string,
             l_xstring TYPE xstring,
             fields TYPE string_table,
             lv_field TYPE string.
      DATA : t_table TYPE if_main=>elements_sel_node,
             data_table TYPE if_main=>elements_sel_node.
    " get single attribute
        wd_context->get_attribute(
           EXPORTING
           name =  `upload`
           IMPORTING
             value = l_xstring ).
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          in_xstring = l_xstring
        IMPORTING
          out_string = l_string.
        SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
    " Bind With table Element.
       LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
        READ TABLE fields INTO lv_field INDEX 1.
        ls_final-ebeln = lv_field.
         READ TABLE fields INTO lv_field INDEX 2.
        ls_final-ekorg = lv_field.
         READ TABLE fields INTO lv_field INDEX 3.
         ls_final-bukrs = lv_field.
         READ TABLE fields INTO lv_field INDEX 4.
         ls_final-ebelp = lv_field.
          READ TABLE fields INTO lv_field INDEX 5.
         ls_final-menge = lv_field.
         READ TABLE fields INTO lv_field INDEX 6.
         ls_final-netpr = lv_field.
         READ TABLE fields INTO lv_field INDEX 7.
         ls_final-aedat = lv_field.
         READ TABLE fields INTO lv_field INDEX 8.
         ls_final-waers = lv_field.
         READ TABLE fields INTO lv_field INDEX 9.
         ls_final-description = lv_field.
          APPEND ls_final  TO lt_final.
      ENDLOOP.
      lo_nd_zalvtab = wd_context->get_child_node( 'sel_node' ).
    lo_nd_zalvtab->bind_table( lt_final ).

    Hi Sathya,
             I guess you are trying to upload data from excel file(XLS format).
             If it is correct then you cannot do this in webdynpro, first you save the excel file as tab delimited.
             Open your excel file->save as->other formats->give file type as TEXT(Tab delemited).
             Now use this file to upload. It should work perfectly.

  • Flat File Upload from WebDynpro ABAP

    Hi,
    I am struggling to find a solution for this requirement and I hope I get some help from the Gurus here.
    I have to upload a ".csv" file from the WebDynpro application, and then store the data in the flat file in a Z# table.
    Can some one explain me how to go ahead with this requirement??
    Regards,
    Nadh

    Hi Nrisimhanadh Yandamuri  ,
    After reading the csv file using file up load you can use the following code to tranfer the same to an itab of your required format
        DATA : loc_conv TYPE REF TO cl_abap_conv_in_ce,
          var_string TYPE string.
    Convert XString to String
        CALL METHOD cl_abap_conv_in_ce=>create
          EXPORTING
            input       = item_content
            encoding    = 'UTF-8'
            replacement = '?'
            ignore_cerr = abap_true
          RECEIVING
            conv        = loc_conv.
    *Read the file contents
        TRY.
            CALL METHOD loc_conv->read
              IMPORTING
                data = var_string.
          CATCH cx_sy_conversion_codepage.
    *-- Should ignore errors in code conversions
          CATCH cx_sy_codepage_converter_init.
    *-- Should ignore errors in code conversions
          CATCH cx_parameter_invalid_type.
          CATCH cx_parameter_invalid_range.
        ENDTRY.
        SPLIT var_string AT crlf INTO TABLE it_string_tab.
    Regards
    Sarath

  • Large PDF file size in Webdynpro JAVA

    Hi All
    I have imported a PDF in Webdynpro JAVA using InteractiveForm UI element. During application execution the size of the PDF seems drastically increased and the application performance is very poor.
    If I make the PDF form as readonly then the size seems normal.
    Any suggestions on the size increase issue with interactive PDF forms in Webdynpro JAVA.
    EP 7.01 SP5
    ADSSAP 7.01 SP5 (1000.7.01.5.0.20090825153742)
    Thanks in advance
    Geogi Luke

    When I make enabled property to false in the UI element, then the size is less than 300KB
    This is ok, it works this way.
    I think some additions are happening at runtime to the PDF and the size is increasing.
    Open the file in WD and save it immediately. Work with the form and save it again. Compare.
    I am using lifecycle designer 7.1 for developments.
    If you can, upgrade to 8.1, you´re efficiency will improve significantly. And of course.. your user experience will change;))
    Note 1176858 - Adobe LiveCycle Designer 8.1 Installation
    Regards Otto

  • File Upload in Webdynpro ABAP

    Hello,
    I would like upload a excel file in Webdynpro for ABAP and I get the data in a attribute in the context node.
    The data is there in Binary format.
    If it is possible to get the data in the ASC format like the function "ws_upload"?
    I had tested with the class "CL_GUI_FRONTEND_SERVICES" and
    the function "ws_upload" both don't work in Webdynpro for ABAP can anyone give me information's how to get the file data in a internal table.
    Regards
    Klaus

    Hi Klaus,
    do you know that there is a special Web Dynpro Java.
    Regards
    Gregor

  • File upload in WebDynpro

    Hi,
    How uploading of a file can be done in webdynpro.
    I had a label 'File" with a text box and a browse button. I need to select a file and when I click the button the selected file should be attached. How we can do it in webdynpro?
    Thank you

    Hi Klaus,
    do you know that there is a special Web Dynpro Java.
    Regards
    Gregor

  • File upload problem in java servlets

    hello,
    I want to upload my files.i have used Multipartrequest object.In my form i had included enctype="multipart/form-data".
    I want to upload one or more files .
    So, I made a file input box and then a select option box. With the help of java script i stored the values of the file input box to the select option drop down box.In this way i stored the name and path of the file in the select option drop down box also. Now when i tried to upload all the file in the select option box it is uploading only one file which is the last one selected from the file input box.
    I hope that file name is also getting from the file input box, and that is the reason why it is uploading that file only.I write this code to execute it.
    MultipartRequest multi=new MultipartRequest(request,".",5*1024*1024);
    I want to upload all the files, so what should i do,
    Please help me to solve this problem
    puneet

    Hi,
    First go through the Multipart code and try to study what it does.it does not upload all the fields u submit in a form.it will first parse the servletInputStream which seperates the normal form fields and the "File" field.when u say ENC-TYPE="multipart/form-data" the way in which it is sent is different for normal fields and the "File" field.there'll be boundaries for each field.also for "File" field the filename will be passed in the Content-disposition info(which contains the values of form fields,their names and filename(only for File input)in specific format) .so if u want to upload more files in the same submit use two or more "File" fields.
    If any one else has a better option let me know

  • .xls and .xlsx file upload in webdynpro

    Hi All,
    Its very urgent.Tried for many options, Searched the scn. But no result. None of them are consistent while uploading xls and xlsx file.
    Sometimes the same file is working garbage value and sometime is working fine.
    Even I tried using CL_FDT_XL_SPREADSHEET , but its always been caught by cx_fdt_excel_core.
    Could anyone suggest me what to do in this case, as my client is not agreeing to any other kind of file .

    Hi Prabhati,
         i had a similar requirement  but i was able to persuade my clients to use tab delimeted file(saved as xls).
    XLS and XLSX excel upload in WDA - webdynpro
    Thanks & Regards,
    Tashi

  • Excel or Any type of file upload in WebDynpro ABAP

    Hi All,
    I need to upload two files in my requirement, where one file is always going to be an excel sheet and another file could be of any type of file.
    I am using below code for cracking the same but it is not behaving the expected way. It is working fine for TXT, CSV and PDF file but not for XLS files.
      DATA: lc_file TYPE string.
    get element via lead selection
      lo_el_context = wd_context->get_element(  ).
    get single attribute
      lo_el_context->get_attribute(
    EXPORTING
          name =  `FILE_CONTENT`
    IMPORTING
          value = lv_file_content ).
      CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
        EXPORTING
          im_xstring  = lv_file_content
         im_encoding = 'UTF-8'
        IMPORTING
          ex_string   = lc_file.
    I would appreciate if any one could suggest me some other way to achieve the desired functionality.
    Regds,
    Ashish

    Hi,
    Please try to use the UI element "Office Control" of a web dynpro view.
    For more details, refer to the web dynpro component: IOS_TEST_HELLOWORLD_MS.
    Best regards,
    Shalini.

  • File Upload from Webdynpro to R/3 Server

    Hi all
    We have a scenario. In that we want to upload any type of file (can be .txt, .pdf, .doc, .xls, .jpg, .gif etc.) to the R/3 server. We r using a FileUpload UI Element.
    The problem is we want to pass the contents of the file (any type of file) to the rfc.
    If anybody  knows the solution for this please help us.
    (It will be of great help if u give the code)
    Thanks & Regards
    Aparnna

    Hi Aparna,
    It happens becuse u r trying to access the byte array of the file in a loop.
    For small file it will not make any pblm, but for for big files, the loop may have to iterate millions of times which result in server hang.
    So dont try to access the byte array in loop in ur code. Try to pass the byte array u r getting as whole to RFC.
    Regards
    Fahad Hamsa

  • Multiple file upload in WD Java

    Dear All,
    I have a requirement to upload multiple files. Now, the forums informed of the Ui element AcfUiUpload/download to fulfill such requirements.
    We are working on SAP NW 7.01. But, there is no such ui element in NWDS 7.01.
    Are these UI elements the only way out? Why are they not availbale in 7.01 editor?
    Kindly enlighten.. Thank you.
    Regards,
    Sharath

    Hello Sharath,
    What Palani is saying is, Create an Excel Sheet and inside that paste the link of the Documents you want to upload. Like in ABC.xls contains
    Column A
    c:\mydocuments\abc.pdf
    c:\mypdf\def.doc
    c:\myprofile\new.xls
    Upload this file and read the values of Column A and get the file names, assign it to your Attribute and upload it.
    Regards
    Nizamudeen SM

  • How to read the complete path in file upload UI

    Hi,
    I want to know how to read the complete path in file upload UI in java web dynpro.
    I have created 1 file upload UI and than when i do browse and select some file say small.jpg from my local PC, desktop , its path is coming in file upload UI like E:\small.jpg,
    I want to know how to get this path in java webdynpro code.
    please let me know..

    Hi Satyam,
    In webdynpro java, first file stores in server location then it reads from server.
    Create a button with upload and write this code OnAction
    Resource is the attribute name in context of type com.sap.ide.webdynpro.uielementdefinitions.Resource, this attribute is for Resource property for Upload UI Element.
    Then in OnAction of button
    InputStream text = null;
           int temp=0;
           try{
                File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
               String path = file.getAbsolutePath();
                wdComponentAPI.getMessageManager().reportSuccess(path);
           }catch(Exception e){
                e.printStackTrace();
        //@@end
    Regards,
    Pradeep
    Edited by: pradeep_546 on May 11, 2011 12:22 PM

Maybe you are looking for

  • After TimeMachine restore, cannot re-activate Acrobat Pro 9

    My iMac's hard drive crashed last week and after replacement, I restored from a TimeMachine back-up on an external hard drive. The only issues I had were getting Adobe applications (CS4 Web Premium) back up and running. After running the License Repa

  • Tax Reporter: magnetic media files in Excel format

    Most of the state agencies websites require a "Microsoft Excel Comma Separated Values File" or a regular Excel file for SUTA reports to be able to upload them online. Is it possible to generate the magnetic media files from Tax Reporter in one of the

  • DW CC - Assets pane not displayed

    In DW CC, I trying to get the Assets pane to show up in it's default place (next to the Files tab). How does one achieve this?

  • Computer just won't start up

    My computer starts normally until the desktop background is displayed and the Spotlight icon is visible in the upper right corner of the screen (the rest of the menu bar isn't there). If I move the cursor over the Spotlight icon, the spinning color w

  • Hiding a confidential field

    Hello friends at www.oracle.com , is there a way for me to hide a field from other users when these users do a SELECT statement? For example, let's suppose I have an USERS table with NAME and PASSWORD field, and one user type a SELECT * FROM USERS, o