Customization Guide

Customize Services

The following describes how to customize the adapter’s services, for instance

  • change the function module called by a service

  • add additional fields based on an RFC’s parameters to the response of a REST service

  • change the parameters passed to an RFC

Service Architecture

The following is a simplified class diagram showing the interfaces and classes involved in a service that reads data from FS-CD, in this case the account balance service.

account balance service
Components
  • Service Interface: Defines the contract for the service. For instance, reading account balances for a partner number and policy number.

  • Service Implementation: Handles the actual retrieval or processing of data using JCo. For instance, retrieval of account balance data from FS-CD.

  • Mapper Interface: Defines the generic mapping function that maps data from a JCoTable to a result type.

  • Mapper Implementation: Maps data from a JCoTable to a specific result type, for instance AccountBalancesResult.

For services that write data to FS-CD, e.g. the posting service, the diagram looks somewhat similar:

posting service

The key difference is that it uses a different mapper interface JcoFunctionMapper and the corresponding implementation PostingMapper. It maps the input data, in this case a list of postings, to parameters of a Jco function. This is the reason JCoFunction is a parameter of the mapper’s map(JCoFunction, O, Map) method.

Change the Function Module Called by a Service

It’s common practice in SAP systems to copy an FM, add additional parameters to its signature or slightly change its logic, while staying compatible with the original. In order to make it easier to use such copies, the name of the FM called by a service can be configured via a property in the spring configuration. For the JcoAccountBalanceService the property is fscd-adapter.account-balance-function-name. For the property of other services see the respective Java class or consult the spring configuration metadata (additional-spring-configuration-metadata.json).

Customize RFC Parameters

Another common scenario is that additional (i.e. customer specific) parameters need to be passed to or from an RFC. Oftentimes, these parameters are additional data to be processed or stored in the form of custom fields in a SAP system. Accordingly, these parameters need to be processed by FS-CD Adapter mappers as well as be represented in the adapter’s domain model.

To customize the mapping-logic between RFC parameters and domain objects, the mapper implementations can be replaced using Spring’s Inversion of Control (IoC) mechanism.

@Primary
@Service
public class MyAccountBalanceResultMapper implements JcoTableMapper<AccountBalancesResult> {

    @Override
    public AccountBalancesResult map(JCoTable table){
        // do something else
    }
}

Domain objects are extensible via their Map<String, Object> extensions attribute. This map attribute allows storing arbitrary data which makes transferring data from and to RFCs convenient when implementing custom mappers.

The adapter’s REST services can also make use of the extensions map. They can receive additional data and pass it on to RFCs. Accordingly, additional data returned by RFCs can be written into the extensions attribute by a custom mapper and subsequently returned in a REST service’s response.

In case the above approaches do not suffice, the whole service implementation can be replaced as follows.

@Primary
@Service
public class MyAccountBalanceService implements FscdAccountBalanceService {

    @Override
    public AccountBalancesResult readAccountBalance(String partnerNo, String policyNo) {
        // do something else
    }
}