Skip to Content
0
Former Member
Oct 30, 2009 at 10:51 AM

Integrate JasperReport using WebDynpro

60 Views

Hi all SAP experts

I wanted to ask if any of you can integrate using JasperReport webdynpro km??

I tried to do something like this:

public void wdDoInit()
  {
    //@@begin wdDoInit()
    byte[] baos = null;
	try{
	IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
	com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
	//create an ep5 user from the retrieved user
	IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
	ResourceContext resourseContext = new ResourceContext(ep5User);
	//Give the path to KM in the variable path
	IResourceFactory resourseFactory = ResourceFactory.getInstance();
	RID pathRID_JRXML = RID.getRID("/documents/pippo/FirstExample3.jrxml");//
	com.sapportals.wcm.repository.IResource resource = resourseFactory.getResource(pathRID_JRXML, resourseContext);
			
	HashMap data = new HashMap();
	data.put("NAME","Banana");
	ArrayList dataList=new ArrayList();
	dataList.add(data);
	dataSourceMap = new JRMapCollectionDataSource(dataList);
			
			
	byte[] pdfData = null;
	JasperDesign jasperDesign = JRXmlLoader.load(resource.getContent().getInputStream());
	JasperReport report = JasperCompileManager.compileReport(jasperDesign);
			
	JasperPrint reportPrint = JasperFillManager.fillReport(report,null,dataSourceMap);
			
	pdfData = JasperExportManager.exportReportToPdf(reportPrint);
	baos=pdfData;
	wdComponentAPI.getMessageManager().reportSuccess("success!");

	}
	catch (Exception e) 
	{
	wdComponentAPI.getMessageManager().reportException(e.getMessage() ,false);
	}
    //@@end
  }

But when I deploy gives me this error:

com.sap.engine.lib.xml.parser.NestedSAXParserException: Generic Exception: -> com.sap.engine.lib.xml.util.NestedException: Validation of xml instance document failed. No external schema is detected.

l'error is JasperReport report = JasperCompileManager.compileReport(jasperDesign);

can someone help me?

Thanks

Banana