cancel
Showing results for 
Search instead for 
Did you mean: 

Display .doc file in new window by url

Former Member
0 Kudos

Hi all,

I hope someone got a quick an easy solution for this one.

I want to access and display (open/save) a .doc file in a new separate window by using createExternalWindow(docUrl, xxx, xxx), where docUrl is a path on the local webAS. Right now I access the file like this:

File doc = new File("apps/local/filename.doc");

wdComponentAPI.getWindowManager().createExternalWindow(doc.getURL(), "", false).open;

This does not work though, since it gives me the absolute path from the hard drive letter and down, ie: c:/usr/sap/../filename.doc

We havent installed Office Integration on our webAS.

Anyone? All help help is appreciated. This doesn't feel like it should be a big issue?!

Best regards,

Andreas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Andreas,

Here is probably not the optimal and not the most intuitive way to perform this task, but anyway:

1. In View controller context create attribute with type <b>binary</b>, let us name it <b>MyDoc</b>

2. In View controller source define private variable

private ISimpleType _msWordType

3. In View controller wdDoInit method place the following:

_msWordType = wdContext
  .getNodeInfo()
    .getAttribute("MyDoc")
      .getModifiableSimpleType();
((IWDModifiableBinaryType)_msWordType).setMimeType( WDWebResourceType.DOC );
((IWDModifiableBinaryType)_msWordType).setFileName( "MyMsWordDocument.doc" );

4. Use the following docUrl when calling createExternalWindow

/* Load document content first */
final byte[] documentContent = loadDocumentBytes();
/* And now the trick itself */
final String docUrl = _msWordType.format( documentContent );

We successfully apply this technique to display photo from employee profile loaded from database

VS

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello Valery!

Thanks very much for your input!

I will be sure to try that out as well.

Right now I put the word documents I want to be able to access in src/mimes/Components and deploy them with the rest of the application. This was the advice I got from SAP. It's a fairly straight forward solution, but I like yours better!

Best regards,

Andreas

Former Member
0 Kudos

It also seems I don't use the correct object name. What is this referring to? My project name, app name, my fully qualified name (ie dev.test.app)?

Best regards,

Andreas

Former Member
0 Kudos

Thx for your replies!

It sure sounds like the thing I want to do, but so far I haven't been able to successfully load my word document.

Seems it's supposed to be put in a folder /webdynpro/resources on the app-server, but I can't even find this directory? Where is it supposed to located? Thanks!

Best regards,

Andreas

Former Member
0 Kudos

Take a look at the IWDURLGenerator API. You probably want to use the method getAbsoluteWebResourceURL().

Former Member
0 Kudos

Small correction: It's a class, so it is named WDURLGenerator. See:

<a href="

https://media.sdn.sap.com/javadocs/NW04/SP9/webdynpro/com/sap/tc/webdynpro/services/sal/url/api/WDUR...

">https://media.sdn.sap.com/javadocs/NW04/SP9/webdynpro/com/sap/tc/webdynpro/services/sal/url/api/WDURLGenerator.html</a>

Armin