cancel
Showing results for 
Search instead for 
Did you mean: 

PDF fails to open inplace after upgrade NW 7.01 to NW 7.31

Former Member
0 Kudos

Hello everyone, hope all is well.

I am trying to remediate some post implementation defects raised by our Web Dynpro Java applications after our NetWeaver upgrade.

Here we have a block of code that was previously successful in opening a PDF document in place:

// Convert the context element to a Byte Stream

byte[] PDF = wdContext.currentVn_ViewElement().getVa_PDFsource();

// Create a new Resource to store the PDF on the File System

IWDCachedWebResource resource = WDWebResource.getPublicCachedWebResource(

PDF,

WDWebResourceType.getWebResourceType("application/pdf","PDF"),

WDScopeType.CLIENTWINDOW_SCOPE,

wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),

wdContext.currentVn_UserElement().getVa_Perner() + wdContext.currentVn_UserElement().getVa_UserID()

);

resource.setResourceName("Generic_Statement");

//Create a External Window with the URL destination of the file we created above.

IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getURL(), "Generic_Statement");

//Eliminate some features of the window

window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);

window.removeWindowFeature(WDWindowFeature.MENU_BAR);

window.removeWindowFeature(WDWindowFeature.STATUS_BAR);

window.removeWindowFeature(WDWindowFeature.TOOL_BAR);

window.setWindowSize(780,430);

window.setWindowPosition(20,140);

window.setTitle("Generic_Statement");

//Show the Window to the Users

window.show();

//Now that we have shown it to the user, blow it up

window.destroyInstance();               

//Blow up the PDF ByteStream

PDF = null;

After our upgrade, the PDF document no longer opens in place, and instead we are presented with a file save dialog that no longer identifies the correct file type. No file extension is added to the file name in the save dialog, but sometimes if we manually append the .pdf file extension the document will save to the file system, where it can be opened successfully. Other times it will simply raise an error that the file is corrupt.

Lots of classes and methods were deprecated between the two versions of NetWeaver, so I set about to update the libraries and revise the code. Here is what I came up with trying to get the above statements working again:

// Convert the context element to a Byte Stream

byte[] bytesPDF = wdContext.currentVn_ViewElement().getVa_PDFsource(); // Va_PDFSource is binary datatype


// A deployable object part is actually the current development component

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


// UserID and PerNum form the key

String keyPDF = wdContext.currentVn_UserElement().getVa_Perner() + wdContext.currentVn_UserElement().getVa_UserID();

// Create a new Resource to store the PDF on the File System

IWDCachedWebResource resourcePDF = WDWebResource.getPublicCachedWebResource(

bytesPDF,

WDWebResourceType.PDF,

WDScopeType.APPLICATION_SCOPE, // we were using WDScopeType.CLIENTSESSION_SCOPE but that has been deprecated

objPartPDF,

keyPDF);

resourcePDF.setResourceName("Generic_Statement");

// the setReadOnce method is our attempt to sustain the behavior we lost when CLIENTSESSION_SCOPE was deprecated

resourcePDF.setReadOnce(true);

//Create a External Window with the URL destination of the file we created above.

IWDWindow windowPDF = wdThis.wdGetAPI().getWindowManager().createNonModalExternalWindow(resourcePDF.getUrl(0));


// CreateNonModalExternalWindow method has changed and no longer accepts URL and window name as parameters, just URL

// Eliminate some features of the window

windowPDF.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);

windowPDF.removeWindowFeature(WDWindowFeature.MENU_BAR);

windowPDF.removeWindowFeature(WDWindowFeature.STATUS_BAR);

windowPDF.removeWindowFeature(WDWindowFeature.TOOL_BAR);

windowPDF.setWindowSize(780,430);

windowPDF.setWindowPosition(20,140);

windowPDF.setTitle("Generic_Statement");


// Show the Window to the Users

windowPDF.show();

//Now that we have shown it to the user, blow it up

windowPDF.destroyInstance();

              

//Blow up the PDF ByteStream

bytesPDF = null;

These code changes had no impact, the defect symptoms remain exactly the same. The PDF document does not open in place, and the file save dialog still does not identify the PDF resource type.

I have combed the forums and found great advice that got me to this point, but my code is still broken. Can anyone help me spot the error?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

My brilliant colleague found that it was not necessary to create the IWDCachedWebResource resource using the getPublicCachedWebResource method, we saw the results we needed with the more generic (but deprecated) getWebResource method:

IWDCachedWebResource resource = WDWebResource.getWebResource(bytesPDF, WDWebResourceType.getWebResourceType("application/pdf","PDF"));

Fewer arguments, too, and no need to manually manage the resource scope or build a key value.

SAP Library documents instruct us to use WDResourceFactory class instead of the deprecated method WDWebResource.getWebResource, so we will try that too and use the factory method instead if it works.

But for now we are operational again.

Answers (0)