Maintain PI 7.1 Adapter Modules in NWDI

Maintain PI 7.1 Adapter Modules in NWDI


As NWDI get's more powerful I try to use it for an increasing number of projects. In that spirit I've picked up the topic of putting PI Adapters and Modules under NWDI-control again and digged through the available SCs.

The good message: One can easily develop PI Modules in NWDI, the only thing needed are the right dependencies. Here's a brief walkthrough:

Set up the NWDI-Project

  • add the SC SAP_XIAF to your track. I used SAPXIAF06P_7-20001975.SCA, if you know whether this guide also works on 3.0, 7.0 and 7.11 components please add a comment
  • create a new J2EE/EJB Module, remember to set the Java EE Version to 1.4
  • create a new J2EE/Enterprise Application, remember to set the Java EE Version to 1.4 and reference the module
  • add references to the SC SAP_XIAF:

  1. com.sap.aii.af.ifc.facade for the Message-Interfaces
  2. com.sap.aii.af.lib.facade for the Module-Interfaces
SAP_XIAF references


  • for facilitating the logging api you might also want to reference

  1. tc/bl/logging/api

ENGFACADE references



Alltogether the module's references should look like this:

all needed references

  • Also add those references to the Enterprise Application DC, don't forget to set the deploy time & run time reference hooks

deploy & runtime references


Develop the module

Now you're all set up and ready to go. Create an EJB 2.1 Stateless Session Bean implementing com.sap.aii.af.lib.mp.module.Module...

/*
* (non-Javadoc)
*
* @see com.sap.aii.af.lib.mp.module.Module#process(com.sap.aii.af.lib.mp.module.ModuleContext,
* com.sap.aii.af.lib.mp.module.ModuleData)
*/
public ModuleData process(ModuleContext ctx, ModuleData md)
throws ModuleException {
final com.sap.engine.interfaces.messaging.api.Message message;
final com.sap.engine.interfaces.messaging.api.XMLPayload document;
final com.sap.engine.interfaces.messaging.api.auditlog.AuditAccess auditAccess;

try {
Object principalData = md.getPrincipalData();
message = (com.sap.engine.interfaces.messaging.api.Message) principalData;
document = message.getDocument();
auditAccess = com.sap.engine.interfaces.messaging.api.PublicAPIAccessFactory
.getPublicAPIAccess().getAuditAccess();
auditAccess
.addAuditLogEntry(
message.getMessageKey(),
com.sap.engine.interfaces.messaging.api.auditlog.AuditLogStatus.SUCCESS,
"Everything is fine.");

document.setContent("important message".getBytes());

return md;
} catch (Exception e) {
throw new ModuleException("Cannot process message in module: " + e,
e);
}

}


Remember you still need to set up ejb-jar.xml, ejb-j2ee-engine.xml and application-j2ee-engine.xml. Consult help.sap.com and the sample module for detailed documentation.

When you're done you can use shiny things like CBS and CMS for your new module.

Note:

  1. There is another blog you might want to have a look at by Alka Panday: "J2EE Adapter Module development using NWDI" describing how to expose the SAP libraries as external library DCs.
  2. If you know a more EJB3-like way to get a working module please drop me some lines.

SAP Developer Network SAP Weblogs: SAP Process Integration (PI)