ABAP SDK for Google Cloud: Code Wizard
A Productivity Booster
Google Cloud recently released the ABAP SDK for Google Cloud, a tool that allows SAP developers to easily integrate their SAP applications with Google Cloud services. This bi-directional, real-time integration can be used to accelerate digital transformation and achieve business goals faster.
It comes with various utilities and tools embedded to enable SAP developers fast track their developments and help SAP customers a faster time to value. This blog post talks about one such utility named “Code Wizard” shipped with the SDK.
Application Development with Code Wizard
The ABAP SDK for Google Cloud includes a code wizard tool that can help generate boilerplate code for easy usage of API methods. This significantly improves developer productivity.
The ABAP SDK for Google Cloud also provides a design pattern called the Single-window of interaction. This pattern simplifies the process of consuming Google Cloud services for ABAP developers by abstracting away the underlying complexities of interacting with Google Cloud APIs, such as authentication and request/response payload formatting.
To use the Single-window of interaction, developers simply need to instantiate the corresponding ABAP class for the Google Cloud API they want to interact with. This class will provide a set of public methods that correspond to the operations exposed by the API. Developers can then call these methods to perform the desired operations.
Each API method call follows a 5-point interaction flow:
- Connect to an API.
- Construct an input request using the ABAP types.
- Call an API method.
- Parse errors and exceptions.
- Read the response using the ABAP types.
The concepts of Single-window of interaction and the 5-point interaction flow for an API call have been comprehensively discussed in this blog post. The Code wizard is built on these concepts.
What is Boilerplate Code?
First let’s understand the term “Boilerplate code”. Here’s how wikipedia defines it:
In computer programming, boilerplate code, or simply boilerplate, are sections of code that are repeated in multiple places with little to no variation.
Source: Wikipedia
What is Code Wizard?
Code wizard is a tool that can help generate boilerplate code for easy usage of ABAP SDK for Google Cloud API methods. It is similar to the “pattern” option used in ABAP world, however, in addition to the ABAP pattern, code wizard also generates all necessary data declarations, response and exception handling.
Consider the Code wizard as a Collection of code snippets that can boost development.
Advantages:
So now that we understand what Code Wizard can do, let’s consider some reasons why you might want to use it.
- It offers less complexity: Basically giving you cleaner and consistent code.
- Provides additional customizations and features in the form of choosing ABAP 7.5 syntax, adding and removing code blocks for opening and closing HTTP connections.
- Generates all the required data declarations.
- Provides placeholders in the code for filing method importing parameters.
- Generates basic response and exception handling.
- Additionally, it also gives you an option to copy the generated code that can be used in subsequent programs/objects.
Code wizard is a tool that provides a basic structure for your code, but you can modify it to meet your specific needs.
Supported APIs:
The tool supports all methods of the APIs enabled by the ABAP SDK for Google Cloud.
Code wizard provides context-sensitive help for both the API class and method. This means that you can press the F4 key to see a list of possible values for any parameter in the code wizard.
And for each API, all relevant methods can be chosen to generate a boilerplate code.
How to Get Started with Code Wizard
To get started with code wizard, you need to install the ABAP SDK for Google Cloud. Once the SDK is installed, you can access code wizard from the SAP GUI following below steps:
Here is an example of how you can use code wizard to generate boilerplate code and use it in a program to create a topic in Google Cloud Pub/Sub from SAP:
- Using SPRO, access the Code Wizard: Goto ABAP SDK for Google Cloud -> Utilities -> Code Wizard
- In the selection screen, select the following options to generate boilerplate code for creating a topic in Google Cloud Pub/Sub:
- This will generate an output like below: Note that it has all relevant data declarations, exception handling, code blocks for opening and closing the HTTP connection and also placeholders to provide input parameters. Additionally, the Source code is also copied to the clipboard.
Note: In the trial version of SAP, you encounter an error at this step, but the generated code will be copied to the clipboard for your usage.
The generated output follows the 5 point Interaction Flow as discussed above.
- Create a new report program, and paste the generated code. Additionally uncomment the importing parameters and provide the relevant parameter values. The below code snippet will create a topic “SAMPLE_DEMO_TOPIC” in Pub/Sub:
Conclusion
Code wizard is a powerful tool that can help you to improve your productivity when developing ABAP applications that use Google Cloud APIs. If you are an ABAP developer who uses Google Cloud, I encourage you to give code wizard a try.
I hope this blog post has been informative. Please let me know if you have any questions.
Next Steps
You may want to evaluate the ABAP SDK for Google Cloud and build some interesting SAP products using Google Services.
The ABAP SDK for Google Cloud is a game-changer that enables you to integrate with Google’s REST-based APIs. The Insider story of Engineering Excellence will give you a glimpse of the amazing things that the SDK implicitly provides to you.
Do check out the What’s new and Quick start sections for more details.
Below are some more blogs to fuel your innovation quotient where you will get a glimpse of how to develop enterprise-grade applications using the ABAP SDK to solve business problems:
- Automating Sales Order Entry in SAP using Google Cloud’s AI services
- Google AI-powered automated order/shipment routing in SAP
Please follow the medium tag abap-sdk-for-google-cloud for more articles and guides.