cancel
Showing results for 
Search instead for 
Did you mean: 

Adapter modules

Former Member
0 Kudos

Hi ,

Can any one suggest me where to use adapter modules ?Any real time instance? Any use full material in this regard ?

Thanks and Regards

Mahesh.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

i think you have all the document for adapter module... Here is a sample example of code...that we had developed...

basically all you logic will b implemented in process method...

where you read the payload... convert it into appropriate format and

then you implement you business logic of the payload...

in the end you set the payload so that standard module of xi can red the payload and do the further processing.....

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)

throws ModuleException

{

Object obj = null; // Handler to get Principle data

Message msg = null; // Handler to get Message object

try

{

obj = inputModuleData.getPrincipalData();

msg = (Message)obj;

try

{

XMLPayload xmlpayload = msg.getDocument();

String messageStr = xmlpayload.getText();

String inputStr = null;

String tags[] = new String[2];

String values[] = new String[2];

String tagvalue1 = messageStr.substring(messageStr.indexOf("BEGIN+"), messageStr.indexOf("'");

String tagvalue2 = messageStr.substring(messageStr.indexOf("'"), messageStr.lastindexOf("ENDING");

tags[0] = "tag1";

tags[1] = "tag2";

values[0] = tagvalue1 ;

values[1] = tagvalue2 ;

Document xmldoc = null;

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

DOMImplementation impl = builder.getDOMImplementation();

org.w3c.dom.Element e = null;

Node n = null;

xmldoc = impl.createDocument(null, "MT940", null);

org.w3c.dom.Element root = xmldoc.getDocumentElement();

for(int i = 0; i < tags.length; i++)

{

e = xmldoc.createElementNS(null, tags);

n = xmldoc.createTextNode(values);

e.appendChild(n);

root.appendChild(e);

}

DOMSource domSource = new DOMSource(xmldoc);

ByteArrayOutputStream myBytes = new ByteArrayOutputStream();

Result dest = new StreamResult(myBytes);

TransformerFactory tf = TransformerFactory.newInstance();

Transformer serializer = tf.newTransformer();

serializer.setOutputProperty("indent", "yes");

serializer.transform(domSource, dest);

byte[] docContent = myBytes.toByteArray();

if (docContent != null) {

xmlpayload.setContent(docContent);

inputModuleData.setPrincipalData(msg);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"sample: Inside sample Module---after setting principal data");

}

}

}

catch(ArrayIndexOutOfBoundsException e)

{

e.printStackTrace();

}

catch(StringIndexOutOfBoundsException e)

{

e.printStackTrace();

}

catch(TransformerException e)

{

e.printStackTrace();

}

catch(Exception e)

{

e.printStackTrace();

}

}

catch(Exception e)

{

ModuleException me = new ModuleException(e);

throw me;

}

return inputModuleData;

}

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Go through the following links....

/people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter

/people/sap.user72/blog/2005/07/15/copy-a-file-with-same-filename-using-xi

PPT: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e21106cc-0c01-0010-db95-dbfc0ffd...

How to Guide: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f013e82c-e56e-2910-c3ae-c602a67b...

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/02706f11-0d01-0010-e5ae-ac2...

regards,

vasanth

prateek
Active Contributor
0 Kudos

<i>Can any one suggest me where to use adapter modules ?</i>

To enhance the functionality provided by the existing adapters

<i>Any real time instance?</i>

For conversion of EDI files (EDIFACT and ANSI X12), u may write a module for file adapter which may convert the EDI files to xml files.

<i>Any use full material in this regard ?</i>

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e21106cc-0c01-0010-db95-dbfc0ffd...

Regards,

Prateek

Former Member
0 Kudos

helpful one::

/people/michal.krawczyk2/blog/2006/10/09/xi-dynamic-configuration-in-adapter-modules--one-step-further

Regards,

Pratibha

Former Member
0 Kudos

Hi,

We use adapter module when we want to enhance the existing adapter.

Regards,

S.RamNarender