Topic
  • 5 replies
  • Latest Post - ‏2013-03-20T12:43:32Z by SystemAdmin
SystemAdmin
SystemAdmin
4179 Posts

Pinned topic JavaNode example for SAP Adapter

‏2013-03-19T15:00:46Z |
Hello,

I try to create a very simple java node, which parses the inbound RFC and creates an RFC-Response. I need some example for java code for parsing of inbound message and creating the outbound mesage.

Especially interesting is which parser shall be used.

Kind Regards
Eduard Neuiwrt
Updated on 2013-03-20T12:43:32Z at 2013-03-20T12:43:32Z by SystemAdmin
  • kimbert@uk.ibm.com
    kimbert@uk.ibm.com
    515 Posts

    Re: JavaNode example for SAP Adapter

    ‏2013-03-19T22:44:19Z  
    In message broker you hardly ever need to write code to do parsing. The product ships with a wide range of parsers that can do that for you. Your Java code should just read the InputRoot message tree ( it is created for you by the parser ) and create OutputRoot.
  • SystemAdmin
    SystemAdmin
    4179 Posts

    Re: JavaNode example for SAP Adapter

    ‏2013-03-20T08:03:39Z  
    In message broker you hardly ever need to write code to do parsing. The product ships with a wide range of parsers that can do that for you. Your Java code should just read the InputRoot message tree ( it is created for you by the parser ) and create OutputRoot.
    Hi,
    exactly, i want to do, what you have described. Is there some example code for this?

    Regards
    Eduard Neuwirt
  • kimbert@uk.ibm.com
    kimbert@uk.ibm.com
    515 Posts

    Re: JavaNode example for SAP Adapter

    ‏2013-03-20T10:31:32Z  
    The question is not specific enough.

    I suggest that you start by trying out some of the product samples, and doing some reading in the info center.
  • SystemAdmin
    SystemAdmin
    4179 Posts

    Re: JavaNode example for SAP Adapter

    ‏2013-03-20T11:58:46Z  
    The question is not specific enough.

    I suggest that you start by trying out some of the product samples, and doing some reading in the info center.
    Hi,

    thanks for your help.I try to be more specific.

    I want to implement an RFC-Function in message broker. In this case acts WMB as a RFC_Server. The function has to be called: 'STFC_CONNECTION'.

    Already done
    1. SAP-System preparations done: This function is already defined in SAP-System. I have already created an RFC-Destination in sm59 which points to message broker.
    2. Created via Adapter Connection wizard all necessary artifacts in my appliction. the choosed RFC is 'STC_CONNECTION'.
    3. Created following message flow: SAP_Input_Node -> Java Compute -> SAP_Reply

    The Java-Compute-Node has the default implementation (path through). I have deployed my mesage flow and sm59 connection test works fine. it means the technical connection between SAp_System and my message flow works properly.

    Now in Java-Compute-Node I want to do following:
    1. read the importing parameters from message. In this case it is requtext.
    2. provide an output message for SAP-reply node.

    Do you have any example how to proceed an incoming RFC within Java-Compute-Node?

    Kind Regards
    Eduard Neuwirt
  • SystemAdmin
    SystemAdmin
    4179 Posts

    Re: JavaNode example for SAP Adapter

    ‏2013-03-20T12:43:32Z  
    The question is not specific enough.

    I suggest that you start by trying out some of the product samples, and doing some reading in the info center.
    It is me again. Finally I got it running. The JavaCompute Node has the following code (rather ugly):

    public void evaluate(MbMessageAssembly inAssembly) throws MbException {
    MbOutputTerminal out = getOutputTerminal("out");
    MbOutputTerminal alt = getOutputTerminal("alternate");

    // Read importing parameters
    MbMessage inMessage = inAssembly.getMessage();
    MbElement inRoot = inMessage.getRootElement();
    MbElement mbElementRequText = inRoot.getFirstElementByPath
    ("/DataObject/SapStfcConnectionWrapper/SapStfcConnection/Requtext");
    String requeText = mbElementRequText.getValueAsString();
    // Create response
    MbMessage outMessage = new MbMessage();
    MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
    MbElement outRoot = outMessage.getRootElement();
    MbElement outBody = outRoot.createElementAsLastChild("DataObject");
    MbElement stfcWrapper = outBody.createElementAsLastChild(MbElement.TYPE_NAME, "SapStfcConnectionWrapper", null);
    MbElement stfcConnection = stfcWrapper.createElementAsLastChild(MbElement.TYPE_NAME, "SapStfcConnection", null);
    MbElement echoText = stfcConnection.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Echotext", requeText);
    MbElement respText = stfcConnection.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Resptext", "Hohoho");

    out.propagate(outAssembly);
    }

    My questions are:
    1. Is my code correct? Do I have other possibilities to create RFC-Responses?
    2. For BLOB-parser the is constant MbBLOB.PARSER_NAME Does a constants exist for parser name "DataObject"?
    3. Do I really need to code the RFC via XML, or is it possible to generate Java-proxies for SAP-Interface?

    Kind Regards
    Eduard