cancel
Showing results for 
Search instead for 
Did you mean: 

Read uniquely named file. Sender File Adapter unsuitable for synchronous

Former Member
0 Kudos

Hi All,

We have a requirement to read a specific file that has a unique name based on a transaction ID. The transaction ID will be passed from the source application.

The communication is required to be synchronous. There could be multiple requests/files generated and present at the directory at any given time but each corresponding to a specific transaction ID. If the file is not yet generated for that transaction ID we return back an error to the calling system.

I think we can not use Sender File Adapter - because of the dynamic naming and also because we have to return a synchronous response back depending on the file availability. i.e. We can not have a defined pattern in the file name nor can we specify a wild card as there could be more than one files in the location.

In theory we could use the File Sender adapter to read all the files in the directory and a BPM with correlation set based on the transaction ID and let the process wait for the request. But as far as possible I want to avoid this unnecessary wait or extra demand on the system. More so because the files could get big.

If I were using a tool like SAP Business Connector or webMethods then I would I used a readFile Java service and given it a filename to return the required bytes in a synchronous read.

Is something like this possible in XI? If someone has written a synchronous Java to read file can they share the code? Or do you suggest I write a ABAP server proxy to read the file? The problem however will be how do we map the data to a XML within the code.

All suggestions welcome. There has to be a simple and effective solution to this mundane requirement !

Wishing all SDNers a bright start to this new year,

Thanks,

Charu

Message was edited by:

Charu Kulkarni

"The transaction ID will be passed from the source application so we know what file to pick"

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

We used a ABAP Proxy

Former Member
0 Kudos

Hi,

You could make the scenario a little simple and avoid custom development if the logic can be put into scripts(out of XI).

Say all the files are coming into a directory called D1.

Here, you could use a script to arrange all these in an order (say ascending) and move the first file into another directory D2.

The sender file adapter would poll this directory D2. The adapter can have a wild card character for the filename field now.

Once the file is in XI, you could check this against the transactionId present(I am not sure how you get this though!), and determine whether to send a mail, or to send a file back.

Here, I have assumed that there is somekind of order present in the files placed in the directory D1.

Again, this is just a suggestion.. I might be wrong with all the assumptions.

Regards,

Smitha.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

you can also consider using sync java proxy

then you'd have to call it with the filename

(don't know how you get this transaction ID)

and inside the proxy use the filename if not successful

then raise an error if not you could just copy the file

to other folder which would take successful files (standard file adapter)

for example

Regards,

michal

Former Member
0 Kudos

Hi Michal, Archana,

Thanks for the suggestions.

I have just edited my message to make it clear that the transaction ID will be passed from the source application.

Archana - A custom Adapter I think will be a difficult thing.

Michal -Where should I look for an sample Java Proxy to read a file ? All we want to do is read the file and ofcourse move it to a archive directory.

Regards,

Charu

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>Michal -Where should I look for an sample Java Proxy to read a file

doesn't matter where

it's just a pure jave code to copy a file with a given name

all you need to do is to get the name from the request message

Regards,

michal

Former Member
0 Kudos

We are on webAs 640 and we do not have Java skills so I guess our preference will be to write a ABAP server proxy to read the file and move the file. Any problems with this approach?

Former Member
0 Kudos

I guess you may have to go for custom adapter or adapter modules for doing this.

--Archana

Former Member
0 Kudos

Hi,

You can do this using Module Adapter.

Read the file and store the name in either JAVA or ABAP stack . In the module adapter check for the unqueness of the file.

Regards

Vijaya

Former Member
0 Kudos

Hi Vijaya,

Thanks for the suggestion. I have just edited my message to make it clear that the transaction ID will be passed from the source application. So XI does not have to be knowledgeable about uniqueness or maintain history. Do you still think we have to use a Module Adapter?

Regards,

Charu