Skip to Content

This blog provides a step-by-step description with the aim to Upload a file and to display the Uploaded file using FileDownload UI Element in a tabular format using NetWeaver Developer Studio(NWDS) 2004S.

Layout Design

(1) Add a FileUpload UI Element and a button in your view.
(2) Add a table under it and insert a column with a TableCellEditor of type FileDownload

Required View Controller Context Elements

(1) Create a value node by name “fileUploadNode” and a value attribute “fileUploadAttr” of type

com.sap.ide.webdynpro.uielementdefinitions.Resource


(2) Create another value attribute “fileUploadName” of type string under “fileUploadNode”.
(3) Create a value attribute “fileUploadUI” of type

com.sap.ide.webdynpro.uielementdefinitions.Resource

directly under the root context node.

The context should look like this…

image

Open the properties view of the FileUpload UI Element.

Map the resource attribute to “fileUploadUI” element of your view controllers context.

Open the properties view of the FileDownload UI Element in your table

Map the resource attribute to “fileUploadNode.fileUploadAttr” element of your view controllers context.

Map the text attribute to “fileUploadNode.fileUploadName” element of your view controllers context.

Save all MetaData. Deploy and run your application.

Try to upload some files and you may find them in your table. Click on them to view the same.

image

This task was pretty complex with NetWeaver Developer Studio(NWDS) 2004. Checkout the following steps.

The context structure should look like this…

image

    int leadSelect = wdContext.nodeDownloadFileNode().getLeadSelection();

     IWDAttributeInfo attInfo = wdContext.nodeDownloadFileNode().getDownloadFileNodeElementAt(leadSelect).node().getNodeInfo().getAttribute(“DownloadFile”);

     ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();

     IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;

     binaryType.setFileName(wdContext.nodeDownloadFileNode().getDownloadFileNodeElementAt(leadSelect).getFileName());

     int size2 = wdContext.nodeDownloadFileNode().getDownloadFileNodeElementAt(leadSelect).getFileName().trim().length();

     int start_location = wdContext.nodeDownloadFileNode().getDownloadFileNodeElementAt(leadSelect).getFileName().trim().indexOf(“.”);

     String extension = wdContext.nodeDownloadFileNode().getDownloadFileNodeElementAt(leadSelect).getFileName().trim().substring(start_location+1, size2);

     if(extension.equalsIgnoreCase(“doc”)){     

          binaryType.setMimeType(WDWebResourceType.DOC);

     }else if(extension.equalsIgnoreCase(“rtf”)){

          binaryType.setMimeType(WDWebResourceType.RTF);

     }else if(extension.equalsIgnoreCase(“pdf”)){

          binaryType.setMimeType(WDWebResourceType.PDF);

     }else if(extension.equalsIgnoreCase(“xls”)){

          binaryType.setMimeType(WDWebResourceType.XLS);

     }

Hence coding is minimized with the same functionality in SAP NetWeaver Developer Studio 2004S for fileUpload and fileDownload.

To report this post you need to login first.

9 Comments

