cancel
Showing results for 
Search instead for 
Did you mean: 

Convert xstring to Word Document

Former Member
0 Kudos

Hi All,

Can you please give me solution for the following scenario.

In R/3 they are converting Word Template as XString type.

From RFC, i am getting XString type as export parameter.

Now i need to convert that xstring and open it as word document template in webdynpro java.

Regards,

Suresh T

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182374
Active Contributor
0 Kudos

Hi,

Use the following code:

byte[] wordFile = wdContext.currentRFC_Output.getXString(); // From your BAPI...

IWDCachedWebResource cachedWordResource = null;

cachedWordResource = getCachedWebResource(

wordFile, "sample.doc", WDWebResourceType.DOC);

cachedWordResource.getURL()

private IWDCachedWebResource getCachedWebResource(byte[] file, String name,

WDWebResourceType type) {

IWDCachedWebResource cachedWebResource = null;

if (file != null) {

cachedWebResource = WDWebResource.getWebResource(file, type);

cachedWebResource.setResourceName(name);

}

return cachedWebResource;

}

Former Member
0 Kudos

Hi Omri,

Already i tried using the following code,

byte[] docContent = wdContext.currentOutputElement().getE_Xstring();

WDDeployableObjectPart objPart = wdThis.wdGetAPI().getComponent().getDeployableObjectPart();

IWDCachedWebResource webCache = WDWebResource.getPublicCachedWebResource(docContent,WDWebResourceType.DOC,WDScopeType.APPLICATION_SCOPE,objPart,"DocGeneration");

wdComponentAPI.getWindowManager().createNonModalExternalWindow(webCache.getURL(),"DocGeneration").open();

After external browser is triggered, it is asking the Options 'Open', 'Save' & 'Cancel'.

But on clicking 'Open' it is throwing error Page cannot be displayed.

Regards,

Suresh T

former_member182374
Active Contributor
0 Kudos

Hi,

Are you sure you used my code?

When you use the code you supplied the application will look for the Word file in the mimes folder under the component).

Please use the code I supplied and see what happens...

Regards,

Omri

Former Member
0 Kudos

Hi Omri,

I have tried using your code, but still im getting the same error "Page cannot be displayed".

Regards,

Suresh T

Former Member
0 Kudos

Hi,

Can you replace one of your line with the following:

wdComponentAPI.getWindowManager().createNonModalExternalWindow(webCache.getAbsoluteURL(),"DocGeneration").open(); 

The change is: use of getAbsoluteURL() method.

I hope this will solve your problem!

-kunal kotak

Former Member
0 Kudos

Hi,

I have already tried this way, but still im facing the same issue.

Regards,

Suresh T