Technology Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
Paul-White
Advisor
Advisor
1,954

This blog gives an example of where generative A.I. can be used to develop code for something. This is a use case where A.I. is used to train the programmer and where A.I. can used to create value for both individuals (improve programming capability, inspire creativity), and society with the end result (production of value to others).

In this example, we use generative A.I. to create a shell script that produces and appends to a basic html table. This blog provides feedback from the experience completing the task and aims to inspire others to get creative. The resulting code is intellectual property and not shared nor is it important to the underlying point of the blog.

NOTE - this should not be a task undertaken by someone new to programming. It is not safe for you to run any kind of code without the requisite knowledge to review & debug the code. This is where you (the human) comes in: you are to safely debug (examine, correct and test) the output from the A.I.

Question 1 to A.I.

Write me some simple html code that presents a table of three columns where the left most column is sortable alphabetically. Make the code snippet easy to incorporate into a shell script that allows the user to enter the values for columns A, B and C. Shell script is to prompt the user to enter a value. Column A is to be the item name, column B is to be a hyperlink and column B is to be a short description of the item. Each time the shell script loads it prompt for new input that appends the HTML file that displays the table.

A.I. Answer

To achieve this, we'll create a simple HTML table with JavaScript to handle the sorting of the first column. We'll also write a shell script to prompt the user for input and append the new rows to the HTML file. Below is the HTML and JavaScript code for the sortable table, followed by the shell script.

Step 1 Conclusion:

The A.I. successfully created the code with logic. However, it did not quite get the append function right. The appended HTML code broke the page so a follow-up question was required.

Question 2 to A.I.

How to allow for a script to continuously append columns to a html table whilst preserving the closing html code.

A.I. Answer

To continuously append rows to an HTML table while preserving the closing HTML tags, we need to modify the script to ensure that it adds new rows right before the closing tags of the table and HTML document.

Here's how you can modify the shell script to achieve this

Step 2 Conclusion

Brilliant, after a clarification question that described the issue observed, the A.I. provided some updated code and guidance on how to fix the problem. With some further tweaks and debugging the problem was resolved.

Question 3 to A.I.

For aesthetics, how can I summarise a hyperlink so that in HTML it just displays the domain part (before the forward slash)?

A.I. Answer

To display only the domain part of a hyperlink in HTML, we can use a combination of shell scripting to process the input and generate the appropriate HTML. Here’s a streamlined solution that extracts the domain from the full URL and appends the processed data to the HTML file.

Final Conclusion

In summary, there were many errors in the code the A.I. provided. You need to have the necessary programming skills and background to be able to make sense of the code and perform corrections. In programming terms this is called debugging which is the natural next-stage phase of programming once the initial code and base-logic is defined.

Creating the initial code and base-logic i.e. "starting from zero" is both difficult and time intensive. Especially if you have a programming background but do not regularly code. It is like having to re-learn a foreign language for example, it helps if you can talk to someone in your native tongue who can talk back to you in the other language and help steer you so you can make sense of it.

Here is where generative A.I. is powerful, it can provide programming language back to the question describing what you need it to do. In this scenario, you are getting generative A.I. to train you and help you understand the code it produces.

You might be able to work out how to develop what you need purely relying on your own programming background and knowledge, Google searches, or even buying a textbook… but it could take 10 times as long and for that reason you might not bother. 

Summary of the benefits of "Using Generative A.I. to code"

  • This could inspire you to "get creative"
  • It could be genuine fun going through a process like this
  • Provide even greater value in your personal life, workplace or society

Be warned! Debugging is still painful but like all learning (or-relearning) processes, you should feel richer for the experience.

SAP and Generative A.I.

What is SAP Joule?

Joule offers conversational interactions between humans and computers to simplify access to information and automate business processes, thus improving both employee and customer satisfaction at scale.

Learn more: SAP Joule

SAP Global AI Ethics Policy:

SAP believes that Artificial Intelligence has the potential to unlock boundless potential for businesses, governments, and society. However, AI may also create economic, political, and societal challenges, depending upon how it is used and implemented.

Our brand-new SAP Global AI Ethics Policy therefore governs the development, deployment, use, and sale of AI systems at SAP, by defining clear rules of ethics that are aligned with SAP’s established guiding principles for AI and its core organizational values.

The policy covers essential elements which are vital to build trust in AI solutions, such as transparency and explainability, human agency and oversight, addressing bias and discrimination as well as civic society.

Read more: Global AI Ethics Policy