use of com.sap.conn.idoc.IDocSyntaxException in project iaf by ibissource.
the class IdocXmlHandler method endElement.
public void endElement(String uri, String localName, String qName) throws SAXException {
// log.debug("endElement("+localName+")");
if (currentField != null) {
String value = currentFieldValue.toString().trim();
if (StringUtils.isNotEmpty(value)) {
if (parsingEdiDcHeader) {
if (log.isDebugEnabled())
log.debug("parsed header field [" + currentField + "] value [" + value + "]");
try {
if (currentField.equals("ARCKEY")) {
doc.setArchiveKey(value);
} else if (currentField.equals("MANDT")) {
doc.setClient(value);
} else if (currentField.equals("CREDAT")) {
doc.setCreationDate(value);
} else if (currentField.equals("CRETIM")) {
doc.setCreationTime(value);
} else if (currentField.equals("DIRECT")) {
doc.setDirection(value);
} else if (currentField.equals("REFMES")) {
doc.setEDIMessage(value);
} else if (currentField.equals("REFGRP")) {
doc.setEDIMessageGroup(value);
} else if (currentField.equals("STDMES")) {
doc.setEDIMessageType(value);
} else if (currentField.equals("STD")) {
doc.setEDIStandardFlag(value);
} else if (currentField.equals("STDVRS")) {
doc.setEDIStandardVersion(value);
} else if (currentField.equals("REFINT")) {
doc.setEDITransmissionFile(value);
} else // else if (currentField.equals("EXPRSS")) { doc.setExpressFlag(value); }
if (currentField.equals("DOCTYP")) {
doc.setIDocCompoundType(value);
} else if (currentField.equals("DOCNUM")) {
doc.setIDocNumber(value);
} else if (currentField.equals("DOCREL")) {
doc.setIDocSAPRelease(value);
} else if (currentField.equals("IDOCTYP")) {
doc.setIDocType(value);
} else if (currentField.equals("CIMTYP")) {
doc.setIDocTypeExtension(value);
} else if (currentField.equals("MESCOD")) {
doc.setMessageCode(value);
} else if (currentField.equals("MESFCT")) {
doc.setMessageFunction(value);
} else if (currentField.equals("MESTYP")) {
doc.setMessageType(value);
} else if (currentField.equals("OUTMOD")) {
doc.setOutputMode(value);
} else if (currentField.equals("RCVSAD")) {
doc.setRecipientAddress(value);
} else if (currentField.equals("RCVLAD")) {
doc.setRecipientLogicalAddress(value);
} else if (currentField.equals("RCVPFC")) {
doc.setRecipientPartnerFunction(value);
} else if (currentField.equals("RCVPRN")) {
doc.setRecipientPartnerNumber(value);
} else if (currentField.equals("RCVPRT")) {
doc.setRecipientPartnerType(value);
} else if (currentField.equals("RCVPOR")) {
doc.setRecipientPort(value);
} else if (currentField.equals("SNDSAD")) {
doc.setSenderAddress(value);
} else if (currentField.equals("SNDLAD")) {
doc.setSenderLogicalAddress(value);
} else if (currentField.equals("SNDPFC")) {
doc.setSenderPartnerFunction(value);
} else if (currentField.equals("SNDPRN")) {
doc.setSenderPartnerNumber(value);
} else if (currentField.equals("SNDPRT")) {
doc.setSenderPartnerType(value);
} else if (currentField.equals("SNDPOR")) {
doc.setSenderPort(value);
} else if (currentField.equals("SERIAL")) {
doc.setSerialization(value);
} else if (currentField.equals("STATUS")) {
doc.setStatus(value);
} else if (currentField.equals("TEST")) {
doc.setTestFlag(value);
} else {
log.warn("header field [" + currentField + "] value [" + value + "] discarded");
}
} catch (IDocConversionException e) {
throw new SAXException("could not parse header field, idoc conversion exception", e);
} catch (IDocSyntaxException e) {
throw new SAXException("could not parse header field, idoc syntax exception", e);
}
} else {
IDocSegment segment = (IDocSegment) segmentStack.get(segmentStack.size() - 1);
if (log.isDebugEnabled())
log.debug("setting field [" + currentField + "] to [" + value + "]");
try {
segment.setValue(currentField, value);
} catch (IDocFieldNotFoundException e) {
throw new SAXException("could not set field [" + currentField + "] to [" + value + "], idoc field not found", e);
} catch (IDocConversionException e) {
throw new SAXException("could not set field [" + currentField + "] to [" + value + "], idoc conversion exception", e);
} catch (IDocSyntaxException e) {
throw new SAXException("could not set field [" + currentField + "] to [" + value + "], idoc syntax exception", e);
}
}
}
currentField = null;
currentFieldValue.setLength(0);
} else {
if (parsingEdiDcHeader) {
parsingEdiDcHeader = false;
} else {
if (segmentStack.size() > 0) {
segmentStack.remove(segmentStack.size() - 1);
}
}
}
}
Aggregations