Skip to Content

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.
To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Dries Guth
    Robert,
    nice blog, didn’t talked about the content yet but – remembering the times working with modules in XI 7.0 😉

    One question: You mentioned “changing” the Java EE Version to 1.4 – What’s with the 5.0 or 6.0 JAVA EE Version in PI 7.1? Don’t we need to set up the NWDI to JAVA EE 5.0 or 6.0 developing PI 7.1 modules?

    Regards,
    Dries

    (0) 
    1. Robert Schimansky Post author
      Hi Dries,

      thanks for the response.

      >modules in XI 7.0 😉

      Elegant weapons, for a more… civilized age.

      >Don’t we need to set up the NWDI to JAVA EE 5.0 or 6.0 developing PI 7.1 modules?

      Of course – to be more precise you need a track set up that has support for the 7.1 sap software components and can compile Java 5. I’ve already asked about JEE5 EJB’s in the forums – seems they’re not supported for Modules.

      Regards,
      Robert

      (0) 
  2. Alessandro Guarneri
    Hi Robert,
    I found your blog interesting.
    At the very beginning of it, you mention that it may work for Adapters as well, but you don’t provide any further detail.
    Except for finding the right DCs dependency which I can try to handle myself, do you have an idea about what type of DC I should use to host and deploy the Adapters resources (source etc.)?
    Thanks
    Alex
    (0) 
    1. Robert Schimansky Post author
      Hi Alex,
      I think it’s possible to make NWDI execute custom buildscripts, so you might check for that and have a plain java-project. If you’ve looked around in eclipse you might have also seen the J2EE-Connector Projects it can handle. Maybe it’s easier to wait 7 more years until NWDI and PI support those Project types natively.
      I’d be glad to hear about your progress on the topic.
      (0) 
      1. Alessandro Guarneri
        Hi Robert,
        Thanks for your response. I wasn’t checking your blog again just because I checked the “Notify me of new comments about this weblog?” option, but it didn’t work (does it work usually? 🙂 )

        No progress so far.
        The best approach I could think of was to create the local Connector project, and then use the “Convert to DC” feature 🙂
        The result was a Java DC (total loss) which, despite my efforts to make it as much similar as possible to an adapter .sda, didn’t build in the CBS.

        Now I am trying to open a customer message to get SAP official position on this, as my customer is totally committed to have any Java development managed via the NWDI.

        Cheers,
        Alex

        (0) 
        1. Robert Schimansky Post author
          Hi Alex,

          notification seems to work for me. I think CBS will support only few DC Types out of the box. Now we know the connector project is not one of them. Good luck on your call, SAP PI Adapters could use some NWDI support. If one does not care about the Metadata-integration custom CBS-Buildscripts might be a way to get it working. I’ll look into that when i find some hours.

          Can you name some of the arguments that convinced your customer to commit to NWDI that way?

          (0) 

Leave a Reply