Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
ajay_wandre
Explorer


     1. For working on module configuration we should first download NETWEAVER DEVELOPER STUDIO (NWDS). The version of NWDS should be lower to the version of SAP server to which the module would be deployed.

2. After installing NWDS, we should copy the following jar files in the java class-path during development of the module. The following jar files can be found in the SAP installation directory as under (save these files in the local directory)-

com.sap.aii.af.cpa.svc.api.jar:                        <bin>/services/com.sap.aii.af.cpa.svc/lib

com.sap.aii.af.lib.mod.jar:                              <bin>/ext/com.sap.aii.af.lib\lib

com.sap.aii.af.ms.ifc_api.jar:                          <bin>/interfaces/com.sap.aii.af.ms.ifc/lib

com.sap.aii.af.svc_api.jar:                              <bin>/services/com.sap.aii.af.svc/lib

sap.com~tc~logging~java~impl.jar:                <bin>/system

 

We should also provide the javax.ejb.jar file in the java class-path which is used during development.

3. In Window->Preferences goto following path and create a new library and click ‘Add JARs’ for importing the jar files-







Select the jar files from the local directory-



The jar files would be found imported in the library-



4. Goto File->New->EJB project and give the following details-



Click Next-



Click Next-



Uncheck ‘Create EJB client….’ and click Finish-

The following projects should get created in the Project Explorer-



5. Right click on ‘GetQueue’ and select New->Enterprise Java Beans



Provide following details as under-



Click Next.

Use the following parameters to be assigned in the next screen:




  • Remote interface: com.sap.aii.af.lib.mp.module.ModuleRemote

  • Home interface: com.sap.aii.af.lib.mp.module.ModuleHome

  • Local interface: com.sap.aii.af.lib.mp.module.ModuleLocal

  • LocalHome interface: com.sap.aii.af.lib.mp.module.ModuleLocalHome

  • Uncheck ‘Service endpoint’

  • Click Finish 




6. On the left panel select ‘ejb-jar.xml’ as below-



The following details should be displayed-



7. In ejb-j2ee-engine.xml, provide the JNDI name which is used as Adapter module in SAP-PI interfaces-



8. Right-click GetQueue->Build Path->Configure Build Path



Click ‘Add Library’ button and select the user-library that we had created in step-3.







9. Double click TraceQueueBean.java on the left panel and write the code on the right hand side-



The code is used to create dynamic queue name based on parameters taken from the payload else a default queue name is set-

/**


*


*/


package com.sap.adaptermodule;


import java.rmi.RemoteException;


import javax.ejb.EJBException;


import javax.ejb.SessionBean;


import javax.ejb.SessionContext;


import javax.ejb.TimedObject;


import javax.ejb.Timer;


//XML parsing and transformation classes


import org.w3c.dom.Document;


import org.w3c.dom.Node;


import org.w3c.dom.NodeList;


import org.w3c.dom.Element;


import java.io.InputStream;


import javax.xml.parsers.DocumentBuilder;


import javax.xml.parsers.DocumentBuilderFactory;


//Classes for Module development & Trace


import com.sap.aii.af.lib.mp.module.*;


import com.sap.engine.interfaces.messaging.api.*;


/**


* @author awandre


*


*/


public class TraceQueueBean implements SessionBean, TimedObject {


      private static final long serialVersionUID=100L;


      /* (non-Javadoc)


       * @see javax.ejb.SessionBean#ejbActivate()


       */


      @Override


      public void ejbActivate() throws EJBException, RemoteException {


            // TODO Auto-generated method stub


      }


      /* (non-Javadoc)


       * @see javax.ejb.SessionBean#ejbPassivate()


       */


      @Override


      public void ejbPassivate() throws EJBException, RemoteException {


            // TODO Auto-generated method stub


      }


      /* (non-Javadoc)


       * @see javax.ejb.SessionBean#ejbRemove()


       */


      @Override


      public void ejbRemove() throws EJBException, RemoteException {


            // TODO Auto-generated method stub


      }


      /* (non-Javadoc)


       * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)


       */


      @Override


      public void setSessionContext(SessionContext arg0) throws EJBException,


                  RemoteException {


            // TODO Auto-generated method stub


      }


