— SAP integration
SAP OData Query Builder
Build correct OData V2 or V4 query strings for S/4HANA services without remembering the syntax. Runs in your browser — nothing is sent anywhere.
$filter
Your query
Request URL
/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder?$filter=SalesOrganization%20eq%20'1010'&$select=SalesOrder,SoldToParty,TotalNetAmount&$orderby=SalesOrder%20desc&$top=50&$format=json
CPI OData receiver — Query Options
$filter=SalesOrganization eq '1010'&$select=SalesOrder,SoldToParty,TotalNetAmount&$orderby=SalesOrder desc&$top=50&$format=json
ABAP sample (SM59 destination)
" Sample only. GET requests need no CSRF token; POST/PUT/DELETE must " first fetch one (header X-CSRF-Token: Fetch) and send it back. DATA lo_client TYPE REF TO if_http_client. DATA lv_path TYPE string VALUE '/A_SalesOrder?$filter=SalesOrganization%20eq%20''1010''&$select=SalesOrder,SoldToParty,TotalNetAmount&$orderby=SalesOrder%20desc&$top=50&$format=json'. " Recommended: SM59 destination (Z_ODATA_DEST is a placeholder name). cl_http_client=>create_by_destination( EXPORTING destination = 'Z_ODATA_DEST' IMPORTING client = lo_client EXCEPTIONS OTHERS = 1 ). " Without a destination: cl_http_client=>create_by_url( url = '/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder?$filter=SalesOrganization%20eq%20''1010''&$select=SalesOrder,SoldToParty,TotalNetAmount&$orderby=SalesOrder%20desc&$top=50&$format=json' ... ). IF sy-subrc <> 0. RETURN. " destination missing or not reachable ENDIF. cl_http_utility=>set_request_uri( request = lo_client->request uri = lv_path ). lo_client->request->set_method( if_http_request=>co_request_method_get ). lo_client->request->set_header_field( name = 'Accept' value = 'application/json' ). lo_client->send( EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. lo_client->close( ). RETURN. ENDIF. lo_client->receive( EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. lo_client->get_last_error( IMPORTING message = DATA(lv_error) ). lo_client->close( ). RETURN. ENDIF. lo_client->response->get_status( IMPORTING code = DATA(lv_status) ). DATA(lv_json) = lo_client->response->get_cdata( ). lo_client->close( ). IF lv_status <> 200. " lv_json holds the OData error body — log it, do not treat as data. RETURN. ENDIF.
Frequently asked questions
- What is the difference between OData V2 and V4 filters?
- V2 uses substringof() for text search, datetime'…' and guid'…' literals, and $inlinecount=allpages for counts. V4 uses contains(), bare date and GUID literals, and $count=true. The builder switches syntax when you change the version.
- Where do I paste the CPI output?
- In the OData receiver adapter's Query Options field (or the query wizard), without the leading question mark.
- Does this tool call my SAP system?
- No. Everything runs in your browser. Nothing is sent to ERPClimb or to SAP.
Check entity and property names against your service's $metadata. ERPClimb is independent and not affiliated with SAP SE.