Why do we need to follow Best Practice in SAP ABAP Enterprise Services?
We need to follow Best Practice mainly because, we want to implement the required business functionality accurately, efficiently and future maintenance. SAP, itself provides solution for SAP ABAP Enterprise services, while we are creating SAP ABAP web services.
Enterprise Services are integration of web-services based on open standards WSDL, XML, UDDI and SOAP etc., which usually put into action by using core technology or some vendor product. They are used to implement new innovative Business Services, where they have encapsulated business logic, which act against data entities that have capacity to have sphere of influence across application.
It is totally depending upon our business requirement, how we implement our Enterprise service, which means, whether we need to enhance existing standard Enterprise services or to create Custom Enterprise Services.
There are two ways of creating Web Service.
- Inside out
- Outside in
Inside out approach:
Usually, when we create a service following this approach, what we do is, we make an application with certain functionality for our business requirement and consume it as a web service. This application can be a BAPI, a RFC (Remote Function Call) or a function module callable outside the application.
Following figure explains straight forwardness of this approach.
Many SAP business data can be accessed through RFC-enabled function modules. BAPIs are implemented as RFC-enabled function modules and provide standardized programming interface. All RFC-enabled function modules (so all the BAPIs) are exposed as web services by default (i.e. no work needed to make them web services). This feature is available since WebAS 6.20.
Outside In Approach
Proper modeling is the one crucial for Outside-in development, and which also necessary for the implementation for the web service. While, we are developing an Outside-in approach, we starts at a business level, looking at decisive business processes and modeling them into services that employ those processes.
From a developer’s perspective, to create a service from the outside in, we need to go through several process steps. As we start developing services from the outside in, we use more of the principles of ESR, such as abstraction from programming languages, hiding the implementation details, and reusing data types where possible.
- CE 7.1 system with ESR for CE 7.1 installed.
- SAP NW 7.0 SP14 System.
Following are the steps to create Web Service with these approaches:
Inside Out approach
- Select function module (RFC enabled) name from browser in left side like following fig. 1. Follow the steps : right click on function module name then select create tab then web service to open the wizard window to create web service
- Next step is to select “Service Provider” as object type, then click on continue tab.
- Now Select “Existing ABAP Objects (Inside Out)” option in this screen then continue.
- In the following screen specify web service name started with Z, then give description and select “Function Module” as end point then continue.
- Now in next screen of wizard enter end point function module name. Also make it sure that “Name Mapping” check box must be checked.
- Next step is, select default profile or “PRF_DT_IF_SEC_LOW” and also check “Deploy service” check box to continue.
- In the following screen enter package name and transport request then continue.
- In next screen click on complete to complete the process.
To publish web service use WSPUBLICE t-code, it will open following screen and put following information
Service Names : <web-service name>
Search Scope : default option (All Services)
Publish Information’s : default option (Service Definition & end points)
Republication : Check “Force Publication”
Service Registry : SR_UDDI
Then press F8 to complete the process of publication. On successful publication this web service can be accessed from any SAP and non-SAP application which is accessing that Service Repository where we published that web-service.
In the Object Navigator, enterprise services are found in a folder under the Function Modules folder. Opening the Enterprise Services folder displays the Service Definitions folder. In this folder, we can see the object we created.
Outside In Approach
In following approach we will create a service model from CE 7.1 ESR and generate proxy in backend system while implementing the service definition.
Following are steps for ESR (Enterprise Service Repository) service modeling:
- Connectivity establishment between Backend system and ESR
It is mandatory that, we need to connect successfully to the Enterprise Service Repository, to implement service definition in backend. For that, we need to configure a value for the CE 7.1 ESR URL and the username/pwd parameters in the exchange profile or create an RFC destination ‘SAP_PROXY_EXR’ with CE 7.1 repository URL in backend.
When we click on ‘Green Arrow Link’ icon on our Enterprise Service Browser or SPROXY transaction, it helps us to have complete check list for setting up a connection to ESR as shown on following fig.
- Modeling of Service in Enterprise Service Builder
We need to login to our ESR http://<j2ee_server>:<Port>/rep
We need to click on ‘Enterprise Service Builder’ to proceed further
- We need to login using ESRAdmin
- Now select ‘Service Definition’ as application profile.
- Next step is to create NAMESPACE under our Software Component and create a folder under modeling. In our case we named it ‘ESRDemo’.
- Now we are in course to create a process component model for business partner search. First, we will create a process component named ‘PartnerSearch’ with service interface ‘BUPASearch’, followed by creation of a business object ‘Partner’ with the operation ‘BUPASearch’, as shown in following fig.
- Now, we just save and activate. Then we will be creating the XI Interface objects (Data Types, Message Type) for the Service Interface in our defined namespace.
Data Types: BUPA_ReqDT
- Data Types: BUPA_ResDT
- Message Types: BUPA_ReqMT refers Data Types: BUPA_ReqDT
Message Types: BUPA_ResMT refers Data Types: BUPA_ResDT
Now, we will create service interface from process component model. First, select service interface block from the model , then right click and select option ‘Create Assignment’ from the context menu to create service interface. Now System will prompt the service interface name and we have to select namespace and service interface attributes as shown in the following fig.
Now, create the assignment for the operation in accordance with the service Interface. Now save all your XI design objects and activate it.
- In following process, we are going to create inbound proxy in backend for service interface. For that, we will login to backend system, where we configured ESR connection. Now either we can use ‘SPROXY’ or select ‘Enterprise Service Browser’ from SE80.
In ES Browser, We have to check all generated XI design objects. Next, we have to expand Service Interface node. To create proxy, we will right clock on Service interface, in our case it is ‘BUPASearch’.
Generated proxy for our service interface will be as shown in following fig.
- We will put our code for the inbound proxy in the method for the class, which we will open by double clicking.
- Create the service endpoint and configuration in ‘SOAMANAGER’ .
In this step, we will be creating the service endpoint and configuration. Launch the transaction ‘SOAMANAGER’ from the backend and search for the service “ZBUPA*” as shown below:
- Create the service endpoint as shown below
- Select the Operation “BUPASearch” and provide the input parameters for the business partner search as shown below:
Conclusion: As we are using ESR (Outside in Approach) for modeling, which is slightly different from our previous outside in technique, where we use message interface in the SAP NetWeaver XI Integration Repository for modeling. Our current approach of using ESR is more modeling specific and user frendly.
Please send us your questions, comments or assistance, and our team would be glad to assist you.
By Sreedhar Babu. (on behalf of SAP Consulting Team)
SAP :: Streamlined
We offer variety of services including SAP ECC ,SAP HR,SAP BW,SAP CRM, SAP SCM,SAP BPM, Business Objects, SAP ABAP Development, SAP BASIS and SAP NetWeaver consulting. We have expertise in providing implementation,development, SAP Migration and SAP support services to SAP customers across diverse industries at a global level.
Have a question on SAP? Write to our SAP Architect : AskTheArchitect@Apprisia.com
(We promise a no-obligation consulting reply)