cancel
Showing results for 
Search instead for 
Did you mean: 

Search string in Text file without File Content Conversion

shweta_walaskar2
Contributor
0 Kudos

Hello,

We have a requirement where XI is used to transfer huge files(in MBs) in .dat format.

This is just a pass through scenario and no conversion is involved.

There is a risk that XI picks up incomplete file when it is being written.

Somehow,the partner is not convinced about using parameter 'Msecs to wait before Modification check' as it is quite critical that file should be processed only when it is finished.

They have suggested another approach that at the end of file ,they would have a unique identifier ,say, string EOF

We should search for this string in the file and only if it is there,file should be picked and placed on target FTP server.

There are different types of files and formats can be different,so it makes no sense to spend lot of efforts in content conversion for each type of file when no mapping is required.

Can anyone please let us know if there is a way to search for this string in the file and only if it is there,file would be picked.

Thanks a lot in advance.

Best Regards,

Shweta

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi shwetha,

As per the requirement specified, I think Lookup would be a better solution.

Refer the below blog:

/people/sundararamaprasad.subbaraman/blog/2005/12/09/making-csv-file-lookup-possible-in-sap-xi

Regards,

shweta_walaskar2
Contributor
0 Kudos

Hi Hareen,

Thanks for the link.But this is not feasible at the moment because Oracle drivers are not installed in our XI system.

Regards,

Shweta

Answers (4)

Answers (4)

shweta_walaskar2
Contributor
0 Kudos

New question posted on the same issue,hence,closing this one

Former Member
0 Kudos

Hi Shweta,

As far as I understand, you have to control this while picking up the file only(that is in sender channel), as JAVA mapping comes into the picture at mapping phase.

That is why I thought of Java Module option.

It will work in the same way as 'Msecs to wait before Modification check' would have worked, meaning, it will be checking continuosly whether 'EOF' string is there or not.

One the string is found, file will be picked up and sent to PI.

-Supriya.

Former Member
0 Kudos

Hi Shweta,

'Msecs to wait before Modification check' parameter is not supported for the FTP protocoal.

Please check the SAP Note 821267, Q 22, for this.

I guess, you have to develope the JAVA module for this requirement.

This module will check the file at sender side, once he will find the string 'EOF', the file will be sent to PI for further processing.

You have to make an entry of this module on Sender channel.

-Supriya.

shweta_walaskar2
Contributor
0 Kudos

Hello,

We could create a Java mapping which waits until it finds this EOF in the file.

So,even if the file is being written,it will be picked by XI and will be passed to this Java Mapping .

We use a String variable which holds contents of the file.

Now the question is,say,the file is incomplete,it is picked by XI,execute method in Java mapping is called and String variable is populated.

After sometime,when the file is complete,will this String variable be overwritten?(execute method called again?)

If not,then this Java mapping will be of no use

Please let us know.

Thanks a lot.

Regards,

Shweta

former_member207622
Contributor
0 Kudos

Hi Shweta ,

You will need to write a batch program whichl will check the file size after regular intervals and say if the re is no modification in file. it will move the file from location A to location B where XI will poll and pick the file .

Thiis batch program has to be written at the FTP location . since its FTP we cannot do much with XI

never had done anything like this ,

Hope my idea helps

Regards

Ninad

shweta_walaskar2
Contributor
0 Kudos

Hello Supriya,

Thanks a lot for the information.

Can we do the same using Java Mapping?

you mentioned "This module will check the file at sender side, once he will find the string 'EOF', the file will be sent to PI for further processing"

Atleast in case of Java mapping,by the time we check if EOF is there,file will be consumed.

How can we stop PI to pick up this file till this check happens?

Thanks.

Regards,

Shweta

shweta_walaskar2
Contributor
0 Kudos

Hi Ninad,

Nice to hear from you after such a long time

Since this needs to be done at partner end ,it has been avoided till now.

They prefer to go for an approach which can be implemented at our end.

Regards,

Shweta

former_member207622
Contributor
0 Kudos

Hi Shweta

" how can we stop PI from picking the file till the time EOF being checked "

Can you use the URLS to stop start communication channels externally in your java mapping program .

/people/william.li/blog/2007/05/04/control-communication-channels-externally-without-using-rwb

In case you are writing java mapping

else convince your client for batch program

Regards

Ninad

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

I prefer your existing approch is best.

Regards,

Raj

shweta_walaskar2
Contributor
0 Kudos

Hello Raja,

Thanks.But how to implement this?

How can I search for a string in a file?

Regards,

Shweta

rajasekhar_reddy14
Active Contributor
0 Kudos

first approch means what you have implemented already.. lookup not a best solution for your req.

convince your customer .:)

Regards,

raj

shweta_walaskar2
Contributor
0 Kudos

Hi Raja,

I am sorry,I think,I am not able to explain my problem with Java Mapping correctly.

My Java mapping checks if EOF is there or not.But what action should I take if EOF is not there?

When Java mapping is executed,file is already consumed, so if I set the message status to fail,file will be lost.

So,even if the file is being written,it will be picked by XI and will be passed to this Java Mapping .

We use a String variable which holds contents of the file.

Now the question is,say,the file is incomplete,it is picked by XI,execute method in Java mapping is called and String variable is populated.

After sometime,when the file is complete,will this String variable be overwritten?(execute method called again?)

If not,then this Java mapping will be of no use

I would like to know if this Java mapping is called again and again till this file size changes?

Please let me know.

Thanks.

Regards,

Shweta

Former Member
0 Kudos

hello shweta,

Here is a batch script that will do this for you:

                                                                          • batch file begin ********************************************

@ ECHO OFF

:READFILE

SET | FIND "SEARCH_STRING" source.txt > NUL

IF ERRORLEVEL 1 GOTO READFILE

IF ERRORLEVEL 0 GOTO END

sleep 5

GOTO READFILE

:END

                                                                        • batch file end ***********************************************

here, SEARCH_STRING is the string that will be searched in file source.txt. This SEARCH_STRING denotes the end of file (the file is ready to be transferred).

This batch file should be called from PI "Run OS command before processing of the message".

I tried this on my system and it worked for me.

Just check at your end. I hope this will solve your query.

Regards, Gaurav.

Edited by: Kr.gaurav on Sep 9, 2010 3:54 PM

shweta_walaskar2
Contributor
0 Kudos

Hello Gaurav,

Thanks a lot for the reply.

I have some questions:

1) This batch file will be placed on XI server?

2) From where does the file name source.txt come?Is it an example?If yes,what should I use as filename in my case?

Please let me know.

Thanks.

Regards,

Shweta

Former Member
0 Kudos

Hello shweta:

Please find my answers below:

1) This batch file will be placed on XI server?

Yes this batch file will be placed on the XI Server. Eg: E:\usr\sap\gobal\command.bat

2) From where does the file name source.txt come?Is it an example?If yes,what should I use as filename in my case?

The source.txt is just an example. You can enter the filename of the file where you want to check the string for end of file. This File can be any file on the XI Server. You can also pass the filename as its relative path. Example: "E:\usr\sap\source.txt"

Hope this answers your query.

Regards, Gaurav.

shweta_walaskar2
Contributor
0 Kudos

Thanks Gaurav,

But XI picks these files from a remote FTP server and hence,these files are not on XI server.

How does it work in this case?

Thanks.

Regards,

Shweta