Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sunit_s
Participant
Dear ABAPers,

Have you ever written code using the ABAP statements OPEN, READ, and WRITE DATASET to read an SAP-generated file from one directory and write it to another directory on a shared file system in your organization? If so, you may have liked the ease with which you can accomplish this by writing code in your se38 ABAP editor.

But what if there was a way to read an SAP-generated file or read data from SAP tables and write it directly to an AWS S3 bucket using your own ABAP code and editor? That's right, it's now possible thanks to the AWS SDK for SAP ABAP! With this you can read a file using Open/Read Dataset and send it to AWS S3 by calling new class and method provided by the AWS SDK for SAP ABAP.

On top of this imagine doing this without worrying about writing code for authorization, authentication, non-sap editors and API connections. Instead, you can concentrate on business data, logic, and innovation you want work on. This can give you the innovation and flexibility of using AWS services ranging from simple file storage to very innovative Gen AI at your fingertips.

The AWS SDK for SAP ABAP offers several benefits, including:

  • Increased efficiency and productivity: You can save time and effort by writing ABAP code to read SAP files and write them directly to S3 buckets. This eliminates the need to use OS commands or put files in a shared file system for other programming languages, such as Python or Java, to process.

  • Improved visibility and control: When you write ABAP code to read and write files to S3, you have complete visibility into the process. You can easily troubleshoot any issues that arise without having to rely on Basis or other non-SAP programmers.

  • Access to a wide range of AWS services: The AWS SDK for SAP ABAP allows you to invoke a wide range of AWS services from within your ABAP code. This gives you the ability to build powerful and integrated applications that leverage the power of AWS.


 

These links below are a good starting point for your first steps:

  1. Overview page: https://aws.amazon.com/sdk-for-sap-abap/

  2. Documentation: https://docs.aws.amazon.com/sdk-for-sapabap/latest/developer-guide/home.html

  3. GREAT blog by Adren D Souza and Glenn Mendonca: https://aws.amazon.com/blogs/awsforsap/getting-started-with-aws-sdk-for-sap-abap/


 

After getting overview of how things work you can set your plan into action by getting SAP Basis, Security and AWS expert to do following steps mentioned in below link:

https://docs.aws.amazon.com/sdk-for-sapabap/latest/developer-guide/getting-started.html

The steps vary slightly based on on-premises, AWS cloud or other cloud based SAP system.

Prerequistes: Have SAP NetWeaver ABAP 7.4 or higher environment.

Rough summary of steps in above link:

  1. Get an AWS Security expert in your organization to create appropriate IAM user, roles, profiles and Access key and Secret.

  2. Get Basis to download and install the AWS SDK for SAP ABAP on your SAP environment by importing transports in your SAP system and configuring steps in transaction code /AWS1/IMG. You don’t have to install all the SDK’s. You can choose SDK’s for services required by your organization and omit the ones that you don’t want.

  3. Further Basis, functional or you can create ‘SDK Profile’ and perform authentication settings in transaction code /AWS1/IMG (e.g., enter Access key and Secret generated by step 1 for on-premises SAP system).

  4. Get Basis or SAP security expert to create role (tcode PFCG) with necessary authorisation objects and ‘SDK Profile’ created in step 3.  Get them to assign this role to your SAP user id or other ABAP developers so that you will be able to execute AWS SDK functions.


 

Once you have completed these steps, you can start writing ‘z-program’ ABAP code to read files and write them to S3 buckets.

Let’s consider a simple but heavily used example. Let’s send a file to AWS S3 using ABAP code assuming a S3 bucket is already existing. If not, you can ask your AWS expert to create one for you with appropriate authentication and ‘WRITE’ permissions for your SAP user-id as discussed above.

I have taken below snippet of ABAP code from GitHub link provided by Amazon:

https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/sap-abap/services/s3/zcl_aws1_s3_actions.c...

 


In the link you will find ABAP class ‘zcl_aws1_s3_actions’ and method ‘put_object’ which reads a file using OPEN/READ DATASET command and executes method of SDK to write file to S3 bucket.

More API documentation for S3 service can be found at this link:

https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/s3/index.html

 

Next steps you can consider:

  1. Send file to multiple S3 buckets.

  2. Check how large files are written.

  3. Archive file to your companies shared file system after successful transfer.

  4. Read a file from AWS S3.

  5. Automatically rotate AWS Credentials like Access key and Secret after some duration.

Labels in this area