• Like
  • Save

SAP NetWeaver Gateway - RFC & BOR Generators

  • 2,122 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,122
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
11
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. SAP NetWeaver GatewayRFC & BOR Generators (Read Only)May 2012 A Branded Service provided by SAP Customer Solution Adoption
  • 2. Objectives At the end of this module, you will be able to:  Create a read-only Gateway Service based on a Remote Function Module or an Object in the Business Object Repository (BOR)  Expose a Gateway Service for consumption  Test your Gateway Service from a browser© 2012 SAP AG. All rights reserved. 2
  • 3. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 3
  • 4. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 4
  • 5. Overview – Remote Function ModulesA Remote Function Module (RFM) is anyABAP Function Module that has had itsRemote-Enabled flag switched on.Activating this flag makes the functionmodule accessible from outside the SAPsystem using the Remote Function Call(RFC) protocol.Important!All SAP Business APIs (BAPIs) areremote enabled function modules, butnot all remote enabled function modulesare BAPIs.A BAPI is a remote enabled functionmodule that has been specifically writtento implement the method of a BusinessObject.© 2012 SAP AG. All rights reserved. 5
  • 6. Overview – Business Object Repository (BOR)The BOR arranges BAPIs intoBusiness ObjectsObjects contain methods, events, keyfields, and attributes Methods are usually mapped to BAPIs Key fields are mandatory fields used to identify an object instance Events are used to notify others of some business eventThe BOR is accessed using transactionSWO2 (Letter “O”, not zero). Here, youcan create your own BOR objectsExisting BOR objects can be extendedusing transaction SWO1© 2012 SAP AG. All rights reserved. 6
  • 7. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 7
  • 8. Gateway Data and Consumption ModelsThe Gateway Modelling Wizard willgenerate a Data ModelA generated Data Model encapsulatesthe functionality to be exposed as aGateway Service.Transaction SE80 allows you to create aGateway Data Model; however, such anobject is not immediately usable as aGateway Service.In order to expose a Gateway DataModel to the outside world, you must firstcreate a Gateway Consumption Modelobject which is then associated with theData Model.© 2012 SAP AG. All rights reserved. 8
  • 9. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 9
  • 10. Gateway Data Models Based on BOR Objects - Overview Gateway Data Models can be created based on RFMs or BOR Objects. Gateway Objects are created using the ABAP Development Workbench (txn SE80) Once the Gateway Object is created, you are taken to the Gateway Object Modeller (txn /IWFND/GWO_GEN) The Gateway Object Modeller is where your service is created. Select a BOR Object or RFM by performing a search. Each RFM or BOR Object method is then mapped to a service operation.© 2012 SAP AG. All rights reserved. 10
  • 11. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 11
  • 12. Step 1) Create A Gateway Data Model – 1/2In SE80, select “GW Data Model” andenter a new object nameAfter confirming that you want to create anew object, you will see the pop-up shownon the right.The object type is “PS” (meaning PublicSolution)You should then select “Generate fromData Source Object” and leave the “ODataChannel” checkbox switched on. Switching this checkbox off will cause the generated model to use the older Generic Channel object model© 2012 SAP AG. All rights reserved. 12
  • 13. Step 1) Create A Gateway Data Model – 2/2Now you must indicate from which type of data object the Gateway Service isto be generatedAfter entering a description, set the Data Source Type to “2 Remote Function Calls”and then enter the System Alias of the relevant backend systemSE80 will now take you directly to the Gateway Modelling Wizard.© 2012 SAP AG. All rights reserved. 13
  • 14. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 14
  • 15. Step 2) Map RFM to Gateway Service Operation – 1/2Select the RFM by performing a search1) Press the Binoculars icon on the tool bar and search for your required RFM2) Enter the search pattern3) Select the required RFM© 2012 SAP AG. All rights reserved. 15
  • 16. Step 2) Map RFM to Gateway Service Operation – 2/2Now your selected RFM must be mapped to a Gateway Service OperationThis is where you decide which of the Create, Read, Update, Delete or Queryoperations this RFM will implement© 2012 SAP AG. All rights reserved. 16
  • 17. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 17
  • 18. Step 3.1) Define the QUERY Operation’s InterfaceThe fields in the RFM interface define the fields that can be made available inthe Gateway Service Operation.IMPORTANT!Just because a field is present in the RFM’s interface does not mean it will bevisible in the OData interface! You must take care to ensure that mandatory inputfields are either supplied with a constant value or are visible in the OData interface.© 2012 SAP AG. All rights reserved. 18
  • 19. Step 3.2) Add Mandatory Fields to the InterfaceAny mandatory fields in the RFM interface must be made visible in the ODatainterface; therefore, mapping routes must be defined for these fields.This action adds the mandatory field(s) to the OData operation’s interface.If this is not completed, the operation will be unusable because data cannot besupplied to a mandatory input field.© 2012 SAP AG. All rights reserved. 19
  • 20. Step 3.2) Define Constant Values for Mandatory FieldsAlternatively, a mandatory input field might only require a static value.Supply a constant value for the mandatory input field. Remember that all non-numeric values must be specified within single quotes.This field will now not appear in the OData interface, but will always be suppliedwith the static value defined here.© 2012 SAP AG. All rights reserved. 20
  • 21. Step 3.3) Remember Which Fields Hold Key ValuesThe QUERY operation will output a list of banks. The user can then select anindividual bank from this list to see its details.We must now take care to remember which fields contain the key data on theoutput side of the QUERY operation, because these fields must then be used tosupply the key data required by the subsequent READ operation.(If we were creating a Gateway Service based on a BOR object, this step would be performed automatically)© 2012 SAP AG. All rights reserved. 21
  • 22. Step 3.4) Define a Model KeyEach Data Model must have one ormore fields defined to act as keys.For instance, when you perform aQUERY, you receive multiple Entities inan Entity Set. We cannot then perform asubsequent READ operation unless wefirst know from where the key values canbe derived. Once the key fields have been defined, the values they contain can be passed from one operation to another.© 2012 SAP AG. All rights reserved. 22
  • 23. Step 3.4) Map RFM Fields to the Model KeyOnce the Model Key fields have been defined, we map the RFM key fields.This allows key data to be passed from one operation to the next.1) At least one field in the OData interface must be flagged as a key field.2) For the RFM assigned to the QUERY operation, all its mandatory input fields must be visible in the OData operation’s interface3) On the output side of the QUERY RFM, the fields that will supply key data should be mapped to the OData key field(s)4) The mandatory input fields of the READ operation are now supplied by the OData key fields Flag OData Mandatory input interface field field of RFM as a key Key field on Key fields output side supply data to of RFM READ operation© 2012 SAP AG. All rights reserved. 23
  • 24. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 24
  • 25. Step 2) A QUERY Operation On Its Own Is Not SufficientThe QUERY operation has now beencreated by mapping it to the functionmodule BAPI_BANK_GETLIST.However, the OData specificationrequires that all services implement atleast a QUERY and a READ operation.Therefore, we must also create a READoperation.© 2012 SAP AG. All rights reserved. 25
  • 26. Step 2) Creating a READ Operation (Summary)1) Map the required RFM to the READ operation2) Define the fields from which this operation will obtain its key data3) Any 0..1 cardinality output structures need to be flattened (i.e. fields that belong to data structures should be remapped to the Gateway Service’s root node)© 2012 SAP AG. All rights reserved. 26
  • 27. Step 2.1) Define the Fields that Will Supply Key DataFor the RFM mapped to the READ operation, selecteach of its mandatory input fields and change theirmapping route to point to the correct Model Key field.Due to our previous mapping assignments, the inputfields of the READ RFM will now be populated withdata coming from the output side of the QUERYoperation.© 2012 SAP AG. All rights reserved. 27
  • 28. Step 2.2) Flattening the Interface – 1/3The RFM mapped to the READ operation exposes the bank’s address in a datastructure called BANK_ADDRESS. If we left these fields within the data structure, wewould need to issue a second HTTP request to obtain the data.To remove the need for a second HTTP request, we must flatten the BANK_ADDRESSstructure by changing the mapping route of each field. These fields have been mapped to the root node These fields have yet to be mapped© 2012 SAP AG. All rights reserved. 28
  • 29. Step 2.2) Flattening the Interface – 2/3As before, right-click on each field in the BANK_ADDRESS structure (this selects thefield but avoids deselecting the checkbox), then click “Change Mapping Route”.Select the root node of the Data Modeland press OK.This process must be repeated for eachfield in BANK_ADDRESS.© 2012 SAP AG. All rights reserved. 29
  • 30. Step 2.2) Flattening the Interface – 3/3Once the BANK_ADDRESS structure has been flattened, the data it produces can thenbe supplied to other operations such as UPDATE or CREATE All fields have now been mapped© 2012 SAP AG. All rights reserved. 30
  • 31. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 31
  • 32. Step 4) Generate the Data Model Runtime ClassesOnce the mapping process is complete, the Data Model must be generated.Generating the Data Model createsthe classes that are used at runtimeA list of all generated classes will bedisplayed© 2012 SAP AG. All rights reserved. 32
  • 33. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 33
  • 34. Step 5) Gateway Consumption Model – OverviewA GW Consumption Model is used toexpose your GW Data Model to theoutside worldConsumption Models are created in theABAP Developer WorkbenchOne or more GW Data Models can bebound to the GW Consumption Model.Also, one GW Data Model can beexposed through multiple GWConsumption Models.An ICF node is created under the path<default_host>/sap/opu/odata/sap/© 2012 SAP AG. All rights reserved. 34
  • 35. Step 5) Gateway Consumption Model – 1/3Create a GW Consumption Model in theABAP Developer WorkbenchFirst create a new Consumption ModelEnter the Service’s Technical Name, being careful to provide a meaningful name.Whatever name you enter here becomes the service name seen in the URL. Do not uncheck this checkbox! Your Data Model and Consumption Model must use the same runtime.© 2012 SAP AG. All rights reserved. 35
  • 36. Step 5) Gateway Consumption Model – 2/3Now assign your existing DataModel to the Consumption ModelRight click on the Consumption ModelEnter in the Data Model’sidentifier© 2012 SAP AG. All rights reserved. 36
  • 37. Step 5) Gateway Consumption Model – 3/3The Consumption Model and DataModel are now associated with eachotherDouble click on the name of theconsumption modelThe URL of theGateway Service isnow shown.However, we’re not quiteready to test the GatewayService!© 2012 SAP AG. All rights reserved. 37
  • 38. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 38
  • 39. Step 6) Assign System Alias to Gateway ServiceTransaction /IWFND/MAINT_SERVICE in Gateway HubThis transaction allows you to perform Gateway Service administration© 2012 SAP AG. All rights reserved. 39
  • 40. Step 6.1) Locate Your Gateway ServiceYour Gateway Service is most easily located by selecting the “External ServiceName” column header and then sorting the list.© 2012 SAP AG. All rights reserved. 40
  • 41. Step 6.2) Display Service PropertiesOnce you have located and then selected your Gateway Service, you will see itsproperties displayed in the lower half of the screen. As can be seen, an active ICF node has been created automatically for the service However, no system alias is yet definedClick on “Add System Alias”© 2012 SAP AG. All rights reserved. 41
  • 42. Step 6.3) Assign a System AliasClick “New Entries” and add a system alias for your service The “Service Document Identifier” is the full name of your Consumption Model Enter the system alias for the backend server that provides your business dataIf the Gateway add-ons have been installed in the same system as your backendBusiness Suite, then the system alias will typically be called LOCAL; however, this isonly a convention and not a rule.© 2012 SAP AG. All rights reserved. 42
  • 43. Agenda Remote Function Calls and Business Object Repository Overview Understanding Gateway Data and Consumption Models Developing Gateway Service based on a Remote Function Module or an Object in the Business Object Repository 1. Create a Gateway Data Model in the ABAP Development Workbench 2. Map your selected RFMs to Gateway Service operations using the Gateway Model Generator 3. Define the interface of the Gateway Service Operation based on the fields in the RFM 4. Generate the Gateway Data Model 5. Associate the Gateway Data Model with a Gateway Consumption Model 6. Associate the Gateway Service with a System Alias 7. Test your Gateway Service in a browser© 2012 SAP AG. All rights reserved. 43
  • 44. Step 7) Test Your Gateway Service – OverviewTesting a read-only Gateway Service can be done from a BrowserThe QUERY and READ operations of any Gateway Service use the HTTP GETmethod, and therefore can be tested from a browser.© 2012 SAP AG. All rights reserved. 44
  • 45. Step 7.1) Invoke Gateway Service From a BrowserOnce you have saved your changes, you can test your Gateway Service bypressing the “Call Browser” button. This will display the “Service Document”© 2012 SAP AG. All rights reserved. 45
  • 46. Step 7.2) The Gateway Service Document – 1/2The URL shown in SE80 for the Consumption Model points you to the ODataService Document.The Service Document is the starting point for Gateway Service consumption© 2012 SAP AG. All rights reserved. 46
  • 47. Step 7.2) The Gateway Service Document – 2/2The Service Document lists the collections provided by this Gateway ServiceEach collection is identified by a relative URL.The collection’s relative URL should be appended to the service’s base URL© 2012 SAP AG. All rights reserved. 47
  • 48. Step 7.3) Testing the QUERY Operation – 1/4To obtain an OData collection, append the collection’s relative URL to theservice’s base URLIn our case, we want to see a list of banks, so we construct the URL and issue thisfrom a browser.Be careful! Except for the Gateway Service part of the name, OData URLs arecase-sensitive.So let’s run the constructed URL... Hmmm, that’s not what we expected...© 2012 SAP AG. All rights reserved. 48
  • 49. Step 7.3) Testing the QUERY Operation – 2/4We have not defined a constant value for the mandatory input field BANK_CTRYand neither has a value been supplied by the client.We can fix this by taking one of two approaches here:(Less flexible) Hardcode a constant value in the service definition, or(More flexible) Add a parameter to the URL to supply the missing value© 2012 SAP AG. All rights reserved. 49
  • 50. Step 7.3) Testing the QUERY Operation – 3/4The most flexible option is to supply the missing parameter in the URLThe URL query string syntax for filtering an OData collection is as follows:?$filter=<field_name> <op> <value> “?” means “start ofYou must include a space or %20 the query string” field on which wethe operator Non-numeric The on either side of wish value. Comparison “$filter” is thefilter (case-sensitive!) to Operator such as in single quotes values must be OData command eq or neImportant: As of Gateway 2.0 SP03, operators must be in lower case© 2012 SAP AG. All rights reserved. 50
  • 51. Step 7.3) Testing the QUERY Operation – 4/4All data that matches the $filter command is now supplied to the clientThe QUERY operation returns 0..n <atom:entry>s in an <atom:feed> element?$filter=bank_ctry eq US© 2012 SAP AG. All rights reserved. 51
  • 52. Step 7.4) Testing the READ Operation – 1/2Each <atom:entry> in an OData Collection contains an <atom:id> elementThis element contains the URL to perform the READ operation for that single entry© 2012 SAP AG. All rights reserved. 52
  • 53. Step 7.4) Testing the READ Operation – 2/2The READ operation returns 0..1 entries in an <atom:entry> elementIf the entity cannot be found, then the <atom:content> element will be empty If found, the business data for the entry being READ will be contained within the <atom:content> element© 2012 SAP AG. All rights reserved. 53
  • 54. Summary You should now be able to:  Create a read-only Gateway Service based on a Remote Function Module or an Object in the Business Object Repository (BOR)  Expose a Gateway Service for consumption  Test your Gateway Service from a browser© 2012 SAP AG. All rights reserved. 54