cancel
Showing results for 
Search instead for 
Did you mean: 

Odataservice basic setup

0 Kudos
2,344

How to dod ODATA SETUP in your system

Accepted Solutions (0)

Answers (6)

Answers (6)

0 Kudos

1. In Backoffice, click Administration > Integration UI Tool.

2. In the navaigation on the left, Monitoring > Inbound.

3. Click Search. If the cron job successfully deleted the InboundRequest, it does not appear in the list.

4. Cart creation example with ODATA service:

5. Impex for Cart Creation Object:

INSERT_UPDATE IntegrationObject; code[unique = true]; integrationType(code)

; CartCD; INBOUND

INSERT_UPDATE IntegrationObjectItem; integrationObject(code)[unique = true]; code[unique = true]; type(code); root[default = false]

; CartCD ; Cart ; Cart ; true ;

; CartCD ; CatalogVersion ; CatalogVersion ; ;

; CartCD ; Catalog ; Catalog ; ;

; CartCD ; CartEntry ; CartEntry ; ;

; CartCD ; Currency ; Currency ; ;

; CartCD ; Product ; Product ; ;

; CartCD ; Unit ; Unit ; ;

; CartCD ; User ; User ; ;

INSERT_UPDATE IntegrationObjectItemAttribute; integrationObjectItem(integrationObject(code), code)[unique = true]; attributeName[unique = true]; attributeDescriptor(enclosingType(code), qualifier); returnIntegrationObjectItem(integrationObject(code), code); unique[default = false]; autoCreate[default = false]

; CartCD:Cart ; entries ; Cart:entries ; CartCD:CartEntry ; ;

; CartCD:Cart ; date ; Cart:date ; ; ;

; CartCD:Cart ; code ; Cart:code ; ; true ;

; CartCD:Cart ; name ; Cart:name ; ; ;

; CartCD:Cart ; currency ; Cart:currency ; CartCD:Currency ; ;

; CartCD:Cart ; user ; Cart:user ; CartCD:User ; true ;

; CartCD:CatalogVersion ; version ; CatalogVersion:version ; ; true ;

; CartCD:CatalogVersion ; catalog ; CatalogVersion:catalog ; CartCD:Catalog ; true ;

; CartCD:Catalog ; id ; Catalog:id ; ; true ;

; CartCD:CartEntry ; order ; CartEntry:order ; CartCD:Cart ; true ;

; CartCD:CartEntry ; product ; CartEntry:product ; CartCD:Product ; ;

; CartCD:CartEntry ; quantity ; CartEntry:quantity ; ; ;

; CartCD:CartEntry ; unit ; CartEntry:unit ; CartCD:Unit ; ;

; CartCD:Currency ; isocode ; Currency:isocode ; ; true ;

; CartCD:Product ; code ; Product:code ; ; true ;

; CartCD:Product ; catalogVersion ; Product:catalogVersion ; CartCD:CatalogVersion ; true ;

; CartCD:Unit ; code ; Unit:code ; ; true ;

; CartCD:User ; uid ; User:uid ; ; true ;

6. After run it will show in backoffice:

7. Which fiels we need to pass in jsone request that we need to check and save in backoffice in right side of window.

8. Creating cart with help of postman with integration Object:

9. Now cart code is generated later we can add cart entries with this cart code so we need to again send request. After creation of cart in inbound we can see integration key.

10.Json request with cart entries with product:

{

"@odata.context": "$metadata#Carts/$entity",

"code":"00303010",

"user":{"uid":"akansha.agrawal01@infosys.com"},

"currency":{ "isocode":"USD"},

"date":"2001-12-21T12:00",

"entries" :

[

{

"product":{

"code":"GSVROW_P0049111600",

"catalogVersion": {

"catalog": {

"id": "ProductCatalog"

},

"version": "Online"

}

},

"order":{

"code":"00303005",

"user":{"uid":"akansha.agrawal01@infosys.com"}

},

"quantity":"3",

"unit":{

"code":"PC"

}

}

]

}

11.Now we can see cart entries in cart in backoffice like this:

12. One important not which model we are generation from Odata for that we need to tick in integration tool and save like eg in cart we have name then we need to select name and save then only name we can pass otherwise it will show 400 bad response.

0 Kudos

1. Monitoring Requests

View the status, payload, and any errors you received for your inbound ExampleProduct request. If you have enabled the payload retention properties, you can download the payload in a text file or view its contents in a browser. See Configuring Payload Retention.

In a web browser, navigate to https://localhost:9102/backoffice/ and log in.

From the drop-down menu at the top, click Administration > Integration UI Tool.

