Skip to main content

Actions

The ballerinax/sap.s4hana.salesarea_0001 package exposes the following clients:

ClientPurpose
ClientRetrieves SAP Sales Area master data via the SAP S/4HANA OData API.

Client

Retrieves SAP Sales Area master data via the SAP S/4HANA OData API.

Configuration

FieldTypeDefaultDescription
authhttp:CredentialsConfigRequiredHTTP Basic Authentication credentials; provide username and password of the SAP technical user.
httpVersionhttp:HttpVersionHTTP_2_0HTTP protocol version to use for requests.
http1SettingsClientHttp1Settings()HTTP/1.x client settings including keep-alive and chunking.
http2Settingshttp:ClientHttp2Settings()HTTP/2 client settings.
timeoutdecimal60Request timeout in seconds.
forwardedstring"disable"Whether to forward X-Forwarded-* headers.
retryConfighttp:RetryConfig()Retry configuration for transient failures.
circuitBreakerhttp:CircuitBreakerConfig()Circuit breaker configuration.
secureSockethttp:ClientSecureSocket()SSL/TLS configuration for secure connections.
proxyhttp:ProxyConfig()HTTP proxy configuration.
validationbooleantrueEnable or disable response payload validation.

Initializing the client

import ballerinax/sap.s4hana.salesarea_0001 as salesarea;

configurable string hostname = ?;
configurable string username = ?;
configurable string password = ?;

salesarea:Client salesareaClient = check new (
{
auth: {
username: username,
password: password
}
},
hostname
);

Operations

Sales area retrieval

listSalesAreas

Retrieves a collection of all Sales Area records, with optional OData query parameters for filtering, sorting, and pagination.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP headers to include in the request.
queriesListSalesAreasQueriesNoOData query options: $skip (int), $top (int), $filter (string), $orderby (SalesAreaOrderByOptions), $count (boolean), $select (SalesAreaSelectOptions).

Returns: CollectionOfSalesArea|error

Sample code:

salesarea:CollectionOfSalesArea result = check salesareaClient->listSalesAreas(
queries = {"\$top": "10", "\$filter": "SalesOrganization eq '1000'", "\$count": "true"}
);

Sample response:

{
"@odata.count": 3,
"value": [
{
"SalesOrganization": "1000",
"DistributionChannel": "10",
"Division": "00"
},
{
"SalesOrganization": "1000",
"DistributionChannel": "10",
"Division": "01"
},
{
"SalesOrganization": "1000",
"DistributionChannel": "20",
"Division": "00"
}
]
}
getSalesArea

Retrieves a single Sales Area record identified by its composite key: Sales Organization, Distribution Channel, and Division.

Parameters:

NameTypeRequiredDescription
SalesOrganizationstringYesThe Sales Organization code (up to 4 characters, e.g., "1000").
DistributionChannelstringYesThe Distribution Channel code (up to 2 characters, e.g., "10").
DivisionstringYesThe Division code (up to 2 characters, e.g., "00").
headersmap<string|string[]>NoAdditional HTTP headers to include in the request.
queriesGetSalesAreaQueriesNoOData query options: $select to limit returned fields.

Returns: SalesArea|error

Sample code:

salesarea:SalesArea salesArea = check salesareaClient->getSalesArea(
"1000",
"10",
"00"
);

Sample response:

{
"SalesOrganization": "1000",
"DistributionChannel": "10",
"Division": "00"
}

Batch operations

performBatchOperation

Executes an OData batch request, allowing multiple read operations to be combined into a single HTTP call for improved efficiency.

Parameters:

NameTypeRequiredDescription
requesthttp:RequestYesAn http:Request object containing the multipart OData batch body with individual operations.
headersmap<string|string[]>NoAdditional HTTP headers to include in the batch request.

Returns: http:Response|error

Sample code:

http:Request batchRequest = new;
string batchBody = string `--batch_1
Content-Type: application/http
Content-Transfer-Encoding: binary

GET SalesArea('1000','10','00') HTTP/1.1


--batch_1--`;
batchRequest.setPayload(batchBody, "multipart/mixed;boundary=batch_1");
http:Response batchResponse = check salesareaClient->performBatchOperation(batchRequest);

Sample response:

--batchresponse_abc123
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 200 OK
Content-Type: application/json

{"SalesOrganization":"1000","DistributionChannel":"10","Division":"00"}
--batchresponse_abc123--