cancel
Showing results for 
Search instead for 
Did you mean: 

file processing

Former Member
0 Kudos

HI,

I have a source file in which the data consists of some file names and their path. Now in file to file scenario, i have to read the source file and pick the file names and their path, and send the data in those files to receiver side.

Please guide me how to proceed for this?

Thanks,

Anil.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Pick up data from source file row by row..so you can pick up your file names and their path.

See the blog <u>/people/sravya.talanki2/blog/2005/08/16/configuring-generic-sender-file-cc-adapter

Cheers!

Samarjit

bhavesh_kantilal
Active Contributor
0 Kudos

Why would you want to do this?

Dont you think the solution provided above is a better and more clean solution?

Regards

Bhavesh

Former Member
0 Kudos

Hi Bhavesh,

What solutions you give it's absolutely correct.

But his file consist file name & path,i think it would be better to picked up data row by row.

Cheers!

Samarjit

bhavesh_kantilal
Active Contributor
0 Kudos

Not convinced ,

If I got the requirement correct, the file content do not contain the file name and path, but , the requirement is that the target data needs the file name and path.

This can be handled quite easliy using my technique.

Reading Line by Line-- How is it going to help read the filename and path?

Regards

Bhavesh

Former Member
0 Kudos

HI Bhavesh, Samarjit

Thank you for giving replies.

Let me elaborate on the requirement:

A source file say source.txt is having data like c:\filename1.txt, c:\filename2.txt. Now read the source.txt and validate whether the two files that are mentioned are exisiting in the specified directory, if so, transfer the files to receiver side.

If the files are not existing then raise an exception.

This is the requirement.

Thanks,

anil.

bhavesh_kantilal
Active Contributor
0 Kudos

Incorrect answer. Content deleted.

Message was edited by:

Bhavesh Kantilal

henrique_pinto
Active Contributor
0 Kudos

Bhavesh,

I can't see how to use BPM for this. Would you mind explaining?

I'd go for Java proxy.

Regards,

Henrique.

bhavesh_kantilal
Active Contributor
0 Kudos

Henrique,

Right on.I failed to read the question perfectly,

<i>A source file say source.txt is having data like c:\filename1.txt, c:\filename2.txt. Now read the source.txt and validate whether the two files that are mentioned are exisiting in the specified directory, if so, transfer the files to receiver side.</i>

I failed to read that the source file will inturn contain the other filenames to be picked up.I hhad thought that the set of filenames were available previously. This would not be possible using a BPM .

Kindly ignore my previous reply. Like pointed by you guess java proxies are the way to go.

Regards

Bhavesh

Former Member
0 Kudos

Hi,

We can do it in two ways ,

one is asexplained by above , we can use BPM.

in BPM

first receive step -- here you will receive the file with file names , the verify the file name is existed or not ,( wehave one bapi to check it also),

next based on the response from bapi , yu can raise the exception ?

by sending this to control step , and raising the alert or cancel the process.

if file is existed then you can continue..

The second method is ,

do it by a ABAP program to check the file is existed ot not and trigger the proxy to do the rest of scenario..

The another approach is maitain a UDF in maping first receive the message in that message you can have the file names , by java code you can test the file is existed or not , Jco, and if existed the continue else , throw the runtime exception

see the below link for another approach

Dynamic folder - in payload

Regards

Chilla

prabhu_s2
Active Contributor
0 Kudos

cant we use UDF for this. write a code to check if the file exits in the folder and if not rasie an exception which will stop the interface from further processing?

bhavesh_kantilal
Active Contributor
0 Kudos

It is possible but doing an IO inside your mapping is not recommended.

You will be reading data inside the mapping , i.e read the enite file content inside mapping which is not recommended at all.

Regards

Bhavesh

henrique_pinto
Active Contributor
0 Kudos

With simple mapping you could even check if files are there, but from requirement, he needs to read the files if they are there and pass them. Message mapping/UDF wouldn't satisfy that.

It'd be possible with java mapping returning a message type with 0...unbounded occurrence (you'll need to use <xi:Messages><xi:Message1>... tags for that). The mapping would parse the source message for filenames and paths, then read the files. If they're not there, raise exception. If they are there, create a DOM document with the <xi:Messages><xi:Message1> tags and add the files (after parsing) to these tags (assuming both files have same message type). No need for BPM.

But as Bhavesh pointed, it is not recommended to have full IO (and not simple lookup) at mapping runtime. Thus, just get the same idea and implement insidade java proxy instead of java mapping.

Regards,

Henrique.

Former Member
0 Kudos

Hi,

If you are able to check the file name is exited or not with java , then better to write a java mapping , in that first read the file and you cna test , if it is not there the you can throw the RuntimeException from mapping , ihope this is the best solution

Regards

Chilla

prabhu_s2
Active Contributor
0 Kudos

is it becoz of perfromance issues for not recommending that approach?

bhavesh_kantilal
Active Contributor
0 Kudos

No. What happens if the server goes down somewhere in between the IO process?

You are going to end up doing a transactional handling feature over which you have no control in case of netwrok failures etc and so this is not recommended.

Regards

Bhavesh

prabhu_s2
Active Contributor
0 Kudos

okie got it and by the use of java proxies u have a better control on it

henrique_pinto
Active Contributor
0 Kudos

Prabhu,

how would you restart a failed mapping, for example?

If it is maintained as a proxy, you can restart the failed message.

Regards,

Henrique.

prabhu_s2
Active Contributor
0 Kudos

do u mean i cannot reporcess any failed messages from moni?

bhavesh_kantilal
Active Contributor
0 Kudos

You can, but will you be able to restart from the point where the error occured? No.

What if you have moduifed some data in the file in the mapping using the Java IO and some error occcurs and when you restart the message the mapping gets executed again and the same the data will be updated again which you might not need actually etc.

regards

Bhavesh

henrique_pinto
Active Contributor
0 Kudos

You could even restart it, but then you'd have to run the entire scenario until mapping. If you had any prior steps, they'd be redone (maybe generating some error).

As a proxy, if any error occurs, then sender side would guarantee delivery (since the sending process was not completed). Also, you'd restart from the point in the scenario where the error occurred.

Regards,

Henrique.

prabhu_s2
Active Contributor
0 Kudos

okie...thkx bhavesh and henrique for the clarification on this point.

henrique_pinto
Active Contributor
0 Kudos

Sure, no problem.

Regards,

Henrique.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

This is a standard requirement.

1. In the sender file adapter , select Adapter Specific Attributs --> FileName and Directory.

2. In the message mapping use this code inside a UDF to read the filename and directory,

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

DynamicConfigurationKey key2 = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

"Directory”);

String FileName = conf.get(key1);

String Directory = conf.get(key2);

Regards

Bhavesh