In the menu on the left, click Monitoring > Inbound. The middle pane of the screen shows inbound requests. You can see the ExampleProduct you previously created.

2. Click the Staged|Default|camera-b52 entry in the listing to populate the Inbound Request Details for the item. See Integration API Request Monitoring for a description of each field.

3. If payload retention is enabled, double-click the Request Payload field to view the payload of the ExampleProduct. See Configuring Payload Retention for more information.

4. n the Edit item Payload window, you can view the payload in two ways:

In the General section of the Edit item Payload window, click Download to save a payload file to your default download folder. For JSON, the file is named Payload_<UUID>.octet-stream. For XML, the file is Payload_<UUID>.xml. Open the file in a text editor to view the payload.

In the Properties section, copy the text in the URL field. In a web browser, type http://localhost:9001 and append the copied URL. The resulting URL looks like http://localhost:9001/medias/Payload-52511970-c898-4d7f-bb0d-b450abce3d67?context=bWFzdGVyfHJvb3R8Mj.... Press Enter to view the item payload.

5. Enabling and Disabling Monitoring

By default, monitoring is enabled. Use the following instructions to disable and re-enable monitoring for inbound and outbound Integration API requests.

In a web browser, navigate to the SAP Commerce Administration Console https://localhost:9002 and log in.

Click Platform > Configuration.

In the Search field, enter monitoring and locate the integrationservices.monitoring.enabled property.

Change the value of inboundservices.monitoring.enabled and outboundservices.monitoring.enabled to false. Click the green checkmark to apply the change for each property.

Enable monitoring again by changing the same values to true. Click the green checkmarks to apply the changes.

6. Managing Data Retention for Inbound Requests:

Request data is persisted in the platform for monitoring as InboundRequest, InboundRequestError, and IntegrationApiMedia types. You can change the data retention policy for how long the data persists in the system, and for when and how often data clean-up cron jobs run.

This tutorial guides you through changing the request data retention duration, the timing and intervals at which request data clean-up jobs run, and then running the data clean-up cron job manually in Backoffice.

7. Change the Data Retention Policy and Clean-up Schedule using ImpEx:

By default, the extension creates two cron jobs, one for cleaning up InboundRequest and InboundRequestError types. You can see the default settings in the following ImpEx.

  • INSERT_UPDATE AfterRetentionCleanupRule creates the cleanup rules for the InboundRequest and IntegrationApiMedia cron jobs. The default retention period is 604800 seconds (7 days).
  • INSERT_UPDATE RetentionJob defines how many items per batch get deleted at once. You can change the number of items for better performance.
  • INSERT_UPDATE CronJob creates the cron job and specifies when, and which days of the week to run each of the two cron jobs
  • INSERT_UPDATE Trigger defines when to run each job. The expression 0 0 0 * * ? runs the jobs every day at midnight. The server must be running at the time you specify in order for it to delete the persisted request data.
  • Impex:

INSERT_UPDATE AfterRetentionCleanupRule ; code[unique=true] ; retirementItemType(code) ; itemFilterExpression ; actionReference ; retentionTimeSeconds ; retirementDateAttribute(enclosingType(code),qualifier)

; inboundRequestCleanupRule ; InboundRequest ; ; basicRemoveCleanupAction ; 604800 ; InboundRequest:creationtime

; inboundRequestMediaCleanupRule ; IntegrationApiMedia ; ; basicRemoveCleanupAction ; 604800 ; IntegrationApiMedia:creationtime

INSERT_UPDATE RetentionJob ; code[unique=true] ; retentionRule(code) ; batchSize

; inboundRequestCleanupJob ; inboundRequestCleanupRule ; 100

; inboundRequestMediaCleanupJob ; inboundRequestMediaCleanupRule ; 100

INSERT_UPDATE CronJob ; code[unique=true] ; job(code) ; sessionLanguage(isoCode)[default=en]

; inboundRequestCleanupCronJob ; inboundRequestCleanupJob ;

; inboundRequestMediaCleanupCronJob ; inboundRequestMediaCleanupJob ;

# CronJob Triggers set to run every day at midnight

INSERT_UPDATE Trigger ; cronJob(code)[unique=true] ; cronExpression

; inboundRequestCleanupCronJob ; 0 0 0 * * ?

; inboundRequestMediaCleanupCronJob ; 0 0 0 * * ?

For this tutorial, change the retention for the InboundRequest to 30 seconds.

In a web browser, navigate to the SAP Commerce Administration Console at https://localhost:9002/ and log in.

Click Console > ImpEx Import.

To override the default retention settings, paste the following ImpEx into the Import Content field and click Import content.

