Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Issue in Excel to XML Conversion

Hi Gurus,

I am creating a custom java module in sap nwds 7.3 for Excel to XML Conversion. But I am getting following error

Classpath dependency validator message.

Classpath entry  will not be exported or published. Runtime ClassNotFoundExceptions may result.


I imported the Jars from a different PI system and i am using NWDS in local PC with creating a separate folder with all JARs and also imported them using build path option.

This issue is occuring for all the jars imported.

I am using following code.

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.io.OutputStream;

import java.util.Map;

import com.sap.aii.mapping.api.StreamTransformation;

import com.sap.aii.mapping.api.AbstractTrace;

import java.util.HashMap;

import jxl.Cell;

import jxl.Workbook;

public class JavaMappingExcelToXML implements StreamTransformation{

private Map map = null;

private AbstractTrace trace = null;

public void setParameter(Map arg0) {

map = arg0; // Store reference to the mapping parameters

if (map == null) {

this.map = new HashMap();

}

}

/*

public static void main(String args[]) { //FOR EXTERNAL STANDALONE TESTING

try {

FileInputStream fin = new FileInputStream ("c:/ashu.xls"); //INPUT FILE (PAYLOAD)

FileOutputStream fout = new FileOutputStream ("C:/Users/ashutosh.a.upadhyay/My Documents/ashuXML2.xml"); //OUTPUT FILE (PAYLOAD)

JavaMappingXLStoXML mapping = new JavaMappingXLStoXML ();

mapping.execute(fin, fout);

}

catch (Exception e1) {

e1.printStackTrace();

}

}*/

public void execute(InputStream inputstream, OutputStream outputstream) {

String msgType = "Message Type name will come here";

String nameSpace = "Namespace Name will come here";

String xmldata = "";

try {

Workbook wb = Workbook.getWorkbook(inputstream);

xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ "<ns0:"+msgType+" "+"xmlns:ns0=\""+nameSpace+"\n">";

Cell[] cells ;

Cell[] cellNames ;

cellNames = wb.getSheet(0).getRow(0);

for(int j=1;j<wb.getSheet(0).getRows();j++){

xmldata = xmldata+"\n<Record>\n";

cells = wb.getSheet(0).getRow(j);

for(int i=0;i<wb.getSheet(0).getColumns();i++){

xmldata = xmldata+"\t<"+cellNames[i].getContents()+">"+cells[i].getContents()+"</"+cellNames[i].getContents()+">\n";

}

xmldata = xmldata+"</Record>";

}

xmldata = xmldata+"\n</ns0:"+msgType+">";

System.out.print(xmldata);

xmldata.getBytes();

wb.close();

byte by[] = xmldata.getBytes();

outputstream.write(by);

inputstream.close();

outputstream.close();

System.out.println("\n"+"File processed");

}

catch (Exception e) {

e.printStackTrace();

}

}

}

Request you to guide how to resolve this issue.

Thanks  in advance

Former Member
Former Member replied

Hi Mridul,

As per your error, Please import the below class in your imports.

com.sap.aii.mapping.api.AbstractTransformation;

And When I see your thread that its an Adapter module then why are you using an AbstractTransformation?

Please follow the bellow blog to create an adapter module to read an excel file

http://www.saptechnical.com/Tutorials/XI/Adapter/Index.htm

Thanks

Jyothi A

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question