Discoverable Procedures

These procedures are created automatically when you discover specific entities. Each discovery creates three types of procedures for that entity.

Discovery Process

Command: discover "[SERVICE_NAME]/[ENTITY_NAME]" from sap

Example:

discover "API_SALES_ORDER_SRV/A_SalesOrder" from sap

After discovery, you can use the three generated procedures for that entity:

Entity Name Normalization

When you discover an entity, the system automatically converts the technical SAP entity name into a more user-friendly format for use in your procedures.

How Normalization Works:

  • Underscores (_) are removed

  • The name becomes easier to read and type

  • The functionality remains exactly the same

Examples:

Technical Entity Name
Normalized Name
Usage in Procedures

A_SalesOrder

ASalesOrder

retrieve some ASalesOrder records from sap

C_MfgQualifnCertBPAssgmt

CMfgQualifnCertBPAssgmt

retrieve some CMfgQualifnCertBPAssgmt records from sap

Warehouse

Warehouse

retrieve some Warehouse records from sap

Finding the Normalized Name:

  1. When you run retrieve some entities from sap, look for the "reference" field in the results

  2. This shows you exactly what name to use in your procedures

  3. The "discover_call" field also shows the exact command to use

Example from entity retrieval:

{
  "technical_name": "A_SalesOrder",
  "label": "Sales Order",
  "discover_call": "discover \\"API_SALES_ORDER_SRV/A_SalesOrder\\" from sap",
  "reference": "ASalesOrder"
}

In this case, you would use ASalesOrder in your procedures after discovery.

1. Retrieve Records

Command: retrieve some [EntityName] records from sap

Purpose: Get a list of records from the discovered entity.

Optional Parameters:

  • the limit is [NUMBER] - Maximum number of records to retrieve. IMPORTANT: We advise setting a limit when we know a certain entity can have a large quantity of records, since returning all of them can cause the UI to crash.

  • the offset is [NUMBER] - Number of records to skip (for pagination)

This procedure follows the filtering way of other KLang procedures. You can use a whose clause to define the property to filter by.

Examples:

# Get all records
retrieve some ASalesOrder records from sap

# Get first 10 records
retrieve some ASalesOrder records from sap
  the limit is 10

# Get records with pagination
retrieve some Warehouse records from sap
  the limit is 10
  the offset is 20
  
# Get records with filter
retrieve some APurchaseOrder records from sap whose PurchaseOrder is "4500002032"
 the limit is 10

Returns: A list of records from the SAP entity.


2. Create Records

Command: create a [EntityName] record in sap

Purpose: Create a new record in the discovered entity.

Required Parameters:

  • the body is [DATA] - The data for the new record

Example:

# First, create the data structure
create a json
use the above as the body
the body's "SalesOrderType" is "OR"
the body's "SalesOrganization" is "1710"
the body's "DistributionChannel" is "10"
the body's "SoldToParty" is "17100002"

# Then create the record
create a ASalesOrder record in sap
  the body is the body

Returns: The newly created record with all fields populated, including system-generated values.

3. Update Records

WARNING: As this is not part of the core Amgen POV, this was implemented in the beginning but has not been thoroughly tested as create and retrieve

Command: update a [EntityName] record in sap

Purpose: Update an existing record in the discovered entity.

Required Parameters:

  • the body is [DATA] - The data to update (must include the record ID as it comes from the create and retrieve procedures)

Example:

# Update a previously created record
use the above as the created order
set the created order's "PurchaseOrderByCustomer" to "new-po-number"

update a ASalesOrder record in sap
  the body is the created order

Returns: The updated record data.

Important Notes:

  • Entities with complex keys as id are not yet supported

  • Update of nested entities is not yet supported.

  • The record data must include an id field to identify which record to update

  • Only the fields that have changed will be sent to SAP

  • The system uses concurrency control to prevent conflicts

Last updated

Was this helpful?