cancel
Showing results for 
Search instead for 
Did you mean: 

file adaptor question

Former Member
0 Kudos

I have a requiurement where i have to poll a certain directory and based on the file type move it to a different location.....i was planning on using 2 comm channels and using exclude file a in cc1 and file 2 in cc2...

Is there any other way..?

Venkat

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

>>file type move it to a different location

you will need only 1 communication channel on sender side,on the receiver side you would need 2 communication channel and route the files based upon the file type using conditional receiver determination.

you would need to get the filename in message mapping so that you can route it to correct receiver in conditional receiver determination,use ASMA for that

Thanx

Aamir

justin_santhanam
Active Contributor
0 Kudos

Aamir,

If we go ahead with your approach then only one comm.channel is enough, why do we need two comm.channels? Can u explain this.

raj.

Former Member
0 Kudos

Raj...i guess that the default way fileAdaptor works...............

Aamir, Can you add some info to the conditional reciever determination , as i am not doing any mapping, here.

Venkat

Former Member
0 Kudos

Hey Raj

well he wants to transfer files to two different locations,right?

now if those two locations are two different systems then he would need 2 receiver adapters and to pick up files he would need only 1.

Thanx

Aamir

justin_santhanam
Active Contributor
0 Kudos

Aamir,

No Buddy, as you said, if he uses Mapping[ASMA] then even in same comm.channel, I can change the directory name isn't it? Why would I need two comm.channel for different folders? Please correct me if I'm wrong.

raj.

Former Member
0 Kudos

Alright..so how do i accomplish that using no mapping

Former Member
0 Kudos

>>as i am not doing any mapping

see to send the file to two separate systems u would need conditional receiver determination,which is done based upon field(s) in payload,now if you are already getting the filename in the payload,then you can simply use that but in case you are not getting the filename in payload then you would need a UDF to get the filename and map it to a field on receiver side and then use this field in conditional receiver determination

Thanx

Aamir

Former Member
0 Kudos

One more thing in the req here...

This is the complete req..

Poll folder A...

If (file a ..then send to folder A

if file b then send to folder B

if file c then send to folder C

Do this with no mapping...

Aamir...2 or 3 reciever channels wont do it...

Venkat

Former Member
0 Kudos

ohh,i meant a UDF just to get the filename,not to route the file,definitely you can use If-Else condition in UDF ,then map the directory name to the node field(or any other field on receiver side) and use this while creating the receiver communication channel(ASMA),in that case he needs only 1 sender and 1 receiver CC.

these are just two different ways to achieve the same thing:)

by two different locations i thought two different machines,and in that case two separate receiver CC's are required.

Thanx

Aamir

Message was edited by:

Aamir Suhail

Former Member
0 Kudos

Aamir,

By 3 different locations i meant same machine but different location...and cannot use udf..as there is no mapping..

Now what..!!!

Venkat

Former Member
0 Kudos

now u have given the complete requirement.

earlier you said different locations which can mean different folder or different physical system.

anyways for your requirement,you need to write a UDF wherein you would get the filename type,once u get the filetype you need to have If-else condition wherein you would assign different folder based upon the filetype,now you need to map this to a field on receiver side(map it to node if u dont want to show this field on the receiver side XML).

then dynamically assign the directory name on the receiver communication channel using this field.

Thanx

Aamir

Former Member
0 Kudos

see the thing is you can't branch off your file without knowing the filetype,right?

now to know the filetype you need to implement a UDF so that you can map it to the some tag on the receiver side and then send it to its correct destination.

if you dont have mapping,then u need to create a simple 1-1 mapping and also have this UDF in it

Thanx

Aamir

Former Member
0 Kudos

Aamir,

I know the filetype .....without udf....i tried using the fileName exclusion mask..doesent work as expected

Venkat

Former Member
0 Kudos

now i m confused:)

lemme tell u how i understand your scenario.

you have 1 directory on the sender side,now XI will pick up file from this directory and then based upon the filetype it will send to either of the three different folders on the receiver side,right?

Thanx

Aamir

Former Member
0 Kudos

You got it toyota....

that is exactly correct...

Venkat

Former Member
0 Kudos

>>You got it toyota....

lolz,i don't need Toyota,i need a Ferrari;)

anyways,so in your scenario you will configure one sender file adapter and give the name of that one directory you want to pick files from,then give file name as ..

this will pick up all the files(irrespective of their extension).also check the Adapter specific message atributes checkbox on the sender side,now in message mapping write a UDF where in you would get the filename(along with its type),store this filename in some variable,then you need to assign the directory path based upon the filetype and then map this to the root node on the receiver side,

have a look at the below code to see how the directory can be assigned dynamically.

your code won't exactly be the same but will use the same concept

Thanx

Aamir

Former Member
0 Kudos

Aamir,

Without mapping is my requirement...How then

Venkat

Former Member
0 Kudos

without mapping its not possible to get the filename,you do get some adapter attributes just by selecting them in the sender adapter but since you have to do some manipulations,that wont help you either,hence you wont be able to route it.

UDF is the easiest way to do it.

Thanx

Aamir

bhavesh_kantilal
Active Contributor
0 Kudos

Use the DynamicConfigurationBean or write a Adapter Module to set the filename if you do not want to use any mapping.

Or, write a Java Mapping. All this Java Mapping will do is read the source filename and set the target filename. The inputstream ( input to the Java Mapping) be pushed out as the output Stream ( Output of Java Mapping).

Regards

Bhavesh

Former Member
0 Kudos

Bhavesh,

Thank you..Can you elaborate, on the dynamic configuration bean...?

I found this in the help.sap.com

Advanced Selection for Source File

If you want to set an exclusion mask for the File Name specified above, or if you want to specify multiple directories using a file name mask and exclusion mask, set the Advanced Selection for Source File indicator.

○ Specify an Exclusion Mask for the file name specified above.

Example

You want to process all files that have the extension '.txt', but want to exclude all files that begin with the letter 'a'. To do this, enter .txt for File Name, and a for Exclusion Mask.

○ You can enter additional specifications for source directories, file names, and exclusion masks in the table. This data is processed in addition to the details specified above.

I tried polling the location....specified .xml so as to process all xml files and then for the exclusion specified abc....in the same folder i also have def.xml..that should have been processed....that wasnt....nothing was processed...........what is not right...

Venkat

bhavesh_kantilal
Active Contributor
0 Kudos

This blog describes what DynamicConfiguration Bean can do..

/people/jin.shin/blog/2007/04/27/sap-netweaver-xi-variable-substitution-with-adapter-specific-message-attributes-via-dynamicconfigurationbean

What does File Exclusion Mask have to do with your Dynamic File Directory? I am confused and as I can see , all the posters to this thread are also confused on what you are trying to achieve. Address one problem at a time

Regards

Bhavesh

Former Member
0 Kudos

Bhavesh,

It does...Since i need to move ONLY fileA to locationA and ONLY fileB to locationB and ONLY fileC to location C.

I have to exclude the files that dont need to be moved...that was an attempt...

also the DynamicConfigurationBean doesent let us specifiy specific filenames and based on the fileName`s make a if then decision as to the location of the reciever....

What are my options now..?

Venkat

Answers (1)

Answers (1)

justin_santhanam
Active Contributor
0 Kudos

Venkat,

Can u explain your scenario from end to end perspective, it's little bit confusing.

raj.