INSERT_UPDATE AfterRetentionCleanupRule; code[unique = true]; retirementItemType(code); itemFilterExpression; actionReference; retentionTimeSeconds; retirementDateAttribute(enclosingType(code), qualifier)

; inboundRequestCleanupRule ; InboundRequest ; ; basicRemoveCleanupAction ; 30 ; InboundRequest:creationtime

Verify that the change was made. In a web browser, navigate to https://localhost:9002/backoffice/ and log in.

In the Administration perspective, click System > Retention Rule.

Locate and click inboundRequestCleanupRule.

At the bottom of the screen, scroll to the Properties section and verify that the value in the Retention Time in Seconds field is 30.

8. Running the Data Clean-up cron jobs

Now you can run the cron job. To see the results of the cron job without waiting until the next scheduled job, change the job schedule. You can either change the schedule using ImpEx, or by triggering the job manually in Backoffice.

Changing the job schedule using ImpEx:

To change the inboundRequestCleanupCronJob to run every 30 seconds, run the following ImpEx:

INSERT_UPDATE Trigger ; cronJob(code)[unique=true] ; cronExpression

; inboundRequestCleanupCronJob ; */30 * * * * ?

Wait 30 seconds and then view the log in terminal. If the job ran successfully, the log shows:

INFO [hybrisHTTP30] [PerformCronJobAction] Performing CronJob CronJobModel (8796093514229@34) from Backoffice!

