Publish events to Cloud Run functions

The document describes how to publish events to Cloud Run functions through the Business Eventing Toolkit for SAP.

Prerequisites

Make sure that you or your administrators have completed the following prerequisites:

  • Enabled the Cloud Run functions API. For information about how to enable Google Cloud APIs, see Enabling APIs.
  • Configured a client key for authentication. For information about how to set up authentication in the on-premises or any cloud edition of ABAP SDK for Google Cloud, see Authentication overview.
  • The service account configured in the client key for authentication must have the following roles:

  • Configure target Google Cloud services with the following details:

    • Event Processor Class: /GOOG/CL_PUBLISHER_CLOUDFUNC
    • Google Cloud Key Name: The client key for authentication.
    • Event Parameter 1: The name of the Cloud Run functions.
    • Event Parameter 2: The location of the Cloud Run functions.
    • Event Parameter 3: Optional. The HTTP method used. For example, GET, POST. If not provided, then the default is GET.

    For information about how to configure target Google Cloud services, see Configure target Google Cloud services.

Publish events

To publish event data to Cloud Run functions, call the publish() method:

DATA: lt_data TYPE /goog/if_ce_publisher=>tt_messages.


" Write logic to populate LT_DATA.
lt_data = VALUE #( ( data = 'Hello World!' ) ).

/goog/cl_event_publisher=>publish_event(
      EXPORTING
        iv_event_key = 'EVENT_KEY'
        it_data      = lt_data
      IMPORTING
        et_output    = DATA(lt_output)
    ev_ret_code  = DATA(lv_ret_code)
ev_err_text  = DATA(lv_err_text)
).

Replace EVENT_KEY with the event key configured for publishing events to Cloud Run functions.

To send an event as a CloudEvent, you can configure the Cloud Event Default Attribute Key and attach this key to your Event key when configuring the target Google Cloud services. The Business Eventing Toolkit for SAP then picks up the default attribute values for the CloudEvent.