Skip to Content
Technical Articles
Author's profile photo Adam Kiwon

How to expose a CSV file as a Service with SAP PI/PRO

Imagine you need to read a file content from a remote application and you do not want to set up a replication?
This scenario explains how to expose a CSV file (here a product list) as a WebService using the standard SOAP Adapter and the WHINT FileReader Adapter.

FRAS2

CSV File:
FRAS1


Design (ESR):

  • Create Service Interfaces (Sender and Receiver side)
  • For the receiver side you can also use the synchronous Inbound Service Interface FileReaderQueryResponse_In which is shipped with the Adapter
  • Optional: Create a Mapping if you do not want to expose the result of the CSV-to-XML conversion of the MessageTransformBean

FRAS9

FRAS10

FRAS11


Configuration (Eclipse/NWDS):

iFlow:
FRAS4

Receiver Channel (FileReader):
FRAS5

SFTP Connectivity (of course you can read the file from NFS or FTP as well):
FRAS6

Module Configuration (MessageTransformBean: CSV->XML):
FRAS7


Upload File to SFTP Server:
FRAS8

Test from SOAP UI:
FRAS3

 

Update: I think it is obvious that the Files can be also queried with other sender channels, not only from SOAP (like e.g. REST here with a JSON response):

FRAS12

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Bhavesh Kantilal
      Bhavesh Kantilal

      Hello Adam,
      Is this a free open source adapter or is it a paid for adapter?
      This adapter solves a pretty common requirement for PO, where we need to "read" a specific file from a Server but this has to be triggered by another Interface. Would be great if you can share more details on this adapter and how one can get their hands on it!

      Regards,
      Bhavesh

      Author's profile photo Bhavesh Kantilal
      Bhavesh Kantilal

      In addition - how does the error handling happen in this case

      • What if this file is not available in the target location?
      • Are there options to delete / archive the files when the receiver channel reads the file?

      Thanks for the blog!

      Regards,
      Bhavesh
       

      Author's profile photo Adam Kiwon
      Adam Kiwon
      Blog Post Author

      Dear Bhavesh,
      i am surprised myself that SAP never delivered this functionality.
      It is an SAP certified adapter developed by us (available in the SAP Appstore), which you can also download from our digital online store (www.whint.de).

      Regarding your further questions:

      • If no file is present, you can raise an exception (channel config) or you receive an empty result.
      • A deletion/archiving is not foreseen (on purpose)

      Best regards,

      Adam

      Author's profile photo Bhavesh Kantilal
      Bhavesh Kantilal

      Excellent and Thank You very much!
      And I agree, this is a space in PI Adapters and am glad you have developed this!
      I would happily recommend this to a customer if I see the need for it!

      Regards,
      Bhavesh