on 2021 Jul 15 1:39 PM
Hi Experts
I am working on File to Idoc scenario,
the filename has the invoice number in it and i need to pass the same to the field in the idoc.
Filename: INVOICE_JULY_US_123456_FR.csv. here 123456 is the invoice number which i need to pass it to the idoc field.
I looked into few variable substitution posts but its mostly used for receiver channel. my question is how can i fetch only the Invoice number(123456) from the filename and use it in the mapping.
Kindly assist . if you have any UDF or code, please share it.
thanks
Request clarification before answering.
Hi Smith,
Please try this UDF
public String extractInvoiceNumberFromFileName(Container container) throws StreamTransformationException{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String fileName = conf.get(key);
String invoiceNumber="";
for(int i=0;i<fileName.length();++i)
{
if(fileName.charAt(i)>='0' && fileName.charAt(i)<='9')
{
invoiceNumber=invoiceNumber+ fileName.charAt(i);
}
}
return invoiceNumber;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
in the file sender adapter you need to select the Set Adapter-Specific Message Attributes flag, then this adds the file name to the header FileName of attribute namespace http://sap.com/xi/XI/System/File.
Via a UDF, you can read the header. In this blog I have a code example how to do this: https://blogs.sap.com/2014/12/18/pi-rest-adapter-using-dynamic-attributes/
And then read the substring via standard functions. If your file name follows a specific template, you can determine the length of the attribute value using the function length, and from there extract the number via function substring.
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank you both for the answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
21 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.