Skip to Content

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

Java Mapping problem

I have a JDBC to RFC scenario where i require to use Java Mapping.

My jdbc pay load as below

<?xml version="1.0" encoding="utf-8" ?>

<ns:mt_test xmlns:ns="http://envision.com/jdbc">

<row>

<NEW_EVENT_MSG>

<ICSS>

<PREMISE_ID>1100036</PREMISE_ID>

<NO_WO>210711170148</NO_WO>

<TP_WO>XX07</TP_WO>

<FG_MANUAL_ORDER/>

<DT_REQUIRED>17-NOV-07</DT_REQUIRED>

</ICSS>

</NEW_EVENT_MSG>

</row>

</ns:mt_test>

I am trying to convert it to

<?xml version='1.0' encoding='UTF-8'?>

<ns0:ZXILOGGINGS_T xmlns:ns0="urn:sap-com:document:sap:rfc:functions">

<LOGS>

<item>

<MSGID>1100036</MSGID>

<WORKREQUEST>210711170148</WORKREQUEST>

<QMART>XX07</QMART>

<FG_MANUAL_ORDER></FG_MANUAL_ORDER>

<ORDERCREATIONDATE>17-NOV-07</ORDERCREATIONDATE>

</item>

</LOGS>

</ns0:ZXILOGGINGS_T>

Here is my java code

execute

public void execute(InputStream ins, OutputStream ops)

throws StreamTransformationException {

// TODO Auto-generated method stub

DefaultHandler handler = this;

SAXParserFactory factory = SAXParserFactory.newInstance();

try{

SAXParser saxParser = factory.newSAXParser();

Echo.out = ops;

saxParser.parse(ins, this);

}catch(Exception ex){

ex.printStackTrace();

}

}

start and end document

public void startDocument() throws SAXException {

emit("<?xml version='1.0' encoding='UTF-8'?>",true);

emit("<ns0:ZXILOGGINGS_T xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\">",true);

emit("<LOGS>");

}

public void endDocument() throws SAXException {

try {

nl();

emit("</LOGS>",true);

emit("</ns0:ZXILOGGINGS_T>",true);

Echo.out.flush();

} catch (Exception e) {

throw new SAXException("I/O error", e);

}

}

start and end

public void startElement(String namespaceURI,

String sName, // simple name

String qName, // qualified name

Attributes attrs)

throws SAXException {

echoText();

String eName = sName; // element name

if ("".equals(eName))eName = qName; // not namespace-aware

nl();

if( eName.equals("row")==true)

emitAttrs("<item>");

else if( eName.equals("ns:mt_test")==true){

}

else if( eName.equals("NEW_EVENT_MSG")==true){

}

else if( eName.equals("ICSS")==true){

}

else if( eName.equals("PREMISE_ID")==true){

emitAttrs("<MSGID>");

}

else if(eName.equals("NO_WO")==true)

emitAttrs("<WORKREQUEST>");

else if(eName.equals("TP_WO")==true)

emitAttrs("<QMART>");

else if(eName.equals("FG_MANUAL_ORDER")==true)

emitAttrs("<FG_MANUAL_ORDER>");

else if(eName.equals("DT_REQUIRED")==true)

emitAttrs("<ORDERCREATIONDATE>");

else

emitAttrs("<"eName">");

}

public void endElement(String namespaceURI, String sName, // simple name

String qName // qualified name

) throws SAXException {

echoText();

String eName = sName; // element name

if ("".equals(eName))

eName = qName; // not namespace-aware

if( eName.equals("row")==true)

emitAttrs("</item>");

else if( eName.equals("ns:mt_test")==true)

emitAttrs("");

else if( eName.equals("PREMISE_ID")==true){

emitAttrs("</MSGID>");

//emitAttrs("</PREMISE>");

}

else if(eName.equals("NO_WO")==true)

emitAttrs("</WORKREQUEST>");

else if(eName.equals("TP_WO")==true)

emitAttrs("</QMART>");

else if(eName.equals("FG_MANUAL_ORDER")==true)

emitAttrs("</FG_MANUAL_ORDER>");

else if(eName.equals("DT_REQUIRED")==true)

emitAttrs("</ORDERCREATIONDATE>");

else if( eName.equals("NEW_EVENT_MSG")==true) {

//emitAttrs("</MSGID>");

}

//emit("");

else if( eName.equals("ICSS")==true){

}

//emit("");

else {

emitAttrs("</" + eName + ">");

System.out.println("ENAME:::: "+eName);

}

}

characters method

public void characters(char buf[], int offset, int len)

throws SAXException {

String s = (new String(buf, offset, len)).trim();

if (textBuffer == null) {

textBuffer = new StringBuffer(s);

} else {

textBuffer.append(s);

}

}

IThe message keeps waiting in the Messgae Monitor. in the sxmb_moni i get the execute method is successful

Regards

Former Member
Not what you were looking for? View more on this topic or Ask a question