This quickstart shows you how to call Vertex AI Agents, built
with the Agent Development Kit (ADK), from your ABAP environment.
This guide explains the process of calling an AI agent by using the on-premises or any cloud edition of ABAP SDK for Google Cloud,
and does not cover
creation or deployment procedures. You create an AI agent using the
Agent Development Kit (ADK), which is an
open-source framework for designing agents, built on the same framework that powers
Google Agentspace and Customer Engagement Suite with Google AI.
You then deploy your agent to Vertex AI Agent Engine, which is a fully managed
runtime in Vertex AI that helps you deploy your custom agents
to production with built-in testing, release, and reliability at a global, secure scale.
Before you begin
Before you run this quickstart, make sure that you or your administrators have
completed the following prerequisites:
Created a Cloud Storage bucket to store the agent deployment files. For more information, see Create buckets.
Deploy agent to Vertex AI Agent Engine
Create, test, and deploy your agent to Vertex AI Agent Engine.
For this quickstart, you can create a weather and time agent and deploy
the agent to Vertex AI Agent Engine.
For information about how to create, test, and deploy your agent, see the following:
From the resource identifier, make a note of the REASONING_ENGINE_ID, for example, 6384464913570601984.
You need this in a later step.
Create a program to call Vertex AI Agents from ABAP environment
In the SAP system, create an executable program in your
custom namespace (for example, Z or Y) by using transaction SE38.
In the SAP GUI, enter transaction code SE38.
In the Program field, enter a name for your program,
for example, ZDEMO_CALL_AGENT.
Click Create.
Specify the program attributes:
In the Title field, enter a title of your program,
for example, Call Vertex AI Agent.
In the Type field, choose Executable Program.
Click Save.
Save the program as a Local Object.
In the ABAP Editor, add the following code:
REPORTzdemo_call_agent.DATAlv_p_projects_idTYPE string.DATAlv_p_locations_idTYPE string.DATAlv_p_reasoning_engines_idTYPE string.DATAls_inputTYPE/goog/cl_aiplatform_v1=>ty_1072.TYPES:BEGIN OFty_agent_input,messageTYPE string,session_idTYPE string,user_idTYPE string,END OFty_agent_input.DATAls_agent_inputTYPE ty_agent_input.TYPES:BEGIN OFty_response,contentTYPE/goog/cl_aiplatform_v1=>ty_695,END OFty_response.DATAls_agent_responseTYPE ty_response.TRY." Open HTTP ConnectionDATA(lo_client)=NEW/goog/cl_aiplatform_v1(iv_key_name='DEMO_AIPLATFORM').DATAlv_agent_response_txtTYPE string." Populate relevant parameterslv_p_projects_id=lo_client->gv_project_id.lv_p_locations_id='LOCATION_ID'.lv_p_reasoning_engines_id='REASONING_ENGINE_ID'.ls_agent_input-message='What is the weather in New York'."Promptls_agent_input-user_id='use-101'.ls_input-class_method='stream_query'.GET REFERENCE OFls_agent_inputINTOls_input-input.lo_client->add_json_name_mapping(iv_abap='CLASS_METHOD'iv_json='class_method').lo_client->add_json_name_mapping(iv_abap='SESSION_ID'iv_json='session_id').lo_client->add_json_name_mapping(iv_abap='USER_ID'iv_json='user_id')." Call API method: aiplatform.projects.locations.reasoningEngines.streamQuerylo_client->stream_query_reasoning_engi(EXPORTINGiv_p_projects_id=lv_p_projects_idiv_p_locations_id=lv_p_locations_idiv_p_reasoning_engines_id=lv_p_reasoning_engines_idis_input=ls_inputIMPORTINGes_raw=lv_agent_response_txtev_ret_code=DATA(lv_ret_code)ev_err_text=DATA(lv_err_text)es_err_resp=DATA(ls_err_resp))." Handle the outputIFlo_client->is_success(lv_ret_code).SPLITlv_agent_response_txtATcl_abap_char_utilities=>newlineINTOTABLEDATA(lt_result_event_tab)." Deserialize to read the final response event from agent/goog/cl_json_util=>deserialize_json(EXPORTINGiv_json=lt_result_event_tab[3]iv_pretty_name=/ui2/cl_json=>pretty_mode-extendedIMPORTINGes_data=ls_agent_response).cl_demo_output=>display(ls_agent_response-content-parts[1]-text).ELSE.MESSAGElv_err_textTYPE'E'.ENDIF." Close HTTP Connectionlo_client->close().CATCH/goog/cx_sdkINTODATA(lo_exception).MESSAGElo_exception->get_text()TYPE'E'.ENDTRY.
Replace the following:
DEMO_AIPLATFORM: The client key for authentication to Google Cloud.
LOCATION_ID: The location where the agent is deployed. You specify the location when you initialize the agent. For more information, see Initialize the agent.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["# Call Vertex AI Agents from ABAP environment\n\n\u003cbr /\u003e\n\nThis quickstart shows you how to call Vertex AI Agents, built\nwith the [Agent Development Kit (ADK)](https://google.github.io/adk-docs), from your ABAP environment.\n\nThis guide explains the process of calling an AI agent by using the on-premises or any cloud edition of ABAP SDK for Google Cloud,\nand does not cover\ncreation or deployment procedures. You create an AI agent using the\n[Agent Development Kit (ADK)](https://google.github.io/adk-docs), which is an\nopen-source framework for designing agents, built on the same framework that powers\n[Google Agentspace](/products/agentspace) and [Customer Engagement Suite with Google AI](/solutions/customer-engagement-ai).\nYou then deploy your agent to Vertex AI Agent Engine, which is a fully managed\nruntime in Vertex AI that helps you deploy your custom agents\nto production with built-in testing, release, and reliability at a global, secure scale.\n\nBefore you begin\n----------------\n\n\nBefore you run this quickstart, make sure that you or your administrators have\ncompleted the following prerequisites:\n\n- You have a Google Cloud account and project.\n\n- Billing is enabled for your project. [See how to confirm that billing is enabled for your project](/billing/docs/how-to/verify-billing-enabled).\n\n- The on-premises or any cloud edition of ABAP SDK for Google Cloud is installed and configured. [See how to install and configure the on-premises or any cloud edition of ABAP SDK for Google Cloud](/sap/docs/abap-sdk/on-premises-or-any-cloud/latest/install-config).\n\n\u003cbr /\u003e\n\n- Authentication to access Google Cloud APIs is set up. [See how to set up authentication](/sap/docs/abap-sdk/on-premises-or-any-cloud/latest/authentication).\n\n- Make sure the Vertex AI API is enabled in your Google Cloud project.\n\n [Go to API library](https://console.cloud.google.com/project/_/apis/library/aiplatform.googleapis.com)\n- Created a [Cloud Storage](/storage) bucket to store the agent deployment files. For more information, see [Create buckets](/storage/docs/creating-buckets).\n\nDeploy agent to Vertex AI Agent Engine\n--------------------------------------\n\nCreate, test, and deploy your agent to Vertex AI Agent Engine.\nFor this quickstart, you can create a **weather and time agent** and deploy\nthe agent to Vertex AI Agent Engine.\n\nFor information about how to create, test, and deploy your agent, see the following:\n\n- [Create your agent](https://google.github.io/adk-docs/deploy/agent-engine/#create-your-agent)\n- [Try your agent locally](https://google.github.io/adk-docs/deploy/agent-engine/#try-your-agent-locally)\n- [Deploy your agent to Agent Engine](https://google.github.io/adk-docs/deploy/agent-engine/#deploy-your-agent-to-agent-engine)\n\nMake sure that you've granted the [required permissions](https://google.github.io/adk-docs/deploy/agent-engine/#grant-the-deployed-agent-permissions) for the agent to use managed sessions.\n\nAfter deployment, you get a resource identifier similar to the following example,\nwhich enables agent invocation within your ABAP program: \n\n```\nAgentEngine created. Resource name: projects/project_id/locations/us-central1/reasoningEngines/REASONING_ENGINE_ID\n```\n\nFrom the resource identifier, make a note of the \u003cvar translate=\"no\"\u003eREASONING_ENGINE_ID\u003c/var\u003e, for example, `6384464913570601984`.\nYou need this in a later step.\n\nCreate a program to call Vertex AI Agents from ABAP environment\n---------------------------------------------------------------\n\n1. In the SAP system, create an executable program in your\n custom namespace (for example, Z or Y) by using transaction `SE38`.\n\n 1. In the SAP GUI, enter transaction code `SE38`.\n\n 2. In the **Program** field, enter a name for your program,\n for example, `ZDEMO_CALL_AGENT`.\n\n 3. Click **Create**.\n\n 4. Specify the program attributes:\n\n 1. In the **Title** field, enter a title of your program,\n for example, `Call Vertex AI Agent`.\n\n 2. In the **Type** field, choose `Executable Program`.\n\n 3. Click **Save**.\n\n 5. Save the program as a **Local Object**.\n\n 6. In the **ABAP Editor**, add the following code:\n\n REPORT zdemo_call_agent.\n\n DATA lv_p_projects_id TYPE string.\n DATA lv_p_locations_id TYPE string.\n DATA lv_p_reasoning_engines_id TYPE string.\n DATA ls_input TYPE /goog/cl_aiplatform_v1=\u003ety_1072.\n\n TYPES: BEGIN OF ty_agent_input,\n message TYPE string,\n session_id TYPE string,\n user_id TYPE string,\n END OF ty_agent_input.\n\n DATA ls_agent_input TYPE ty_agent_input.\n\n TYPES: BEGIN OF ty_response,\n content TYPE /goog/cl_aiplatform_v1=\u003ety_695,\n END OF ty_response.\n DATA ls_agent_response TYPE ty_response.\n\n TRY.\n\n \" Open HTTP Connection\n DATA(lo_client) = NEW /goog/cl_aiplatform_v1( iv_key_name = '\u003cvar class=\"edit\" translate=\"no\"\u003eDEMO_AIPLATFORM\u003c/var\u003e' ).\n DATA lv_agent_response_txt TYPE string.\n\n \" Populate relevant parameters\n lv_p_projects_id = lo_client-\u003egv_project_id.\n lv_p_locations_id = '\u003cvar class=\"edit\" translate=\"no\"\u003eLOCATION_ID\u003c/var\u003e'.\n lv_p_reasoning_engines_id = '\u003cvar class=\"edit\" translate=\"no\"\u003eREASONING_ENGINE_ID\u003c/var\u003e'.\n\n ls_agent_input-message = 'What is the weather in New York'. \"Prompt\n ls_agent_input-user_id = 'use-101'.\n ls_input-class_method = 'stream_query'.\n GET REFERENCE OF ls_agent_input INTO ls_input-input.\n\n lo_client-\u003eadd_json_name_mapping( iv_abap = 'CLASS_METHOD' iv_json = 'class_method' ).\n lo_client-\u003eadd_json_name_mapping( iv_abap = 'SESSION_ID' iv_json = 'session_id' ).\n lo_client-\u003eadd_json_name_mapping( iv_abap = 'USER_ID' iv_json = 'user_id' ).\n\n \" Call API method: aiplatform.projects.locations.reasoningEngines.streamQuery\n lo_client-\u003estream_query_reasoning_engi( EXPORTING iv_p_projects_id = lv_p_projects_id\n iv_p_locations_id = lv_p_locations_id\n iv_p_reasoning_engines_id = lv_p_reasoning_engines_id\n is_input = ls_input\n IMPORTING es_raw = lv_agent_response_txt\n ev_ret_code = DATA(lv_ret_code)\n ev_err_text = DATA(lv_err_text)\n es_err_resp = DATA(ls_err_resp) ).\n\n \" Handle the output\n IF lo_client-\u003eis_success( lv_ret_code ).\n SPLIT lv_agent_response_txt AT cl_abap_char_utilities=\u003enewline INTO TABLE DATA(lt_result_event_tab).\n\n \" Deserialize to read the final response event from agent\n /goog/cl_json_util=\u003edeserialize_json( EXPORTING iv_json = lt_result_event_tab[ 3 ]\n iv_pretty_name = /ui2/cl_json=\u003epretty_mode-extended\n IMPORTING es_data = ls_agent_response ).\n\n cl_demo_output=\u003edisplay( ls_agent_response-content-parts[ 1 ]-text ).\n\n ELSE.\n MESSAGE lv_err_text TYPE 'E'.\n ENDIF.\n\n \" Close HTTP Connection\n lo_client-\u003eclose( ).\n\n CATCH /goog/cx_sdk INTO DATA(lo_exception).\n MESSAGE lo_exception-\u003eget_text( ) TYPE 'E'.\n ENDTRY.\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDEMO_AIPLATFORM\u003c/var\u003e: The client key for authentication to Google Cloud.\n - \u003cvar translate=\"no\"\u003eLOCATION_ID\u003c/var\u003e: The location where the agent is deployed. You specify the location when you initialize the agent. For more information, see [Initialize the agent](https://google.github.io/adk-docs/deploy/agent-engine/#initialization).\n - \u003cvar translate=\"no\"\u003eREASONING_ENGINE_ID\u003c/var\u003e: The resource identifier for the agent that you've noted in the [Deploy agent to Vertex AI Agent Engine](#deploy-agent-to-vertex-ai-agent-engine) section.\n2. Run your application in `SE38`.\n\n3. Validate that the results are consistent with those observed when the agent was run locally.\n\n ```\n Example response: OK. The weather in New York is sunny with a temperature of 25 degrees Celsius (41 degrees Fahrenheit).\n ```\n\nWhat's next\n-----------\n\n\n- Explore other quickstarts available on the GitHub repository, [GoogleCloudPlatform/google-cloud-abap/abap-sdk\n /ZGOOG_SDK_QUICKSTART/](https://github.com/GoogleCloudPlatform/google-cloud-abap/tree/main/abap-sdk/ZGOOG_SDK_QUICKSTART).\n- Read the guide [Application development with the on-premises or any cloud edition of ABAP SDK for Google Cloud](/sap/docs/abap-sdk/on-premises-or-any-cloud/latest/developer).\n- View the [code samples](/sap/docs/abap-sdk/samples/all-samples#on-premises-or-any-cloud-edition).\n- Ask your questions and discuss ABAP SDK for Google Cloud with the community on [Cloud Forums](https://discuss.google.dev/tags/c/google-cloud/14/abap-sdk).\n\n\u003cbr /\u003e"]]