Wednesday, May 29, 2013

SAP Netweaver Gateway – Useful transactions

In some earlier articles on this blog (like this one), we discussed SAP Netweaver Gateway, SAP's platform for exposing business information and functionality to the outside world.

In this blog about SAP Netweaver Gateway we will discuss the most important transactions that you might use when you are working with SAP Netweaver Gateway. These transactions vary from customizing, development and testing / monitoring transactions.

Customizing: Transaction SPRO

To do configuration and administration of your SAP Netweaver Gateway system, you have (the good old) customizing transaction SPRO. Here you can find all sorts of options that you can use to do basis things like:
  • Enabling/disabling the SAP Netweaver Gateway
  • Defining roles for SAP Netweaver Gateway users and administrators
  • Connecting the system to SLD
  • Connection the system to another SAP system
  • Turning on/off the SAP Netweaver Gateway cache
  • Turning on/off virus scanning (for binary data)
  • Set SAP Netweaver Gateway log levels
Check out the path SAP Netweaver > Gateway (and subordinate paths) for all the settings.

Transaction SPRO

Development: Transaction SEGW (Gateway Service Builder)

Since SAP Netweaver Gateway 2.0 SP4, the heart of all service development is the SAP Netweaver Gateway service builder. Using this transaction you can define your model either from scratch or via other routes like generating it based on an RFC of data dictionary structure. Another option you have is to create your model by redefining an existing Gateway service.
What you do in the service builder is creating your OData entities and entity sets, after that you can create associations between entities and collections. For example: you might have an entity 'customer' that has an association with the entity set 'orders'.
Once your model is complete, you can generate runtime artefacts for the model. The following stuff is generated for you:
  • The model
  • A model provider base class (MPC)
  • A model provider extension class (MPC_EXT)
  • A data provider base class (DPC)
  • A data provider extension class (DPC_EXT)
  • The actual SAP Netweaver Gateway Service
The most important one (the one you will probably use the most) is the data provider extension class (DPC_EXT). This is the class that you can edit using the next transaction that I will discuss.

Transaction SEGW: SAP Netweaver Gateway Service Builder

Development: Transaction SE24 (Class Builder)

As mentioned in the previous section, the Gateway Service Builder generates a data provider extension class for you. Out of the box, everything is created for you and ready to go. For each of your modelled entity collections, the generated class already has the following methods set up:
  • GET_ENTITY (Read a single entity)
  • GET_ENTITYSET (Read a collection of entities)
  • CREATE_ENTITY (Create an entity)
  • UPDATE_ENTITY (Update a single entity)
  • DELETE_ENTITY (Delete a single entity)
All you have to do is redefine these methods and add your own logic tot hem to handle the operations.

Transaction SE24: Class Builder

Admin: /IWFND/MAINT_SERVICE (Maintain Services)

Once your model and implementation are done, you can activate & maintain your service using this transaction. This transaction can also be found via transaction SPRO.
The most important thing you do here is adding your service to the list and assigning one or more system aliases to the service. The system alias can either be the local system or any other back-end system in case of a standalone Gateway installation (CRM, ECC etc.). By assigning the system alias, you are instructing your gateway on which server the service should be executed.

Transaction /IWFND/MAINT_SERVICE (Activate and Maintain Services)

Testing: /IWFND/GW_CLIENT (SAP Netweaver Gateway Client)

Once modelling, implementing and activating is done, it is time to test your service. This can be done either by calling it from a client like an iOS device, but the SAP Netweaver Gateway also includes a transaction that can be used to test the services you create.
All you have to do is specify the path to your service, the method you want to test (GET/POST/PUT/DELETE) and request data (request data only applicable for PUT/update and POST/create). Once you hit execute, the Gateway Client will execute your request and provide you with the expected response or an error if something’s wrong.

SAP Netweaver Gateway Client

Testing / Monitoring: /IWFND/ERROR_LOG (Gateway Error Log)

Let’s say you did not get the expected result when testing with the SAP Netweaver Gateway Client, then you would probably want to analyse what went wrong. The error log provides you a list you requests to the server that did not succeed. In the error log you can select the failed request and look at the request body of the call and get some additional information on the error that occurred while processing the request (e.g. RFC failure). The SAP Netweaver Gateway can provide you with some information in the response of your failed request, but this response can be vague and you will definitely need the error log to analyse errors with a bit more detail.

Transaction /IWFND/ERROR_LOG: SAP Netweaver Gateway Error Log

Monitoring: /IWFND/APPS_LOG (Application Log Viewer)

If you’re not only interested errors, but also the successful service calls and activity on your SAP Netweaver Gateway server, you can check out this transaction. I must admit I don’t use it that often because it does not provide a whole lot of information. But you might be interested if someone who should be testing your app (or something like that) is actually testing your app. In the apps log, you can check if the user shows some activity in a period that you can select. The apps log provides you with information about the type of service call (read/create/update/delete), user name and time and date of the call.
Transaction /IWFND/APPS_LOG: SAP Netweaver Gateway Application Logs

Too vague? Want more details?

I can imagine you would want some additional and more detailed info about all this. Luckily there are a lot of resources available online via