Implementing Prompt Templates in ABAP AI SDK via ISL Scenario Model
ByAinvest
Friday, Jul 11, 2025 1:22 pm ET2min read
SAP--
Understanding Prompt Templates
Prompt templates serve as the foundation for generating prompts for language models. They allow for the inclusion of dynamic variables, making the generated text more personalized and relevant. The ABAP AI SDK provides robust tools to manage and utilize these templates efficiently.
Implementing Prompt Templates in ABAP AI SDK
To integrate prompt templates within the ABAP AI SDK, developers need to follow a specific process. First, they must add the prompt templates to the Intelligent Scenario Model (ISLM) artifact in Eclipse (ADT). This can be achieved by defining the parameters using a specific format, such as `{ISLM_name of the variable}`.
Code Example
The following code snippet demonstrates how to add prompt templates and generate descriptions using the ABAP AI SDK classes:
```abap
METHOD generate_description.
TRY.
FINAL(api) = cl_aic_islm_compl_api_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' ).
CATCH cx_aic_api_factory INTO DATA(lx_api).
rv_description = ''.
ENDTRY.
TRY.
FINAL(prompt_template_instance) = cl_aic_islm_prompt_tpl_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' template_id = 'CITY_DESC' ).
FINAL(prompt_template_instance2) = cl_aic_islm_prompt_tpl_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' template_id = 'SYS_ROLE' ).
CATCH cx_aic_api_factory INTO DATA(lx_api1).
rv_description = ''.
ENDTRY.
IF ( prompt_template_instance IS BOUND ).
TRY.
FINAL(prompt) = prompt_template_instance-get_prompt( parameters = VALUE #( ( name = 'ISLM_city' value = iv_city ) ) ).
FINAL(sys_role_prompt) = prompt_template_instance2-get_prompt( ).
CATCH cx_aic_prompt_template INTO DATA(lx_prompt_templ).
"handle exception
ENDTRY.
ENDIF.
IF ( api IS BOUND ).
TRY.
DATA(messages) = api-create_message_container( ).
messages-set_system_role( sys_role_prompt ).
messages-add_user_message( prompt ).
rv_description = api-execute_for_messages( messages )-get_completion( ).
CATCH cx_aic_completion_api INTO DATA(lx_completion).
rv_description = ''.
ENDTRY.
ENDIF.
ENDMETHOD.
```
Conclusion
By integrating prompt templates into the ABAP AI SDK via ISLM using Eclipse (ADT), financial professionals can significantly enhance the capabilities of their AI models. This approach allows for the generation of more accurate and contextually relevant descriptions, which can be crucial for decision-making processes in the financial sector. The provided code example offers a practical guide on how to implement this functionality, ensuring that AI models can be effectively utilized to meet the specific needs of financial professionals.
References
[1] SAP Community. "How to Use Prompt Templates in ABAP AI SDK via ISLM Scenario." Retrieved from https://community.sap.com/t5/technology-blog-posts-by-sap/how-to-use-prompt-templates-in-abap-ai-sdk-via-islm-scenario/ba-p/14150585
[2] LangChain. "PromptTemplate." Retrieved from https://python.langchain.com/api_reference/core/prompts/langchain_core.prompts.prompt.PromptTemplate.html
The article explains how to use Prompt Templates in ABAP AI SDK via ISL using Eclipse (ADT). It provides a code example of how to add Prompt Templates in the Intelligent Scenario Model artefact and access them using the ABAP AI SDK classes. The code example demonstrates how to retrieve prompt templates and generate descriptions using the SDK classes.
In the rapidly evolving landscape of artificial intelligence, leveraging prompt templates has become a crucial aspect of enhancing the capabilities of AI models. This article explores how to effectively utilize prompt templates in the ABAP AI SDK via the Intelligent Scenario Model (ISLM) using Eclipse (ADT). By following a structured approach, financial professionals can harness the power of AI to generate more accurate and contextually relevant descriptions.Understanding Prompt Templates
Prompt templates serve as the foundation for generating prompts for language models. They allow for the inclusion of dynamic variables, making the generated text more personalized and relevant. The ABAP AI SDK provides robust tools to manage and utilize these templates efficiently.
Implementing Prompt Templates in ABAP AI SDK
To integrate prompt templates within the ABAP AI SDK, developers need to follow a specific process. First, they must add the prompt templates to the Intelligent Scenario Model (ISLM) artifact in Eclipse (ADT). This can be achieved by defining the parameters using a specific format, such as `{ISLM_name of the variable}`.
Code Example
The following code snippet demonstrates how to add prompt templates and generate descriptions using the ABAP AI SDK classes:
```abap
METHOD generate_description.
TRY.
FINAL(api) = cl_aic_islm_compl_api_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' ).
CATCH cx_aic_api_factory INTO DATA(lx_api).
rv_description = ''.
ENDTRY.
TRY.
FINAL(prompt_template_instance) = cl_aic_islm_prompt_tpl_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' template_id = 'CITY_DESC' ).
FINAL(prompt_template_instance2) = cl_aic_islm_prompt_tpl_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' template_id = 'SYS_ROLE' ).
CATCH cx_aic_api_factory INTO DATA(lx_api1).
rv_description = ''.
ENDTRY.
IF ( prompt_template_instance IS BOUND ).
TRY.
FINAL(prompt) = prompt_template_instance-get_prompt( parameters = VALUE #( ( name = 'ISLM_city' value = iv_city ) ) ).
FINAL(sys_role_prompt) = prompt_template_instance2-get_prompt( ).
CATCH cx_aic_prompt_template INTO DATA(lx_prompt_templ).
"handle exception
ENDTRY.
ENDIF.
IF ( api IS BOUND ).
TRY.
DATA(messages) = api-create_message_container( ).
messages-set_system_role( sys_role_prompt ).
messages-add_user_message( prompt ).
rv_description = api-execute_for_messages( messages )-get_completion( ).
CATCH cx_aic_completion_api INTO DATA(lx_completion).
rv_description = ''.
ENDTRY.
ENDIF.
ENDMETHOD.
```
Conclusion
By integrating prompt templates into the ABAP AI SDK via ISLM using Eclipse (ADT), financial professionals can significantly enhance the capabilities of their AI models. This approach allows for the generation of more accurate and contextually relevant descriptions, which can be crucial for decision-making processes in the financial sector. The provided code example offers a practical guide on how to implement this functionality, ensuring that AI models can be effectively utilized to meet the specific needs of financial professionals.
References
[1] SAP Community. "How to Use Prompt Templates in ABAP AI SDK via ISLM Scenario." Retrieved from https://community.sap.com/t5/technology-blog-posts-by-sap/how-to-use-prompt-templates-in-abap-ai-sdk-via-islm-scenario/ba-p/14150585
[2] LangChain. "PromptTemplate." Retrieved from https://python.langchain.com/api_reference/core/prompts/langchain_core.prompts.prompt.PromptTemplate.html

Stay ahead of the market.
Get curated U.S. market news, insights and key dates delivered to your inbox.
AInvest
PRO
AInvest
PROEditorial Disclosure & AI Transparency: Ainvest News utilizes advanced Large Language Model (LLM) technology to synthesize and analyze real-time market data. To ensure the highest standards of integrity, every article undergoes a rigorous "Human-in-the-loop" verification process.
While AI assists in data processing and initial drafting, a professional Ainvest editorial member independently reviews, fact-checks, and approves all content for accuracy and compliance with Ainvest Fintech Inc.’s editorial standards. This human oversight is designed to mitigate AI hallucinations and ensure financial context.
Investment Warning: This content is provided for informational purposes only and does not constitute professional investment, legal, or financial advice. Markets involve inherent risks. Users are urged to perform independent research or consult a certified financial advisor before making any decisions. Ainvest Fintech Inc. disclaims all liability for actions taken based on this information. Found an error?Report an Issue

Comments
No comments yet