Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Install ABAP Platform Trial 2022 on Google Cloud Platform and Install Vertex AI SDK for ABAP

1727684941595.png

Do you want to install your own SAP sandbox system and Call Gemini using Vertex AI SDK for ABAP in under 30 mins? Then keep reading this article.

In this article, I have listed the steps to install ABAP Platform Trial 2022 on Google Cloud and then install latest release of ABAP SDK for Google Cloud which also includes the new Vertex AI SDK for ABAP.

In under 30 minutes, you'll have everything you need to start exploring the full power of Gemini, all from within ABAP!!!

We use the scripts that are hosted in this GitHub Repository. The repository README file has detailed documentation of the script’s functionality.

The following Google Cloud services are used in this codelab:

  • Compute Engine
  • Network Services
  • Cloud Shell

What you’ll build

You’ll create the following using the script:

  • A Compute Engine Instance with ABAP Platform Trial 2022 running on the docker container.
  • Firewall Rules.
  • Service Account for accessing Google Cloud APIs using the ABAP SDK for Google Cloud.

Requirements

  • A browser, such as Chrome or Firefox.
  • A Google Cloud project with billing enabled or Create a 90-Day Free Trial account for Google Cloud Platform.
  • SAP GUI (Windows or Java) installed in your system. If SAP GUI is already installed on your laptop, connect to SAP using the VM external IP address as the Application Server IP. If you are on Mac, then you can also install the SAP GUI for Java available in this link.

Before you begin

1.png

  • Run the following commands to authenticate for your account and set the default project to abap-sdk-poc. Zone us-west4-b is used as an example. If needed, please change the project and zone in the following commands based on your preference. These parameters are used by the installation script.
gcloud config set project abap-sdk-poc
gcloud config set compute/zone us-west4-b

Execute the creation script

Run the following command to execute the script create_vm_withdocker.sh.

mkdir sap-docker-2022
cd sap-docker-2022
git clone https://github.com/google-cloud-abap/abap-cloud-trial-2022-gcp.git
cd abap-cloud-trial-2022-gcp
chmod 755 create_vm_with_docker.sh
./create_vm_with_docker.sh

The script will do the following activities:

Note: The script will auto agree the SAP license terms on behalf of the executor using the flag — agree-to-sap-license. (Refer to license section in the docker hub page for more details the license)

Set IAM roles

Follow the below steps to add the IAM role to the service account

  • Navigate to IAM & Admin in the Google Cloud Console and click on "Grant Access"

AnZK6hsFUNrVCLF.png

AW5QZASWC6pgB9X.png

Monitor the installation

The VM will get created in a few minutes, but installing the SAP docker container step will take around 15 mins.

To monitor the installation process, perform the following steps:

After the VM is created, use one of the following methods to SSH into the system:

2.png

  • Run the following command in the Cloud Shell terminal:
gcloud compute ssh "abap-trial-docker-2022"

The installation script creates an output file /tmp/output.txt. To monitor the installation process, you run the tail command with this file.

tail -f /tmp/output.txt

Wait till you see the below confirmation message in the output file that the SAP docker container is running.

You can also run the following command to check if the container is running:

sudo docker ps

This completes the installation and now we can move on to the next step of connecting to the system.

Test connecting to the SAP system

You can now connect to the SAP system.

  • Run the following command to get the External IP Address of the VM or check in the Google Cloud console.
gcloud compute instances describe abap-trial-docker  \
--format='get(networkInterfaces[0].accessConfigs[0].natIP)'

Use the following information to connect from SAP GUI:

  • System ID: A4H
  • Instance Number: 00
  • Application Server: <External IP Address>

3.png

The user name is DEVELOPER with the password ABAPtr2022#00 . This is also predefined (same password) for client 000, client 001: SAP*, DDIC. Please refer here for more details.

Renew the SAP trial license

To renew the SAP trial license, perform the following steps:

  • Log in to the system using the following credentials:

4.png

  • Get the Hardware key from Tcode: SLICENSE
5.png

6.png

 

  • Go to Tcode: SLICENSE, click the Install button, and select the downloaded text document A4H_Multiple.txt. The system will extend for another 3 months.

Activate TMS configuration

In order to import transports into the system, we must activate the TMS configuration.

  • Log in to the system using username DEVELOPER with the password ABAPtr2022#00.
  • Go to TCode STMS > Overview > Imports.

7.png

  • Select Environment > System Overview.

8.png

9.png

 

  • Select Extras > Distribute and Activate Configuration.
10.png
11.png
  • Go to TCode STMS_IMPORT, where you should see the following screen: 

12.png

Now the SAP system is ready to import any transports.

Configure Trust Certificate

For securely connecting to Google APIs using the ABAP SDK, trust certificates are required.

Download the following certificates from the Google Trust Services repository into your desktop:

  • GTS Root R1 (PEM)
  • GTS CA 1C3 (PEM)

