Artificial Intelligence and Machine Learning Blogs
Explore AI and ML blogs. Discover use cases, advancements, and the transformative potential of AI for businesses. Stay informed of trends and applications.
cancel
Showing results for 
Search instead for 
Did you mean: 
monalisa_biswal
Contributor
6,233
Introduction

This blog is a follow-up to my previously published blog A Cool use of Open AI in SAP GUI Editor | SAP Blogs.

Thanks for all the feedback on this blog.

Two of them were really important:

  • How to have similar integration done from Eclipse as most of SAP Developments happen in Eclipse

  • How can we trust the accuracy of code generation done by AI


Here is the link to my eclipse plugin which can work on text editor-based developments and help auto generate code like we saw in SAP GUI. AI Developer Plugin for Eclipse (github.com)

(The plugin is in experimental stage and will get better with your feedback.)

Writing a good prompt is really important to work with generative AI:

Please refer this Prompt engineering techniques with Azure OpenAI - Azure OpenAI Service | Microsoft Learn for some tips on constructing a good prompt.

The plugin is leveraging Chat Completion Api of Azure OpenAI and code generation is relying on codex model and how well prompt is articulated for AI engine.

Chat Completion takes two components for generating response: System Message and User Message.

System Message: It guides the assistant's behavior. In this case it is setup to work as an AI Assistant to generate code for SAP based developments.

User Message: In this, we provide the actual queries to get the response from AI Assistant.

A query can be a short query with random or creative answers from the assistant. or well constructed to get more definite answers


















Sample Query Sample AI Answer Answer behavior
Write a sql query to read customer details. SELECT kunnr, name1, city, country
FROM kna1
INTO TABLE @DATA(customer_details).
AI will respond with some random query. It may or may not work for your case. But you can use this to try and explore which option works for your case.
Write a SQL query to read customerno name street city state
use following technical field names
kunnr name1 stras ort01 regio
from KNA1
SELECT kunnr AS customerno, name1 AS name, stras AS street, ort01 AS city, regio AS state
FROM kna1.
A more definite answer

How to Install this plugin

AI-Developer-Plugin-for-Eclipse (github.com) Github has the archive file and a step by step document to guide you through the installation process.

After you install this plugin

You will get this menu in your eclipse.


 

How to Use this plugin

  1. Give a sample text as requirement.  Press CTRL + 8 or Generate code from the menu to suggest code for the requirement.

  2. You can provide multiple lines surrounded with #START #END or select the lines you want to pass to prompt.

  3. Provide #Describe in the comment to ask ai to explain the code in the form of abap comment

  4. Generate a Template from existing code by giving #TEMPLATE#<TEMP_NAME> and selecting code, then pressing Ctrl+4 or Generate Template. Then reuse your existing code in another program by giving this text Use #TEMPLATE#<TEMP_NAME> with additional requirement and Ctrl +8 and Generate Code.


Some Sample Demos

Create an ABAP report to write data from an SAP table to a comma separated text file on your local system. Provide clear instructions on the program flow like below:
*#START
*Define a select options to take input for customer KNA1-KUNNR and a parameter(p_file) to take local file path as input
*Provide field names with table to declare a structure
*Declare a type with fields and internal table
*customer street city state
*kunnr stras ort01 regio
*from KNA1
*select data from KNA1 to this internal table
*looping in the internal table generate comma separated text and add the text to an internal table
*download this table to the file given in the input
*#END



Now let's change this program to generate a json string in the file. Locate the loop where it is generating comma separated text and add line below that section. Highlight the code block for loop alongwith below text and press Ctrl + 8 to ask open ai to suggest code for json file download.
 *Rewrite above code to concatenate fields from it_customer in json format.



Using Template function, you can generate a template file from existing code. Then you can apply the template file to generate code for similar requirement in a different development object. Below demo shows first how to create a template from an alv report then use the same for generating another report.



Reference:

Getting started with the ABAP in Eclipse SDK | SAP Blogs

Conclusion

While existing open ai codex model is not fully trained on SAP language, still with good prompts you can automate lot of manual efforts. With generate template option you can leverage your existing codebase and also learn how to write a good prompt.

Hope this plugin helps with your AI learning journey.

 

 

 
2 Comments
Top kudoed authors