Skip to Content
0
Aug 24, 2020 at 02:01 PM

SAP PI: Mapping UDF to get filename at runtime without field in CSV

220 Views Last edit Aug 24, 2020 at 02:17 PM 2 rev

Hi,

SFTP (CSV -> FCC-> XML) ----- PI ----- SOAP ECC

We have to send the picked filename as a field to ECC as XML. We will receive CSV from third party without any extra field for filename. We have converted it to XML using FCC and also added UDF mapped to "Filename" field and got the desired result. But this works only if i pass an empty value in CSV (like at last ,, ).

Third party confirmed with us that they wont be including any extra field in CSV to accomodate filename. So we have to generate the field with filename passed to it with UDF at runtime.

UDF:

publicString getFileName(String a, Container container) throws StreamTransformationException
{
String filename ="";
DynamicConfiguration conf1 =(DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
filename = conf1.get(key1);
conf1.put(key1,filename);
return filename;
}

I need to pass the filename to a field without having a field for filename in CSV file.

Santhosh Kumar VellingiriIsuru FernandoMark DihiansanVijay BRaghuraman SAzael NAVARRO JIMENEZ S Sriram

Any help would be appreciated.