Start of Content Area

Procedure documentation Implementing Lookups Using SystemAccessor  Locate the document in its SAP Library structure

Procedure

Generic Lookup API

In the case of generic access, before executing the lookup, developers must themselves build the payload that the adapter expects and parse the result payload.

To access an application system generically, developers use the SystemAccessor class. For generic calls, developers of a method must pass a stream with the payload, which is then sent to the adapter. The result of the call is a payload object, which you can use to both read the payload as a stream and parse the payload.

The generic lookup API is part of the mapping API (see LookupService class in the Javadoc documentation). For more information about these APIs, see SAP Developer Network at https://www.sdn.sap.com/irj/sdn/javadocs (SDN user required).

Note

You can obtain the schema to call an RFC by simply importing the RFC into the Enterprise Services Repository. (See Importing IDocs and RFCs.)

Example

import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import com.sap.aii.mapping.lookup.*;

public class Parametraziation_Java extends AbstractTransformation {

   public void transform(TransformationInput in, TransformationOutput out)
         throws StreamTransformationException {

      SystemAccessor accessor = null;
      java.io.InputStream inputStream = null;

      try {

         // 1. Read Import Parameter to get the channel ID for Lookup
         Channel channel = in.getInputParameters().getChannel("MYCHANNEL");

         // 2. Get a system accessor for a channel.
         accessor = LookupService.getSystemAccessor(channel);

         // 3. Create a payload according to the data type.
         // To get a payload object, pass the payload
         // as java.io.InputStream to one of the following methods:
         // LookupService.getBinaryPayload() for binary payload,
         // or LookupService.getTextPayload() for text payloads.

         Payload payload = LookupService.getXmlPayload(inputStream);

         // 4. Set the operation name and namespace; optional step,
         // only necessary if the used adapter needs these parameters.

         accessor.setOperationName("myInterfaceName");
         accessor.setOperationNamespace("myInterfaceNS");

         // 5. Execute lookup.
         Payload result = accessor.call(payload);

         // Steps 3. and 5. can be executed several times.

      } catch (Exception e) {
         // Exception Handling
      } finally {
         // 5. close the accessor in order to free resources.

         if (accessor != null)
            accessor.close();
      }
   }
}

 

 

 

 

 

End of Content Area