You must be Logged on to comment or reply to a post.

  1. Hi Rekha,

    I did what you have suggested ie declared the content elemnt as Resources and then mapped the attributes to repective values but when i paste the code given by you, i get an error that “IWDResources cannot be resolved”

    Only different thing  i have done is that i have created a table in that there are 3 columns and 4 rows.In first column i have inserted FileUpload ,in second column Submit button is inserted and in third column FileDownload is inserted.
    Does this make any difference.
    Can you please guide me what to do….

    Thanks
    Tauseef

    (0) 
    1. Armin Reichert
      The interface is named IWDResource (without “s”) and is in package “com.sap.tc.webdynpro.services.sal.datatransport.api”.

      Press CTRL-Shift-O to add the corresponding import-statement to your source file.

      Armin

      (0) 
      1. Hi Armin,

        Thanks a lot CTRL-Shift-O worked.One thing i would like to ask,what basically happens when we do CTRL-Shift-O .How is it able to add library ,i am new to this so it would be helpful if i can get to know it.

        Thanks a lot for your help.

        Regards
        Tauseef

        (0) 
      2. Hi Armin,

        Now i have another problem:

        I have made a table:with 4 columns.
        First Column contains the name of Platform.
        Second column contains the File Upload.
        Third Column contains SubmitF button
        Fourth olumn contains File Download.

        So now i want that in table for each platform i get a download link in the fourth column.
        i.e for paltform1 i get download link1 in fourth column  similarly for platform 2 i get download link2 in fourth column

        But at this stage i get download link only for the first platform ,is there a way of getting different download link for different platforms.

        What i am getting is:
        Platform    FileUpload  Button   FileDownload
        Platform1 ….. Browse Submit     link1
        Platform2 ….. Browse Submit     link1

        But i want is
        Platform2 ….. Browse Submit     link2

        So can you please guide me again.

        Regards
        Tauseef

        (0) 
  2. Som Sarkar
    Hi Rekha

    When i did create the App following this blog. I get an exception saying :

    com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: DataSource attribute of table not valid. [Table Table in view class com.sap.tc.webdynpro.progmodel.generation.DelegatingView]

    Here in the properties view of the table,
    Datasource is required to mapped to some attribute, otherwise its saying INVALID

    Any help on this issue from ur end

    (0) 
    1. Rekha Malavathu Post author
      Hi Som Sarkar,

      Will you please let me know the version of the NetWeaver Developer Studio that you are currently working on?

      With NWDS 2004S this shouldnt happen.

      Regards,
      Rekha Malavathu

      (0) 
      1. Som Sarkar
        Hi Rekha

        Here i am using SAP NWDS with version: 7.0.10

        So, can u pls help to make some modifications for the same App under this NWDS. I’ll be obliged if you honor this.

        Thanks

        Som

        (0) 
        1. Have you found any solution for this problem?  I am having same issue.

             com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: DataSource attribute of table not valid. [Table Table_0_1_2 in view class com.sap.tc.webdynpro.progmodel.generation.DelegatingView]

               at com.sap.tc.webdynpro.clientserver.uielements.adaptbase.AbstractAdapter._assertionFailed(AbstractAdapter.java:240)

               at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.TableAdapter.setViewAndNodeElement(TableAdapter.java:336)

               at com.sap.tc.webdynpro.clientserver.uielements.adaptmgr.URAdapterManager.getAdapterFor(URAdapterManager.java:285)

               at com.sap.tc.webdynpro.clientserver.uielements.adaptmgr.URAdapterManager.getAdapterFor(URAdapterManager.java:93)

               at com.sap.tc.webdynpro.clientserver.uielements.adaptbase.AbstractAdapter.getAdapterFor(AbstractAdapter.java:495)

               at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.FlowLayoutAdapter$Items.getControl(FlowLayoutAdapter.java:368)

               at com.sap.tc.ur.renderer.nn7.FlowLayoutRenderer.renderFlowLayoutItemFragment(FlowLayoutRenderer.java:307)

               at com.sap.tc.ur.renderer.nn7.FlowLayoutRenderer.renderFlowLayoutFragment(FlowLayoutRenderer.java:244)

               at com.sap.tc.ur.renderer.nn7.FlowLayoutRenderer.render(FlowLayoutRenderer.java:49)

               at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)

               at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)

               at com.sap.tc.ur.renderer.nn7.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:572)

               at com.sap.tc.ur.renderer.nn7.ScrollContainerRenderer.render(ScrollContainerRenderer.java:74)

               at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)

               at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)

               at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.UiWindowRenderer.render(UiWindowRenderer.java:52)

               at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:434)

               at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.RenderManager.render(RenderManager.java:133)

               at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendHtml(HtmlClient.java:1058)

               at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.fillDynamicTemplateContext(HtmlClient.java:458)

               at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendResponse(HtmlClient.java:1247)

               at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.retrieveData(HtmlClient.java:253)

               at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doRetrieveData(WindowPhaseModel.java:595)

               at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:156)

               at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)

               at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)

               at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:321)

               at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:713)

               at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:666)

               at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)

               at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)

               at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)

               at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:46)

               at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

               at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

               at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)

               at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)

               at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)

               at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)

               at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)

               at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)

               at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)

               at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)

               at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)

               at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)

               at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

               at java.security.AccessController.doPrivileged(Native Method)

               at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102)

               at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)

          (0) 

Leave a Reply