on 04-24-2009 2:12 PM
Hi,
I want to develop custom action with xml type input and/or output parameter.
Is there sample code for java side. How is the definition of input and/or output parameter and set/get methods?
does it need special .jar file to develop custom action like this?
Thanks.
Cemil - yes, you can use XML data types. Use the class
com.sap.lhcommon.xml.XMLDataType
for your parameter type. Here is a snippet from a custom action we use to log XML (instead of just returning the #text node like the default logger does):
public class XMLLogger extends ActionReflectionBase
{
private String source;
private String eventType;
private String textMessage;
private XMLDataType xmlMessage;
...
public XMLLogger()
{
log = new Logger("UserLog");
source = DEFAULT_SOURCE;
eventType = TYPE_INFO;
textMessage = "";
xmlMessage = new XMLDataType();
}
...
public XMLDataType getXmlMessage()
{
return xmlMessage;
}
public void setXmlMessage(XMLDataType xmlMessage)
{
this.xmlMessage = xmlMessage;
}
...
public void Invoke(Transaction transaction, ILog ilog)
{
StringBuffer sb = new StringBuffer();
sb.append('[');
sb.append(source);
sb.append("] ");
sb.append(textMessage);
sb.append(XMLUtils.convertXmlToString(xmlMessage));
...
}
}
XMLUtils is a helper class we wrote - it's just a bunch of standard Java XML boilerplate code. The important part you need to know is XMLDataType.getDocument() will return an org.w3c.dom.Document.
I hope that was enough information to help.
-tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cemil,
The logger was com.sap.xmii.system.Logger, but you should be using [NW logging API|http://help.sap.com/saphelp_nwce10/helpdata/en/4a/c3953ff1353c17e10000000a114084/frameset.htm].
As I explained in my previous, XMLUtils is a class we wrote - the import statement would do you no good. Once you have the org.w3c.dom.Document via XMLDataType.getDocument(), then you have everything you need. I don't have all my documentation in front of me, but I'm going to assume there is an XMLDataType.setDocument(org.w3c.dom.Document) method too. If you are interested, here is the standard Java code we use to transform the XML to a String:
...
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
DOMSource source = new DOMSource(xml.getDocument());
sw = new StringWriter();
StreamResult result = new StreamResult(sw);
transformer.transform(source, result);
return sw.toString();
...
Note that the variable "xml" is an XMLDataType and that all exception handling is omitted.
-tim
Mike, there is no plan to update the article for 12.x. It would be nice, but I'm sufficiently removed from everyday development of our ERP integration that I no longer feel qualified to write it.
Besides, I'm still miffed that MII came out with dynamic transaction calls in 12.0. Part 2 of the series of articles was going to show how we implemented a dynamic transaction call custom action...
-tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tim and Mike,
Thanks you both for help.
I ask if there is XML typed parameter in custom action.
I already wrote some custom actions but parameters were simple types (string, integer etc. (not xml)).
I need som information if custom action has XML typed parameter.How to handle it in java side?
Is there sample for this variation of custom action.
Thanks.
The article Mike refers to is [here|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0407ed8-7f81-2a10-d49e-ea99d6b744cb]. This was for MII 11.5.
-tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cemil,
Start here:
[https://wiki.sdn.sap.com/wiki/display/xMII/Customization]
Sam has not updated his custom action instructions from his 11.5 document, but most of it should still be useful information. I also think Tim Drury wrote an article about it. I will see if I can find a link to it if you need to see it. Let me know if you need more help than the wiki holds.
Regards,
Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
7 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.