Prepare flight data example

Let the world know ...Tweet about this on TwitterShare on Google+Share on FacebookEmail this to someoneShare on LinkedIn

Each SAP NetWeaver ABAP system comes with a built-in sample application that allows developers to learn how to use SAP technology. More information about flight sample can be found at SAP Help. Let see how to set up the flight sample and to test it. By default, the ABAP code is installed, but no data is provided. Therefore, the ABAP applications are of no use. First step is to set up the flight data!

Generate flight sample data

  • Transaction: SE38
  • Program: SAPBC_DATA_GENERATOR

Execute the program: . Next screen: select data to be generated.

Execute: . A dialog will pop up, warning that old data will be deleted. Confirm with yes.

Check status at bottom of screen:

Test if data was created

Table data

  • Transaction: SE16
  • Table name: SFLIGHT

Insert no criteria to get a list of all table entries.

Execute. The table entries are returned. If nothing is returned, something went wrong during the data generation step.

Function Module

  • Transaction: SE37
  • Function Module: BAPI_FLIGHT_GETLIST

  • Import parameter: Airline: LH

Execute. The result screen is shown.

The table FLIGHT_LIST needs to contain some values. Select the table to see the returned values.

In case the flight sample data was successfully generated and the user has the permission to execute the BAPI, both the table and the BAPI return valid data.

Trouble shooting

In case the BAPI is not returning any data, but an authorization error, check if the user has the permission to run the BAPI.

Symptom

Table FLIGHT_LIST is empty and RETURN table contains two entries.

Value of table RETURN:

  • No authorization

Root cause

Check missing authorization with transaction SU53.

  • Missing authorization S_FLBOOK

Solution

Assign authorization S_FLBOOK to user.

  1. Create a role with the authorization

  2. Click on Single Role
  3. Create role GUI is shown

  4. Click on tab Authorizations

  5. Click on Change Authorization Data

  6. Add the missing role manually

  7. Insert S_FLBOOK

  8. The role is added, but marked yellow.

  9. Click on the yellow icon. A dialog opens

  10. Confirm.
  11. Now everything is green

  12. Generate the role:
  13. A new dialog opens.

  14. Nothing needs to be done here, just confirm the information.
  15. Status in SAPGui:
  16. Exit the transaction.

  17. Generate

Back in PFCG, select tab user

Assign user to the newly created profile.

Click on User Comparison. A popup is shown, confirm by saving role.

Select complete comparison

Close dialog.

Done. The user has now access to call the BAPI.

Let the world know ...Tweet about this on TwitterShare on Google+Share on FacebookEmail this to someoneShare on LinkedIn

Activate RMTSAMPLEFLIGHT service

Let the world know ...Tweet about this on TwitterShare on Google+Share on FacebookEmail this to someoneShare on LinkedIn

After installing a SAP NetWeaver Gateway system, you’ll want to play around with a OData service. One option is to create everything from scratch; another option is to use a sample service that serves as a basis for learning. SAP NetWeaver ABAP comes with the flight sample, and to no surprise, SAP Gateway comes with a sample OData service based on the flight sample. To maintain a service, transaction /IWFND/MAINT_SERVICE is used. It shows a list of available services:

Adding the service

After a fresh SAP Gateway installation, the flight sample service won’t be listed. The service is already installed, but is not visible in the service catalog. To add it, select the Add Service option: This brings up the Add Selected Services screen.

The get a list of services, first inform the system alias. In my case, I created before in SPRO an alias named GWD for my Gateway system.

Then, click on Get Services: . The brings up the list of services available in the system

The OData service for the flight data is RMTSAMPLEFLIGHT or RMTSAMPLEFLIGHT_2. Select the services you want to add and click on Add Selected Services.

Confirm the following dialog

This will load the service. After everything was done successfully, you’ll hopefully see the following information:

Back at the Activate and Maintain Services transaction shows that the RMTSAMPLEFLIGHT service is added.

Test the service

Click on the service name. This will change the lower section of the screen.

To test the service, click on Gateway Client: . This will open the SAP NetWeaver Gateway Client.

Note that in the Request URI field the service URI is already inserted: /sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/?$format=xml

To see of the service works, just execute a GET request. This should bring back the service description.

Service document

Metadata document

Collection

To retrieve data from a specific collection, click on Entity Sets: . Select an Entity Set (Collection)

This will set the URI parameter accordingly.

Specific flight

The information returned by the entity set can be used to retrieve the information of a specific flight. Part of the returned XML is an entity, that contains an URL like this:

/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/FlightCollection(carrid=’AA’,connid=’0017′,fldate=datetime’2014-10-29T00%3A00%3A00′)

Copy & paste this URL in the URI field.

Let the world know ...Tweet about this on TwitterShare on Google+Share on FacebookEmail this to someoneShare on LinkedIn