cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in Excel to XML Conversion

Former Member
0 Kudos

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

View Entire Topic
anandvithal
Active Participant
0 Kudos

Hi,

If you have NWDS 7.3 then try this

In the build path screen of the ejb project click add library

select XPI library

Select XPI adapter library

apart from the standard jars if you have any other jars, add them manually.

Thanks,

Anand

Former Member
0 Kudos

HI anand,

Thanks for your help it resolved some errors but still i m facing some errors.

Can u help on resolving these issues.

Thanks Mridul

jyothi_anagani
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Jyothi,

Thanks for your valuable help. But I am struck at one point I imported all the jars in NWDS 7.3

Former Member
0 Kudos

Hi Jyothi,

Thanks for your help. But i am struck at one point I importd all Jars according to  NWDS 7.3 but for following classes I am not able to figure out which jar to use

Audit;

AuditDirection;

AuditMessageKey;


for AuditLogStatus;


i am using the below mentioned api

com.sap.engine.interfaces.messaging.api.auditlog.AuditLogStatus;


It would be really helpful if u can tell where to get these classes.

jyothi_anagani
Active Contributor
0 Kudos

Hi Mridul,

Have you imported these?

import com.sap.aii.af.mp.module.Module;
import com.sap.aii.af.mp.module.ModuleContext;
import com.sap.aii.af.mp.module.ModuleData;
import com.sap.aii.af.mp.module.ModuleException;
import com.sap.aii.af.ra.ms.api.Message;
import com.sap.aii.af.ra.ms.api.MessageDirection;
import com.sap.aii.af.ra.ms.api.XMLPayload;
import com.sap.aii.af.service.auditlog.Audit;
import com.sap.aii.af.service.auditlog.AuditDirection;
import com.sap.aii.af.service.auditlog.AuditLogStatus;
import com.sap.aii.af.service.auditlog.AuditMessageKey;

For more information please refer

XI libraries for development - Process Integration - SCN Wiki

Adapter Module Development

PI 7.0(3.0)
PI 7.1/7.3
aii_af_mp.jar
com.sap.aii.af.lib.mod.jar
aii_af_ms_api.jar
com.sap.aii.af.ms.ifc_api.jar
aii_af_trace.jar
sap.com~tc~logging~java~impl.jar
aii_af_svc.jar
com.sap.aii.af.svc_api.jar
aii_af_cpa.jar
com.sap.aii.af.cpa.svc.api.jar

Please let me know if you need more details.

Thanks

Jyothi A

Former Member
0 Kudos

Hi Jyothi,

I have imported all these except these two classes 

import com.sap.aii.af.service.auditlog.Audit;

import com.sap.aii.af.service.auditlog.AuditDirection;


as the following jar is unavailable in my setup. com.sap.aii.af.service.auditlog

Thanks

Mridul Manchanda