Skip to Content
0

Require help for Scenario -How to download text (.txt file) from web url

Mar 29, 2017 at 05:00 AM

67

avatar image

Hi Experts

I require help in designing the following scenario.

How to download text file from web url using sap PI. our version of PI is PI 7.11 .

Please suggest any scenarios link or help.

10 |10000 characters needed characters left characters exceeded

The .txt file needs to be downloaded from the url https://..................... by using PI and then the file needs to be sent to SAP for further logic. PI just needs to download the .txt file and send to SAP.

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Iñaki Vila Mar 29, 2017 at 05:53 AM
1

Hi Iakshimi,

You can try with the SOAP (Axis) adapter https://blogs.sap.com/2012/01/05/michals-pi-tips-exchange-rates-from-an-xml-file-on-a-web-page-rest-axis/ . However, i'm not sure if it works with non XML file. In the worse case you can do it with java development in a java mapping or own module bean.

Regards.

Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Mar 29, 2017 at 07:29 AM
1

Hi Lakshmi!

URL website = new URL("http://source.server/source.file");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("information.html");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
With this java code you can download file by given URL.

Regards, Evgeniy.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi Evgeniy

Should i use this code as a java udf or should i use the java mapping.

what communication channels should i use and how the scenario needs to be developed, please suggest your inputs.

regards

lakshmi

0

Hi Lakshmi!

It depends on your further reqirements. You can use this code in UDF or in java mapping as well.

If contents of downloaded file is used in mapping logic or as output payload, you can use java mapping.

If you need to save it as attachment, for example, you can implement UDF in graphical mapping.

Regards, Evgeniy.

0

Hi Evgeniy

The .txt file needs to be downloaded from the url https://..................... by using PI and then the file needs to be sent to SAP for further logic. PI just needs to download the .txt file and send to SAP.

0