{"id":"f593e45e-d105-4cb3-ae31-d371e0d62154","shortId":"7wtMwp","kind":"skill","title":"odata","tagline":"Help with OData service development in ABAP including OData V2 and V4 services via RAP service bindings, SEGW-based services, service definitions, service bindings, OData annotations, consumption of external OData services, and troubleshooting common OData errors. Use when users ","description":"# OData Service Development\n\nGuide for creating and consuming OData services in ABAP, covering both RAP-based (V4/V2) and SEGW-based (V2) approaches.\n\n## Workflow\n\n1. **Determine the user's goal**:\n   - Exposing a RAP BO as an OData service (recommended approach)\n   - Creating a classic SEGW-based OData V2 service\n   - Consuming an external OData service from ABAP\n   - Adding OData annotations for Fiori UIs\n   - Troubleshooting OData errors\n\n2. **Identify the approach**:\n   - RAP-based service (preferred for ABAP Cloud)\n   - SEGW-based service (classic, Standard ABAP only)\n   - OData consumption (client proxy)\n\n3. **Guide implementation** following SAP best practices\n\n## RAP-Based OData Services (Recommended)\n\n### Architecture Flow\n\n```\nCDS View Entity → Behavior Definition → Service Definition → Service Binding\n                                                                    ↓\n                                                              OData V4/V2 Endpoint\n```\n\n### Service Definition\n\nExposes CDS entities and their behaviors as a named service:\n\n```cds\n@EndUserText.label: 'Travel Service'\ndefine service ZUI_TRAVEL_O4 {\n  expose ZC_Travel as Travel;\n  expose ZC_Booking as Booking;\n  expose I_Currency as Currency;\n  expose I_Country as Country;\n}\n```\n\n#### Key Rules\n\n- Expose projection CDS views (C\\_ prefix by convention), not root views\n- Include value help CDS views (I\\_\\* views) the UI needs\n- Alias names become OData entity set names\n- One service definition can be bound to multiple protocols\n\n### Service Binding\n\nBinds a service definition to a specific OData protocol and provides a URL:\n\n| Binding Type         | Protocol | Use Case                           |\n| -------------------- | -------- | ---------------------------------- |\n| `OData V4 - UI`      | V4       | SAP Fiori Elements apps            |\n| `OData V2 - UI`      | V2       | Legacy Fiori apps, older frontends |\n| `OData V4 - Web API` | V4       | API consumption (A2X scenarios)    |\n| `OData V2 - Web API` | V2       | API consumption (legacy)           |\n| `InA - UI`           | InA      | Analytical scenarios               |\n\n### Creating a Service Binding\n\n1. In ADT: **New → Other ABAP Repository Object → Business Services → Service Binding**\n2. Select the service definition\n3. Choose binding type (e.g., OData V4 - UI)\n4. Activate\n5. Click **Publish** to register the service\n6. Click **Preview** to open the Fiori Elements preview\n\n## OData V4 vs V2\n\n| Feature               | OData V4                      | OData V2                        |\n| --------------------- | ----------------------------- | ------------------------------- |\n| **Protocol**          | JSON by default               | XML (Atom) default, JSON option |\n| **Batch**             | `$batch` with JSON            | `$batch` with multipart         |\n| **Deep operations**   | Deep create/update supported  | Limited                         |\n| **Actions/Functions** | Bound and unbound             | Function imports                |\n| **Filtering**         | `$filter` with `lambda`       | `$filter` basic                 |\n| **Draft**             | Full support                  | Supported via extensions        |\n| **Aggregation**       | `$apply` transformation       | Not natively supported          |\n| **Recommendation**    | Preferred for new development | Maintain existing only          |\n\n## SEGW-Based OData V2 Services (Classic)\n\nFor Standard ABAP only (not available in ABAP Cloud):\n\n### Architecture\n\n```\nSEGW Project → Data Model (Entity Types, Sets, Associations)\n             → Service Implementation (MPC/DPC classes)\n             → Register & Activate in /IWFND/MAINT_SERVICE\n```\n\n### Steps\n\n1. **Create project** in `SEGW` transaction\n2. **Define data model**: Entity types, properties, navigation properties\n3. **Generate runtime artifacts** (MPC/DPC classes)\n4. **Implement DPC extension methods**: `GET_ENTITYSET`, `GET_ENTITY`, `CREATE_ENTITY`, etc.\n5. **Register service** in `/IWFND/MAINT_SERVICE`\n6. **Test** via `/IWFND/GW_CLIENT` or browser\n\n### DPC Method Implementation Example\n\n```abap\nMETHOD travelset_get_entityset.\n  SELECT * FROM ztravel_tab\n    INTO TABLE @DATA(lt_travel)\n    UP TO 100 ROWS.\n\n  et_entityset = CORRESPONDING #( lt_travel ).\nENDMETHOD.\n```\n\n## Consuming External OData Services\n\n### In ABAP Cloud (using HTTP Client and Communication Arrangements)\n\n```abap\n\"1. Get HTTP client via communication arrangement\nDATA(lo_dest) = cl_http_destination_provider=>create_by_comm_arrangement(\n  comm_scenario  = 'Z_MY_OUTBOUND_SCENARIO'\n  service_id     = 'Z_MY_HTTP_SERVICE' ).\n\nDATA(lo_client) = cl_web_http_client_manager=>create_by_http_destination( lo_dest ).\n\n\"2. Build request\nDATA(lo_request) = lo_client->get_http_request( ).\nlo_request->set_uri_path( '/sap/opu/odata4/sap/api_business_partner/srvd_a2x/sap/api_business_partner/0001/A_BusinessPartner?$top=10' ).\n\n\"3. Execute and parse response\nDATA(lo_response) = lo_client->execute( if_web_http_client=>get ).\nDATA(lv_json) = lo_response->get_text( ).\nlo_client->close( ).\n```\n\n### Using OData Client Proxy (V2/V4)\n\n```abap\n\"Create OData client proxy for V4\nDATA(lo_proxy) = /iwbep/cl_cp_client_proxy_fact=>create_v4_remote_proxy(\n  iv_service_definition_name = 'Z_MY_ODATA_CDEF'\n  io_http_client             = lo_client\n  iv_relative_service_root   = '/sap/opu/odata4/sap/api_service/0001/' ).\n\n\"Build and execute read request\nDATA(lo_request) = lo_proxy->create_resource_for_entity_set( 'ENTITYSETNAME' )->create_request_for_read( ).\nlo_request->set_top( 10 ).\nDATA(lo_response) = lo_request->execute( ).\n\n\"Get business data\nDATA lt_data TYPE STANDARD TABLE OF z_entity_type.\nlo_response->get_business_data( IMPORTING et_business_data = lt_data ).\n```\n\n## OData Annotations for Fiori\n\nKey CDS annotations that control OData/Fiori behavior:\n\n```cds\n@UI.headerInfo: {\n  typeName: 'Travel',\n  typeNamePlural: 'Travels',\n  title: { type: #STANDARD, value: 'TravelID' },\n  description: { type: #STANDARD, value: 'Description' }\n}\n\n@UI.lineItem: [{ position: 10 }]\n@UI.selectionField: [{ position: 10 }]\n@UI.identification: [{ position: 10 }]\nTravelID;\n\n@UI.lineItem: [{ position: 20, importance: #HIGH }]\n@UI.identification: [{ position: 20 }]\n@Consumption.valueHelpDefinition: [{ entity: { name: 'I_Currency', element: 'Currency' } }]\nCurrencyCode;\n```\n\n## Troubleshooting\n\n| Error / Issue                  | Solution                                           |\n| ------------------------------ | -------------------------------------------------- |\n| `/IWBEP/CX_MGW_BUSI_EXCEPTION` | Check DPC implementation, validate input data      |\n| `/IWBEP/CX_MGW_TECH_EXCEPTION` | Check data model consistency, regenerate artifacts |\n| 403 Forbidden                  | Check ICF node activation, authorization           |\n| 404 Not Found                  | Verify service is registered and activated         |\n| `$metadata` returns empty      | Publish service binding, check activation          |\n| Draft not working              | Verify draft table exists, BDEF has `with draft`   |\n| Deep create fails              | Check composition in CDS and BDEF                  |\n| `CX_WEB_HTTP_CLIENT_ERROR`     | Check communication arrangement, SSL certificates  |\n\n## Output Format\n\nWhen helping with OData topics, structure responses as:\n\n```markdown\n## OData Service Guidance\n\n### Approach\n\n- Type: [RAP-based / SEGW-based / Consumption]\n- Protocol: [OData V4 / OData V2]\n\n### Implementation\n\n[Step-by-step with code examples]\n\n### Testing\n\n[How to test the service]\n```\n\n## References\n\n- SAP OData V4 Documentation: https://help.sap.com/docs/abap-cloud/abap-rap/odata-service\n- RAP Service Binding: https://help.sap.com/docs/abap-cloud/abap-rap/service-binding\n- OData Client Proxy: https://help.sap.com/docs/abap-cloud/abap-rap/odata-client-proxy","tags":["odata","abap","skills","likweitan","agent-skills","sap"],"capabilities":["skill","source-likweitan","skill-odata","topic-abap","topic-agent-skills","topic-sap"],"categories":["abap-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/likweitan/abap-skills/odata","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add likweitan/abap-skills","source_repo":"https://github.com/likweitan/abap-skills","install_from":"skills.sh"}},"qualityScore":"0.456","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 12 github stars · SKILL.md body (7,831 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-24T01:03:16.792Z","embedding":null,"createdAt":"2026-04-23T13:03:45.371Z","updatedAt":"2026-04-24T01:03:16.792Z","lastSeenAt":"2026-04-24T01:03:16.792Z","tsv":"'/docs/abap-cloud/abap-rap/odata-client-proxy':896 '/docs/abap-cloud/abap-rap/odata-service':884 '/docs/abap-cloud/abap-rap/service-binding':890 '/iwbep/cl_cp_client_proxy_fact':632 '/iwbep/cx_mgw_busi_exception':767 '/iwbep/cx_mgw_tech_exception':774 '/iwfnd/gw_client':483 '/iwfnd/maint_service':440,479 '/sap/opu/odata4/sap/api_business_partner/srvd_a2x/sap/api_business_partner/0001/a_businesspartner':588 '/sap/opu/odata4/sap/api_service/0001':654 '1':67,302,442,528 '10':590,679,739,742,745 '100':506 '2':108,314,448,572 '20':749,754 '3':132,319,457,591 '4':327,463 '403':781 '404':788 '5':329,475 '6':336,480 'a2x':283 'abap':8,53,98,118,126,307,417,422,490,519,527,622 'actions/functions':376 'activ':328,438,786,796,804 'ad':99 'adt':304 'aggreg':394 'alia':223 'analyt':296 'annot':28,101,711,716 'api':279,281,288,290 'app':266,273 'appli':395 'approach':65,82,111,849 'architectur':145,424 'arrang':526,534,545,832 'artifact':460,780 'associ':432 'atom':359 'author':787 'avail':420 'base':21,58,63,88,114,122,141,410,853,856 'basic':387 'batch':363,364,367 'bdef':812,824 'becom':225 'behavior':150,166,720 'best':137 'bind':18,26,155,240,241,254,301,313,321,802,887 'bo':76 'book':187,189 'bound':235,377 'browser':485 'build':573,655 'busi':310,687,702,706 'c':206 'case':258 'cdef':644 'cds':147,162,171,204,216,715,721,822 'certif':834 'check':768,775,783,803,819,830 'choos':320 'cl':538,561 'class':436,462 'classic':85,124,414 'click':330,337 'client':130,523,531,560,564,579,600,605,615,619,625,647,649,828,892 'close':616 'cloud':119,423,520 'code':869 'comm':544,546 'common':36 'communic':525,533,831 'composit':820 'consist':778 'consum':49,92,514 'consumpt':29,129,282,291,857 'consumption.valuehelpdefinition':755 'control':718 'convent':209 'correspond':510 'countri':197,199 'cover':54 'creat':47,83,298,443,472,542,566,623,633,665,671,817 'create/update':373 'currenc':192,194,759,761 'currencycod':762 'cx':825 'data':427,450,501,535,558,575,596,607,629,660,680,688,689,691,703,707,709,773,776 'deep':370,372,816 'default':357,360 'defin':175,449 'definit':24,151,153,160,232,244,318,639 'descript':732,736 'dest':537,571 'destin':540,569 'determin':68 'develop':6,44,404 'document':881 'dpc':465,486,769 'draft':388,805,809,815 'e.g':323 'element':265,343,760 'empti':799 'endmethod':513 'endpoint':158 'endusertext.label':172 'entiti':149,163,227,429,452,471,473,668,697,756 'entityset':469,494,509 'entitysetnam':670 'error':38,107,764,829 'et':508,705 'etc':474 'exampl':489,870 'execut':592,601,657,685 'exist':406,811 'expos':73,161,180,185,190,195,202 'extens':393,466 'extern':31,94,515 'fail':818 'featur':349 'filter':382,383,386 'fiori':103,264,272,342,713 'flow':146 'follow':135 'forbidden':782 'format':836 'found':790 'frontend':275 'full':389 'function':380 'generat':458 'get':468,470,493,529,580,606,612,686,701 'goal':72 'guid':45,133 'guidanc':848 'help':2,215,838 'help.sap.com':883,889,895 'help.sap.com/docs/abap-cloud/abap-rap/odata-client-proxy':894 'help.sap.com/docs/abap-cloud/abap-rap/odata-service':882 'help.sap.com/docs/abap-cloud/abap-rap/service-binding':888 'high':751 'http':522,530,539,556,563,568,581,604,646,827 'icf':784 'id':553 'identifi':109 'implement':134,434,464,488,770,863 'import':381,704,750 'ina':293,295 'includ':9,213 'input':772 'io':645 'issu':765 'iv':637,650 'json':355,361,366,609 'key':200,714 'lambda':385 'legaci':271,292 'limit':375 'lo':536,559,570,576,578,583,597,599,610,614,630,648,661,663,675,681,683,699 'lt':502,511,690,708 'lv':608 'maintain':405 'manag':565 'markdown':845 'metadata':797 'method':467,487,491 'model':428,451,777 'mpc/dpc':435,461 'multipart':369 'multipl':237 'name':169,224,229,640,757 'nativ':398 'navig':455 'need':222 'new':305,403 'node':785 'o4':179 'object':309 'odata':1,4,10,27,32,37,42,50,79,89,95,100,106,128,142,156,226,248,259,267,276,285,324,345,350,352,411,516,618,624,643,710,840,846,859,861,879,891 'odata/fiori':719 'older':274 'one':230 'open':340 'oper':371 'option':362 'outbound':550 'output':835 'pars':594 'path':587 'posit':738,741,744,748,753 'practic':138 'prefer':116,401 'prefix':207 'preview':338,344 'project':203,426,444 'properti':454,456 'protocol':238,249,256,354,858 'provid':251,541 'proxi':131,620,626,631,636,664,893 'publish':331,800 'rap':16,57,75,113,140,852,885 'rap-bas':56,112,139,851 'read':658,674 'recommend':81,144,400 'refer':877 'regener':779 'regist':333,437,476,794 'relat':651 'remot':635 'repositori':308 'request':574,577,582,584,659,662,672,676,684 'resourc':666 'respons':595,598,611,682,700,843 'return':798 'root':211,653 'row':507 'rule':201 'runtim':459 'sap':136,263,878 'scenario':284,297,547,551 'segw':20,62,87,121,409,425,446,855 'segw-bas':19,61,86,120,408,854 'select':315,495 'servic':5,14,17,22,23,25,33,43,51,80,91,96,115,123,143,152,154,159,170,174,176,231,239,243,300,311,312,317,335,413,433,477,517,552,557,638,652,792,801,847,876,886 'set':228,431,585,669,677 'skill' 'skill-odata' 'solut':766 'source-likweitan' 'specif':247 'ssl':833 'standard':125,416,693,729,734 'step':441,865,867 'step-by-step':864 'structur':842 'support':374,390,391,399 'tab':498 'tabl':500,694,810 'test':481,871,874 'text':613 'titl':727 'top':589,678 'topic':841 'topic-abap' 'topic-agent-skills' 'topic-sap' 'transact':447 'transform':396 'travel':173,178,182,184,503,512,724,726 'travelid':731,746 'travelset':492 'troubleshoot':35,105,763 'type':255,322,430,453,692,698,728,733,850 'typenam':723 'typenameplur':725 'ui':104,221,261,269,294,326 'ui.headerinfo':722 'ui.identification':743,752 'ui.lineitem':737,747 'ui.selectionfield':740 'unbound':379 'uri':586 'url':253 'use':39,257,521,617 'user':41,70 'v2':11,64,90,268,270,286,289,348,353,412,862 'v2/v4':621 'v4':13,260,262,277,280,325,346,351,628,634,860,880 'v4/v2':59,157 'valid':771 'valu':214,730,735 'verifi':791,808 'via':15,392,482,532 'view':148,205,212,217,219 'vs':347 'web':278,287,562,603,826 'work':807 'workflow':66 'xml':358 'z':548,554,641,696 'zc':181,186 'ztravel':497 'zui':177","prices":[{"id":"83bc18f4-b947-432f-9c4c-d50ac56d797e","listingId":"f593e45e-d105-4cb3-ae31-d371e0d62154","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"likweitan","category":"abap-skills","install_from":"skills.sh"},"createdAt":"2026-04-23T13:03:45.371Z"}],"sources":[{"listingId":"f593e45e-d105-4cb3-ae31-d371e0d62154","source":"github","sourceId":"likweitan/abap-skills/odata","sourceUrl":"https://github.com/likweitan/abap-skills/tree/main/skills/odata","isPrimary":false,"firstSeenAt":"2026-04-23T13:03:45.371Z","lastSeenAt":"2026-04-24T01:03:16.792Z"}],"details":{"listingId":"f593e45e-d105-4cb3-ae31-d371e0d62154","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"likweitan","slug":"odata","github":{"repo":"likweitan/abap-skills","stars":12,"topics":["abap","agent-skills","sap"],"license":"mit","html_url":"https://github.com/likweitan/abap-skills","pushed_at":"2026-04-17T13:44:41Z","description":"Advance Agent Skills for ABAP Developers","skill_md_sha":"0e59a53a8a9c4f39fabe639cd1eef959cd63f20d","skill_md_path":"skills/odata/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/likweitan/abap-skills/tree/main/skills/odata"},"layout":"multi","source":"github","category":"abap-skills","frontmatter":{"name":"odata","description":"Help with OData service development in ABAP including OData V2 and V4 services via RAP service bindings, SEGW-based services, service definitions, service bindings, OData annotations, consumption of external OData services, and troubleshooting common OData errors. Use when users ask about OData, OData V2, OData V4, service binding, service definition, SEGW, OData annotations, OData consumption, OData client proxy, HTTP client, communication arrangement, external API consumption, /IWBEP/ errors, or exposing a RAP BO as OData. Triggers include \"create OData service\", \"expose RAP BO\", \"service binding\", \"OData V4\", \"consume external OData\", \"OData annotations\", \"SEGW service\", or \"OData error\"."},"skills_sh_url":"https://skills.sh/likweitan/abap-skills/odata"},"updatedAt":"2026-04-24T01:03:16.792Z"}}