INFO [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Starting AfterRetentionCleanupJob

INFO [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Selecting items for clean up using inboundRequestCleanupRule

INFO [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Sending 1 items for clean up, using basicRemoveCleanupAction

INFO  [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Sending 0 items for clean up, using basicRemoveCleanupAction

9. Changing the job schedule and running the cron job in Backoffice

To clean up a persisted InboundRequest using the Integration UI Tool view in Backoffice, perform the following steps.

1. In a web browser, navigate to https://localhost:9102/backoffice/ and log in.

2. In Backoffice, from the drop-down menu at the top, click Administration > Integration UI Tool.

3. In the navigation menu on the left, click System > Background Processes > Cronjobs.

4. In the list of jobs, click inboundRequestCleanupCronJob. The job details appear in the bottom of the screen.

View the log in terminal to verify that the job ran successfully. The log should show:

INFO [hybrisHTTP30] [PerformCronJobAction] Performing CronJob CronJobModel (8796093514229@34) from Backoffice!

INFO [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Starting AfterRetentionCleanupJob

INFO [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Selecting items for clean up using inboundRequestCleanupRule

INFO [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Sending 1 items for clean up, using basicRemoveCleanupAction

INFO [inboundRequestCleanupCronJob::de.hybris.platform.servicelayer.internal.jalo.RetentionJob] (inboundRequestCleanupCronJob) [AfterRetentionCleanupJobPerformable] Sending 0 items for clean up, using basicRemoveCleanupAction

0 Kudos

1. Creating the Product Integration Item:

Use the following instructions to create a new Product Integration Item using the Integration API.

Create the following JSON payload and save it as product.json.

{

"@odata.context": "$metadata#Products/$entity",

"code": "camera-b52",

"name": "Camera B52",

"catalogVersion": {

"catalog": {

"id": "Default"

},

"version": "Staged"

}

}

2. We need to set configuration in postman as :

3. Viewing a Product Integration Item:

0 Kudos

1. First I am creating Inbound object so that object will come from middle ware to hybris then it will be useful. Then it will see in backoffice like this:

2. I can create this object with help of API request with POSTMAN and can create from backoffice as well with + sign .

3. After creating we can see for that particular object EDMX and impex view as well.

Click Product to view the object attributes. To view the object and its attributes in an ImpEx script or the EDMX schema, click the Metadata Viewer button and select the Impex View or EDMX View tab.

We can see this request we can put in browser:

then response will come or with postman help also we can see this issue.

4. For inbound data when we tried from postman and it will generate integration key with payload with success for that we need to configure some properties as true.

inboundservices.monitoring.error.payload.retention : true

inboundservices.monitoring.success.payload.retention : true

5. When we want to see integration object we can see with help of url and need to give username and password as : admin and nimda

Like :

6. Creating and Viewing a Product Integration Item:

7. Create and retrieve a single Product item.

8. After you define the ExampleProduct Integration Object in the system, the service is available at https://localhost:9102/odata2webservices/ExampleProduct/Products. You can then create and update a Product item. You can also use the IntegrationObjects endpoint to create and view integration object items, but the following examples use the Products endpoint. For more information about using the IntegrationObjects endpoint,

0 Kudos

1. First I am creating Inbound object so that object will come from middle ware to hybris then it will be useful. Then it will see in backoffice like this:

2. I can create this object with help of API request with POSTMAN and can create from backoffice as well with + sign .

3. After creating we can see for that particular object EDMX and impex view as well.

Click Product to view the object attributes. To view the object and its attributes in an ImpEx script or the EDMX schema, click the Metadata Viewer button and select the Impex View or EDMX View tab.

We can see this request we can put in browser:

then response will come or with postman help also we can see this issue.

4. For inbound data when we tried from postman and it will generate integration key with payload with success for that we need to configure some properties as true.

inboundservices.monitoring.error.payload.retention : true

inboundservices.monitoring.success.payload.retention : true

5. When we want to see integration object we can see with help of url and need to give username and password as : admin and nimda

Like :

6. Creating and Viewing a Product Integration Item:

7. Create and retrieve a single Product item.

8. After you define the ExampleProduct Integration Object in the system, the service is available at https://localhost:9102/odata2webservices/ExampleProduct/Products. You can then create and update a Product item. You can also use the IntegrationObjects endpoint to create and view integration object items, but the following examples use the Products endpoint. For more information about using the IntegrationObjects endpoint,

0 Kudos

ODATA Service install steps:

1. What is OData (Open Data Protocol)?

SAP Cloud for Customer offers an OData API in order to consume SAP Cloud for Customer features in your

business applications. With this OData API, you can query, read, add, update and delete data from and into SAP

Cloud for Customer.

This document is a reference point for learning SAP Cloud for Customer OData API. Thus, it provides a short

introduction to the capabilities of the OData API as well as information on where to find more details.

OData (Open Data Protocol) is an open protocol for sharing data. In other words - OData defines an abstract data model and a protocol that let any client access information exposed by any data source.

2. Why use the OData?

Currently a lot of common ways of designing web API's have emerged on the web. Many of them already apply REST and use JSON or XML to expose data.

However these APIs are not uniform.

OData solves this problem by providing a uniform way to expose, structure, query and manipulate data using REST practices and JSON or ATOM syntax to describe the payload.

OData also provides a uniform way to represent metadata about the data, allowing computers to know more about the type system, relationships and structure of the data.

3. Add all extensions in local

<!-- integration -->

<extension name='outboundservices' />

<extension name='outboundsync' />

<extension name='odata2webservices' />

<extension name='odata2webservicesfeaturetests' />

<extension name='integrationbackoffice' />

<extension name='integrationmonitoringbackoffice' />

<extension name='outboundsyncbackoffice' />

4. Add dependency in custom extension as core:

With this <requires-extension name="odata2webservices"/>

5. The odata2webservices extension exposes the business service as a REST-based web service. The extension depends on odata2services, which depends on integrationservices. When you install odata2webservices, the odata2services and integration services extensions are automatically available at compile and runtime.

6. In a command line, cd to the <HYBRIS_HOME>/hybris/bin/platform directory.

7. Source the setantenv.sh script using the command:

. setantenv.sh

8. In the command line, run ant clean all. This step builds the platform/commerce-suite directory with the extensions you added to the localextensions.xml file.

9. In the command line, run ant initialize if new setup.

10.Start SAP Commerce using the command:

./hybrisserver.sh

11.Click Administration > Integration UI Tool. If you can open the Integration UI Tool, the extension is successfully installed. Data is not present if you have not yet created any metadata for monitoring.

12.Impex run in HAC

INSERT_UPDATE IntegrationObject; code[unique = true]; integrationType(code)

; ExampleProduct1; INBOUND

INSERT_UPDATE IntegrationObjectItem; integrationObject(code)[unique = true]; code[unique = true]; type(code)

; ExampleProduct1 ; Catalog ; Catalog

; ExampleProduct1 ; CatalogVersion ; CatalogVersion

; ExampleProduct1 ; Product ; Product

INSERT_UPDATE IntegrationObjectItemAttribute; integrationObjectItem(integrationObject(code), code)[unique = true]; attributeName[unique = true]; attributeDescriptor(enclosingType(code), qualifier); returnIntegrationObjectItem(integrationObject(code), code); unique[default = false]

; ExampleProduct1:Catalog ; id ; Catalog:id ;

; ExampleProduct1:CatalogVersion ; catalog ; CatalogVersion:catalog ; ExampleProduct1:Catalog

; ExampleProduct1:CatalogVersion ; version ; CatalogVersion:version ;

; ExampleProduct1:Product ; code ; Product:code ;

; ExampleProduct1:Product ; catalogVersion ; Product:catalogVersion ; ExampleProduct1:CatalogVersion

; ExampleProduct1:Product ; name ; Product:name ;