Start of Content Area

Procedure documentation Creating a JCO.Function Object  Locate the document in its SAP Library structure

Activities

To create a JCO.Function object, proceed as follows:

 

...

       1.      Create a Function Template (interface IFunctionTemplate()). A function template contains all the metadata (parameters and exceptions) for an RFM. To optimize performance, SAP JCo retrieves the metadata only once and saves it in the cache.

       2.      Use the method getFunctionTemplate() of the class JCO.Repository to create the template. If the value null is returned, the RFM cannot be found in the SAP server.

       3.      You can then use the template to create a JCO.Function object, using the method getFunction().

Syntax documentation

Creating a Function Object

Public JCO.function createFunction (String name) throws Exception {

   try {

      IFunctionTemplate ft =

         mRepository.getFunctionTemplate (name.toUpperCase ())

      if (ft == null)

         return null;

      return ft.getFunction ();

}

catch (Exception.ex) {

      throw new Exception (“Problem retrieving JCO.Function object.“);

  }

}

 

In addition to containing metadata, a function object also contains the current parameters for executing the RFMs. The relationship between a function template and a function in SAP JCo is similar to that between a class and an object in Java. The code displayed above encapsulates the creation of a function object.

 

NoteSAP recommends that you create a new function object for each individual execution. By doing so you can ensure that the parameters do not contain any elements from previous calls.

 

 

 

End of Content Area