      /* (non-Javadoc)


       * @see javax.ejb.TimedObject#ejbTimeout(javax.ejb.Timer)


       */


      @Override


      public void ejbTimeout(Timer arg0) {


            // TODO Auto-generated method stub


      }


      public void ejbCreate() throws javax.ejb.CreateException {


      }


      public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)


    throws ModuleException{


try {


String param1 = (String) moduleContext.getContextData("param1");


String param2 = (String) moduleContext.getContextData("param2");


Message msg = (Message) inputModuleData.getPrincipalData();


Payload payload = msg.getDocument();


InputStream inps = (InputStream) payload.getInputStream();


DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();


DocumentBuilder db = dbf.newDocumentBuilder();


Document doc = db.parse(inps);




  1. doc.getDocumentElement().normalize();


NodeList nodeLst1 = doc.getElementsByTagName(param1);


NodeList nodeLst2 = doc.getElementsByTagName(param2);


Element Elmnt1 = (Element) nodeLst1.item(0);


Element Elmnt2 = (Element) nodeLst2.item(0);


NodeList ndLst1 = Elmnt1.getChildNodes();


NodeList ndLst2 = Elmnt2.getChildNodes();


String queueId;


if (ndLst1.item(0) != null)


      queueId =((Node) ndLst1.item(0)).getNodeValue();


else if (ndLst2.item(0) != null)


      queueId =((Node) ndLst2.item(0)).getNodeValue();


else


      queueId = msg.getSequenceId();




  1. msg.setSequenceId(queueId);

  2. inputModuleData.setPrincipalData(msg);


return inputModuleData;


} catch (Exception e) {




  1. e.printStackTrace();


ModuleException me = new ModuleException("Unable to create Queue", e);


throw me;


}


}


}


     10. Save the code and select Project->Build Project


A class file gets generated in the Workspace of NWDS at the following path-


 



     11. In ‘GetQueueEAR->EarContent->META-INF->application-j2ee-engine.xml’ provide the source code as below-

<?xml version="1.0" encoding="UTF-8" standalone="no"?>


<application-j2ee-engine


      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"


      xsi:noNamespaceSchemaLocation="application-j2ee-engine.xsd">


      <reference


            reference-type="hard">


            <reference-target


                  provider-name="sap.com"


                  target-type="library">com.sap.aii.af.lib</reference-target>


      </reference>


      <reference


            reference-type="hard">


            <reference-target


                  provider-name="sap.com"


                  target-type="service">com.sap.aii.adapter.xi.svc</reference-target>


      </reference>


      <reference


            reference-type="hard">


            <reference-target


                  provider-name="sap.com"


                  target-type="service">com.sap.aii.af.svc</reference-target>


      </reference>


      <reference


            reference-type="hard">


            <reference-target


                  provider-name="sap.com"


                  target-type="service">com.sap.aii.af.cpa.svc</reference-target>


      </reference>


      <fail-over-enable


            mode="disable"


            xsi:type="fail-over-enableType_disable"/>


</application-j2ee-engine>



We would find the values under References as below-



In the above screen, select ‘Failover Mode’ and give the value as ‘disable’.

12. Save the project and select ‘Project->Build Project’. Now this developed module is ready for deployment to the SAP server.

13. Goto ‘Window->Preferences->SAP as Java’ and click ‘Add’ button to provide the details of the SAP server-



The server details gets displayed as below-



Note: For deploying the module to the SAP server, the SAP user-id must have J2EE admin rights.

14. To deploy the module right click ‘GetQueueEAR->Run As->Run on Server



Select the SAP sever, where the deployment is to be made-



Click Next.



Click Finish.

Provide the SAP logon user-id & password which has J2EE admin rights-





15. In Net weaver Administrator; Troubleshooting->JNDI Browser, we can find the module ‘TraceQueue’ after successful deployment-

This module is ready to be used in the interfaces.



16. Prepare a sample scenario in PI and provide the details in Module tab as below in sender communication channel with EOIO as QoS.



17. The message will be generated in SXMB_MONI with dynamic queue name driven from field ‘Emp_Id’ in payload. If ‘Emp_Id’ is with no value, then ‘First_Name’ would be used for dynamic queue name else a default queue name will be set-



Payload:



4 Comments
Labels in this area