One of the popular requirement in SDN is to download csv data from web page. For this purpose, i have written code(UDF) to download csv content from web page to SAP.
This blog will give you clear view how to write java code(UDF) in PI.
At sender side Customer team is updating file in their web page then PI will pick the data and send to ECC.
Business Scenario: We need to retrieve daily files from the web page and upload them into
SAP ECC using Proxy communication.
Basic knowledge of PI/PO, Java etc…
Create the one more RFC Destination to connect to ECC to PI and viceversa. And specify the below details
- Connection type: G
- Target Host: SAP PI host
- Service No : SAP PI Service No
- Path perfix : /sap/xi/adapter_plain?namespace=XXXXXXXXX&interface=XXXX&service=XXXX&qos=EO
- Create DT, MT, and SI for the String field (having Data here).
- Create MM and create new UDF as per the below code.
public void getDataFromCNB(String var, ResultList result, Container container) throws StreamTransformationException
AbstractTrace trace = container.getTrace();
String var1 = null;
URL url = new URL(“http://www.abc.com/xyz.txt“);
URLConnection uc = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String line = null;
while ((var1 = in.readLine()) != null)
Map the UDF to a data String field.
Mapping details given below in screenshot(Just for reference purpose).
- Create Operation mapping.
Save and activate IR part.
Go to ID part and create the Scenario name and create the sender agreement, Receiver Agreement, Receiver Determination and Interface Determination and both the channels.
Store the data in local folder and then Use file adapter to process the same as per your requirement to ECC.
Go to change list and activate all the ID objects.