on 07-11-2007 4:12 PM
Hi, all,
I want to create a pdf file with xstring(255044462D...) using java. Is there anybody know how to do it? Thanks a lot!
Marea
Hi Marea,
I made an Web Dynpro Java application that receive a xstring type from RFC back-end and show a PDF file at the window. That's work very nice and is so easy to implement.
It is the code at the iview:
IWDCachedWebResource resource = WDWebResource.getWebResource(wdContext.currentZ_Pdf_Report_OutputElement().getPdf(), WDWebResourceType.getWebResourceTypeForFileExtension("pdf"));
// xstring type is wdContext.currentZ_Pdf_Report_OutputElement().getPdf()
resource.setResourceName(this.getDescriptionReport());
// Create a External Window with the URL destination
IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(resource.getURL(), this.getDescriptionReport(), true);
// 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.open();
I hope it help you!!!
Regards,
Luciano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Luciano,
Thanks for the reply. But I never used web Dynpro. When I use your java code, I got a lot of errors says those methods like "IWDCachedWebResource, wdContext.....can not be resolved). I guess those are Web Dynpro method. I use SAP NetWeaver Developer Studio. I don't know how I can use those methods into my program. Would you please give me more clues? Thank you!
Marea
Hi Marea,
Try to create the first WD application, its so easy. After the first contact, try to puts that code at the method to hande any action( i.e. button pressed).
This code will just open um Xstring data as PDF. Before that, I guess, you have to execute some RFC to get this data.
This is the way!
Regards,
Luciano
Marea,
i'm not really familiar with XI adapters, but a more basic way to do it (without WD, even if i love it) is:
1. You must have the remote function module available, which delivers the XSTRING data (let's call it Z_GET_PDF).
2. Import the function module (FM) interface using the Enterprise Connector import feature in the NWDS. This gives you the classes/jar to access the FM in a type-safe manner. The import can be done into a plain Java project, which has to reference the aii_proxy related jars and the sapmwjco.jar to resolve the compile time errors.
3. The import always generates xxxInput, xxxOutput classes and a single xxxPorttype class. So for the example, this might result in something like Z_Get_PdfInput, Z_Get_PdfOutput and PdfModulePorttype, if you specify the port type name as "PdfModule" in the EC import wizard.
4. Using is easy. Pseudo-Code:
// Instantiate the port type
PdfModulePortType port = new PdfModulePortType();
// Instantiate the input (IMPORT parameters/tables of FM)
Z_Get_PdfInput input = new Z_Get_PdfInput();
// Set the name/ID whatever of the PDF to load...
input.setPdfID("test_pdf");
// You must have the JCO client connection available.
// This is configurable in XI, isn't it? ;)
// The connection must be set in the port-type.
// This method might have another, rather similar name (writing this from my internal memory hmpf)
port.messageSpecifier.setJCOClient(client);
// Now execute the FM using the port type and get the result (output)
// Of course you have to catch the (runtime) exceptions in real life.
Z_Get_Pdf_Output output = port.executeZ_Get_Pdf(input);
// In case of XSTRING, you should get a byte[] in Java.
// This is already the data representing the PDF file.
byte[] pdfData = output.getXStringData();
// Do something with pdfData, create file or whatever.
Hope that helps.
Regards,
Stefan
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.