Send Messages to an ERP System Via REST APIs

Before you begin

Procedure

  1. The ERP Scheduler service provides the ability to POST various entities into the Integration Database. To access the user interface, follow the instructions in Plant Applications REST APIs. Refer to Swagger URLs of Rest Services for the ERP Scheduler Service's URL (as well as the URLs for all other services).
  2. Authorize to the ERP Scheduler Service.
    1. Follow the steps in Authorize to the ERP Scheduler Service.
    2. Additionally you will require the client id and and client secret configured during installation. See Access the Plant Applications REST APIs.
  3. Refer to the erp-scheduler-service documentation for the specification of the controllers used for importing the entities materials, material lots, outside processing, process orders and work orders.
  4. Each controller requires a message string as an input.  The message string is the import document (listed with links below) with all JSON String Escape characters.
  5. The response from each POST returns a jobID.  Immediately the response code and message will have no value.  The POST begins the ERP import request by adding data to the integration table, where it will wait to be processed.  The ERP scheduler uses a polling time interval (erp.scheduler.service.importJobPoll.milliseconds) to search for new jobs to process from the integration table. The ERP scheduler will process the jobs and when the processing is successful, the response of that processing can be found by either of the following:
    • Requesting a status by Job ID from the service
      • GET https://<FQDN or Hostname>/erpscheduler-service/importOrders/importedJobs?jobIds=[JobIDs]
    • Subscribing to the kafka topic mes.erp.inbound.messages
      • Kafka Payload Structure:
        {
          "jobId": 234,  
          "messageType": "Workorder",
          "mediaType": "application/json",
         "keyData" :"WO_Import_Test"
          "responseCode": "200",
          "responseMessage": "Work Order imported Successfully",
          "insertedBy": "ErpUser",
          "insertedDate": "2021-03-20T13:28:39Z",
          "processStartDate": "2021-03-20T13:28:42Z",
          "processCompletionDate": "2021-03-20T13:28:55Z"
        }
      • Kafka Headers Structure:
        {
          "PARTITION_ID": "234",  
          "event-aggregate-type": "mes.erp.inbound.messages",
          "DATE": "Sat, 20 Mar 2021 13:28:56 GMT",
          "event-aggregate-id": "234",
          "event-type": "mes.erp.inbound.messages.RequestProcessedEvent",
          "DESTINATION": "mes.erp.inbound.messages",
          "ID": "00000176e6321a7b-0242ac12001c0000"
        }
      • Kafka Message Structure Example:
        {"payload":"{\r\n \"jobId\": 234, \r\n \"messageType\": \"Workorder\", \r\n \"mediaType\": \"application/json\",\r\n \"keyData\" :\"WO_Import_Test\"\r\n \"responseCode\": \"200\",\r\n \"responseMessage\": \"Work Order imported Successfully\",\r\n \"insertedBy\": \"User\",\r\n \"insertedDate\": \"2021-03-20T13:28:39Z\",\r\n \"processStartDate\": \"2021-03-20T13:28:42Z\",\r\n \"processCompletionDate\": \"2021-03-20T13:28:55Z\"\r\n}","headers":{\r\n \"PARTITION_ID\": \"234\",\r\n \"event-aggregate-type\": \"mes.erp.inbound.messages\",\r\n \"DATE\": \"Sat, 20 Mar 2021 13:28:56 GMT\",\r\n \"event-aggregate-id\": \"234\",\r\n \"event-type\": \"mes.erp.inbound.message.RequestProcessedEvent\",\r\n \"DESTINATION\": \"mes.erp.inbound.messages\",\r\n \"ID\": \"00000176e6321a7b-0242ac12001c0000\"\r\n}
        
    Either method will provide the final status of the ERP import request by providing the response code and response message for each job ID. For further analysis, a controller is available to retrieve the full import request message by job ID:
    • GET https://<FQDN or Hostname>/erpscheduler-service/importOrders/importedJobs/<jobID>/message