With on-premise, it was relatively easy to create files and transfer them to our AL11 directories. However, in the public cloud, most of the references that I found asks me to create an iflow where I call an odata and use an FTP receiver adapter to transfer the file.
Now I am just wondering if it's even possible/advisable to create/send the file via an program? The blog below shows how to do it via HTTP API classes assuming that the SFTP server provides a REST API.
I would like to know what is the best practice way to achieve it in the public cloud. Thanks.
The best practice in SAP S/4HANA Cloud is to use service integration (previously known as SAP Cloud Platform Integration or SCP-CPI). The platform supports the creation of an integration flow (iflow) that fetches the data via OData and saves it to a SFTP server through an FTP Receiver Adapter.
In SAP S/4HANA Cloud, use of conventional ABAP-based file operations or direct access to file system directory (like in AL11 of an on-premise system) or using HTTP APIs directly from ABAP, which is depicted in your example are not recommended - some of these operations may not be possible at all due to restrictions implemented for enhance system security, consistency, and upgradability.
For transferring files, the basic idea in the cloud environment is to retrieve data via white-listed APIs (like Odata), and then transfer it to your required platform (like to a SFTP server in your case) using an iflow in SAP Cloud Platform Integration. This way, all the cloud guidelines & restrictions are adhered to by design, as well as ensuring an overall cloud compatible solution.
Please check SAP Help Portal of SAP Integration Suite.