In the SAP GUI, use the STRUST transaction to import both the root and subordinate certificate into the SSL client SSL Client (Standard) PSE folder.

In STRUST, select the node SSL client SSL Client (Standard) and click Import certificate to upload both the files, click Add to Certificate List and Save.

13.png14.png

Import ABAP SDK for Google Cloud latest version

The transport files for ABAP SDK for Google cloud are available in this link. To expedite, we will execute the import using a script.

  • From the cloud shell, SSH into the SAP docker VM:
gcloud compute ssh "abap-trial-docker-2022"
  • Download and execute the import transport script:
wget https://raw.githubusercontent.com/google-cloud-abap/abap-cloud-trial-2022-gcp/main/import_abap_sdk.sh
chmod 755 import_abap_sdk.sh
./import_abap_sdk.sh
  • Once completed, check for the package /GOOG/ABAP_SDK in SE80. You now have the ABAP SDK installed.

15.png

Write a sample ABAP program using Vertex AI SDK

Let’s write a sample ABAP program to use Gemini Flash and send a sample prompt.

Step1: Configure client key

Log in to the SAP Trial A4H system with the user name DEVELOPER and password ABAPtr2022#00 and follow these steps to configure the client key:

  1. In the SAP GUI, enter transaction code SPRO.
  2. Click SAP Reference IMG.
  3. Click ABAP SDK for Google Cloud > Basic Settings > Configure Client Key.
  4. Click New Entries.
  5. Enter values for the following fields:
16.png

Step2: Create RFC destination

Create RFC destination for IAM credential and Vertex AI API using the transaction code SM59. If needed, please refer here for detailed steps on creating an RFC destination.

17.png

Under the Technical Settings tab, enter the following details for the ZGOOG_IAMCREDENTIALS  destination. 

18.png

 Under the Technical Settings tab, enter the following details for the ZGOOG_VERTEX_AI destination.

20.png

For the SSL Certificate field, make sure that the option DEFAULT SSL Client (Standard) is selected for both the RFC destinations.

21.png

Step3: Configure service mapping

To configure the service mapping table for IAM API, and Vertex AI API, perform the following steps:

  1. In the SAP GUI, enter transaction code SPRO.
  2. Click SAP Reference IMG.
  3. Click ABAP SDK for Google Cloud > Basic Settings > Configure Service Mapping.

Click New Entries for IAM Credential and Vertex AI API and update the RFC destinations as shown below.

22.png

Step4: Configure Vertex AI SDK Model Generation Parameters

To configure the generation parameter for models related to Text embedding, Multimodal embeddings and Gemini-flash, perform the following

  1. In the SAP GUI, enter transaction code SPRO.
  2. Click SAP Reference IMG.
  3. Click ABAP SDK for Google Cloud > Basic Settings > Vertex AI SDK: Configure Model Generation Parameters.
  4. Click New Entries for model configurations and update the entries as shown below.
23.png

Step5: Create a Report program with following lines of code to send a sample prompt to Gemini.

TRY.

    " Instantiate Genrative Model class from Vertex AI SDK
    DATA(lo_model) = NEW /goog/cl_generative_model( iv_model_key = 'Gemini-Flash' ).

    " Call Gemini-Flash
    DATA(lv_response) = lo_model->generate_content(
                            iv_prompt_text = 'What is LLM? Please respond in HTML format' )->get_text( ).

    cl_demo_output=>display_html( lv_response ).

  CATCH /goog/cx_sdk INTO DATA(lo_exception).
    cl_demo_output=>display_text( lo_exception->get_text( ) ).

ENDTRY.

Example Output:

24.png

Congratulations

Congratulations! You have successfully installed ABAP Platform Trial 2022 on Google Cloud Platform, imported the transports for ABAP SDK for Google Cloud and also interacted with Gemini LLM all under 30 minutes!!

The SAP trial system will allow you to explore more about ABAP SDK and Vertex AI SDK scenarios .

You can now proceed with the other ABAP SDK codelabs to continue with your learning journey of using ABAP SDK for Google Cloud to access various Google Cloud Services.

Clean Up

For clean up use the below commands to delete the VM, the firewall rules and the service account.

gcloud compute instances delete abap-trial-docker-2022
gcloud compute firewall-rules delete sapmachine
gcloud iam service-accounts delete \
    abap-sdk-dev@abap-sdk-poc.iam.gserviceaccount.com

Delete the project abap-sdk-poc using Manage Resources.

Follow this medium tag for more content on ABAP SDK for Google Cloud.

️ Happy Learning! and Happy Innovating!

1 2 743
2 REPLIES 2

I am interested, but would need to know how much would it cost, for example when used 4 hours per day.

I have used the Calculator to obtain the price of the Compute Engine? But the rest? How can I know the total sum?

This doesn't work at all. The Script fails saying that it cannot find the Service Account. The service account is there.

After that the Script cannot be restarted anymore.

Complete failure.