net.sf.sapjcosupport
Class SapJcoInterface

java.lang.Object
  extended bynet.sf.sapjcosupport.SapJcoInterface
Direct Known Subclasses:
SapSearchHelp

public abstract class SapJcoInterface
extends Object

Abstract superclass for all SAP data access objects.

Since:
Jan 18, 2006 - 3:07:41 PM
Author:
Niki Driessen

Field Summary
protected  SapDataSource dataSource
           
protected  int maxParallelCalls
           
 
Constructor Summary
SapJcoInterface()
           
 
Method Summary
protected  void checkReturnStructure(com.sap.mw.jco.JCO.Function function)
           
protected  void convertMap(com.sap.mw.jco.JCO.Table table, Object entity, SapStructureMapping sapStructureMapping, Class persistentObject)
           
protected  com.sap.mw.jco.JCO.Function getFunction(String name)
          This method will resolve the FunctionTemplate for the given name.
protected  void mapOneField(Class entityDef, Object entity, com.sap.mw.jco.JCO.Record record, SapFieldMapping sapFieldMapping)
           
protected  void mapRecordToEntity(Class entityDef, Object entity, com.sap.mw.jco.JCO.Record record, SapStructureMapping structureMapping)
           
 Object performSapCall(SapMapping sapMapping, Map input, Class persistentObject, String profile)
          Actually calls a BAPI.
protected  List retrieve(Class persistentObject, List inputMaps)
           
protected  List retrieve(Class persistentObject, List inputMaps, String profile)
           
protected  Object retrieve(Class persistentObject, Map input)
           
protected  Object retrieve(Class persistentObject, Map input, String profile)
          Retrieves value objects of type persistentObject.
 void setDataSource(SapDataSource source)
          Sets the SAP data source this data access object is working on.
 void setMaxParallelCalls(int calls)
          Sets the maximum number of parallel calls to SAP.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSource

protected SapDataSource dataSource

maxParallelCalls

protected int maxParallelCalls
Constructor Detail

SapJcoInterface

public SapJcoInterface()
Method Detail

setMaxParallelCalls

public void setMaxParallelCalls(int calls)
Sets the maximum number of parallel calls to SAP.

Parameters:
calls - maximum number of parallel SAP calls

setDataSource

public void setDataSource(SapDataSource source)
Sets the SAP data source this data access object is working on.

Parameters:
source - SAP data source

getFunction

protected com.sap.mw.jco.JCO.Function getFunction(String name)
This method will resolve the FunctionTemplate for the given name. It will search the local cache and if not found, retrieve it from SAP via the repository. It then caches that and returns it.

This method NEVER returns null! An exception is thrown when the function can not be resolved.

Parameters:
name - the name of the function to find
Returns:
the function template
Throws:
SapJcoMappingException - when the requested function can not be found in the configured repositories

performSapCall

public Object performSapCall(SapMapping sapMapping,
                             Map input,
                             Class persistentObject,
                             String profile)
Actually calls a BAPI.


retrieve

protected List retrieve(Class persistentObject,
                        List inputMaps)

retrieve

protected List retrieve(Class persistentObject,
                        List inputMaps,
                        String profile)

retrieve

protected Object retrieve(Class persistentObject,
                          Map input)

retrieve

protected Object retrieve(Class persistentObject,
                          Map input,
                          String profile)
Retrieves value objects of type persistentObject.

The input parameter specifies the input paramters that should be passed to SAP. If the result of this call will be one value object, the entries in the Map will be mapped to SAP call import parameters. If the result of this call is a List of value Objects, and a SAP input table is used rather than import parameters, the Map contains a Collection as well. The key of this Collection is the same as the SAP input table.

This Collection can contain two types of values.

  1. The elements of the collection contain a value that should be assigned to the primary key field of the table, which is defined in the input list mapping. Each value of in the collection will be assigned to the primary key of a new JCO.Table row
  2. The elements of the collection contain a Map. The keys of this Map should correspond exactly to the SAP fields and the values will be assigned to these fields. Every Map in the collection correspond to one JCO.Table row.

Here is an example of the second situation: a Collection of Maps. Each map can contain a different number of field/value pairs to process.

 Collection
    0 - Map
       * DOCUMENT_NUMBER -> value
    1 - Map
       * DOCUMENT_NUMBER -> value
       * DOCUMENT_TYPE -> value
    2 - Map
       * MATERIAL -> value
       * DOCUMENT_NUMBER -> value
       * DOCUMENT_TYPE -> value
    etc.
 

Parameters:
persistentObject - type of the value object
input - input map
profile - name to retrieve fields for
Returns:
- one single value object of type persistentObject
- or a List of value objects of type persistentObject if the SAP call supports input/output tables

checkReturnStructure

protected void checkReturnStructure(com.sap.mw.jco.JCO.Function function)
                             throws org.springframework.dao.DataRetrievalFailureException
Throws:
org.springframework.dao.DataRetrievalFailureException

mapRecordToEntity

protected void mapRecordToEntity(Class entityDef,
                                 Object entity,
                                 com.sap.mw.jco.JCO.Record record,
                                 SapStructureMapping structureMapping)

mapOneField

protected void mapOneField(Class entityDef,
                           Object entity,
                           com.sap.mw.jco.JCO.Record record,
                           SapFieldMapping sapFieldMapping)

convertMap

protected void convertMap(com.sap.mw.jco.JCO.Table table,
                          Object entity,
                          SapStructureMapping sapStructureMapping,
                          Class persistentObject)


Copyright © 2006 null. All Rights Reserved.