cancel
Showing results for 
Search instead for 
Did you mean: 

Routing the files based on structure of the files, present in same folder with same naming convention

nitindeshpande
Active Contributor
0 Kudos

Hello Everyone,

I have a scenario, where we get 4 different types of files in the same folder. Two files are in XML format and other two are in text format and all these four files have same naming convention and they will be placed in same folder.

Previously we were getting only two XML files and the structure of the files were almost same, hence i had used a common XSD to accommodate both the structures and differentiate them in the Interface determination using XPath expression and have different operation mapping.

Now there are two additional text files which are placed in the same folder with same naming convention as above two XML files. I need to take these two files and drop into one of the folder of ECC system.

Can you please let me know how to accommodate this in my scenario?

Regards,

Nitin Deshpande

Accepted Solutions (1)

Accepted Solutions (1)

manoj_khavatkopp
Active Contributor
0 Kudos

Hi Nitin,

When you say file-naming convention is same do u mean even the extension of .txt and .xml file are same ? or their is no extension at all.

If you have extension respectively i.e as .txt/.xml then you can do filtering in RD/ID.

Br

Manoj

nitindeshpande
Active Contributor
0 Kudos

Hello Mark/Manoj,

Thanks a lot for your reply.

Unfortunately, the filename extension are random actually. Files come from SWIFT and it adds up some random reference number at the end hence even the filename extension becomes unique for all the files.

Only way to differentiate them is based on the data present inside them.

Regards,

Nitin

manoj_khavatkopp
Active Contributor
0 Kudos

Nitin,

Then my suggestion would be have extending receiver determination then using some java parse the file and identify if its xml or a text ( usually xml file has <?xml version=1.0......?> take this as identifier ) and then route it accordingly.

Br,

Manoj

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Nitin,

Here's a little POC for you:

I made the sender file channel not to use any extensions:

Receiver determination:

Use xpath to check the existence of a field for the payloads that use XML. In the no receiver found behavior, enter the receiver which accepts text files. In my case it is BC_RD2

Sample test:

Routed to BC_RD2

Test2:

Routed to BC_RD

Regards,

Mark

manoj_khavatkopp
Active Contributor
0 Kudos

Mark,

Curious to know didn't you get the error "Content not allowed in prolog" for the non xml file ?I guess you have done this POC using dummy service interface without ESR ? with ESR does this works fine?

Br,

Manoj

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Manoj,

I did not select a software component version in the sender agreement and receiver determination, that is why it is working

Regards,

Mark

manoj_khavatkopp
Active Contributor
0 Kudos

Hi Mark,

I though the same but how did u achieve to keep the xpath when you dont mention SWCV in sender agreement.?

Br,

Manoj

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Manoj,

The xpath can be inputted manually. It is easier if SWCV is mentioned, since you'll be able to see the structure. However, with both xml and non-xml payload using the same RD. It has to be removed.

Regards,

Mark

nitindeshpande
Active Contributor
0 Kudos

Hi Mark,

Sorry for the delay in reply. I used the exact same solution for my scenario. Very happy to see, we approached the same method to resolve this.

Actually i had to convert the data into XML. Because i had to differentiate between the four type of files and route them separately -

Below are the steps which i followed -

1. I read the complete data into a single field using FCC.

2. Used XPath expression with consists of function to differentiate between the text file and XML file. In one of the text file we have one fixed ID being generated this was used in the RHS of consists-of function and routed this to one of the receiver which is a ECC system

3. And for the XML files, i checked if the Root tag of XML is present and routed this to another receiver, which is PI system. I placed this in SAP PI system temporarily and ran another ICO to pick this file and map it to proxy. I had to use another scenario for differentiating the two types of XML files using XPath expression.

4. If the above both condition in 1st ICO fails, then the files will be routed to another receiver which places the files directly in one of the folder. This is another text file.

Thanks a lot for your detailed reply and POC.

Regards,

Nitin

markangelo_dihiansan
Active Contributor
0 Kudos

Your are welcome Nitin

Answers (2)

Answers (2)

former_member183816
Active Participant
0 Kudos
markangelo_dihiansan
Active Contributor
0 Kudos

Hi Ambuj,

The fileType only has two values: bin and text. However, in the fileSender CC there is no dynamic option for fileType, meaning the value that the dynamic configuration will retrieve is the value set in the channel.

You can do a small test to confirm. Try uploading a text file when the fileType is bin and it will give you bin

Regards,

Mark

former_member183816
Active Participant
0 Kudos

I gathered everything from standard SAP help docs. So ideally it should work.

I don't know how Nitins's PI adapters, file and folder properties react to it.

I will leave this testing to Nitin

Thanks,

Ambuj

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Nitin,

In the condition editor for receiver determination, select context objects (xpath is the other option), scroll down and select FileName. Then use the approx sign (wavy equal) and then input .txt.

Regards,

Mark