cancel
Showing results for 
Search instead for 
Did you mean: 

File to File and then Call ABAP Program and pass file name and location

MG3
Contributor
0 Kudos

Hi

I am new to PI and am working on the following requirement and some guidance would help:

A file is picked up from a third party server using FTP and is put in an SAP server in a specific location. After I have put in the file successfully, I need to call an ABAP program and provide the name and location of the file for further processing by the ABAP program.

Although I am familiar with File to File, how can I add in the ABAP call with the filename and location? I do not want to pass any other information to the ABAP program.

Thanks for your help.

Manoj

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

hi bhavanisankar.solasu,

>>>mightbe that is possiable with standad beans "RequestResponseBean " & "ResponseOnewayBean"

he needs to call the program after the file is generated and not before so how can those beans help ?

I don't see a way

Regards,

Michal Krawczyk

MG3
Contributor
0 Kudos

Thanks, Michal, bhavanishankar for your response.

Michal - just wondering why I should create a new file using the OS command after a file transfer. In the receiver file adapter, I would be specifying the target directory anyways, and after a successful transfer, the file would be available in that location. I just need to get that file name and path and call the RFC. Is this possible?

Thanks

Manoj

former_member184681
Active Contributor
0 Kudos

Hi Manoj,

The solution described by Michal is a little bit tricky. Let me shed some more light on it. In addition to the "original" interface file created by the receiver file adapter, you create an additional file (by means of the OS command). And for that file, you have to develop a simple (but separate) scenario in PI that will read this file and execute your RFC-enabled function module.

It is not possible to call an ABAP program directly from the file adapter.

Hope this helps,

Greg

Former Member
0 Kudos

I think, you can use BPM for that requirement.

MG3
Contributor
0 Kudos

Thanks Greg. So that means I overwrite the existing file that was originally created with the OS command. I understand that I would need to specify %f.

In the File to RFC, do I need to import the RFC into the IR? Is there any way for me to call the RFC without having to import it? I was told this was possible, but I'm not sure how.

Sorry if these questions are too elementary, but am a bit confused.

Thanks Ordu - Sorry, BPM is not an option at the moment.

Thanks for your help

Manoj

former_member184681
Active Contributor
0 Kudos

So that means I overwrite the existing file that was originally created with the OS command.

No, you do not overwrite the file. You create an additional file that contains the name and directory of the original file. Then you process this file with your additional interface "file to RFC".

In the File to RFC, do I need to import the RFC into the IR?

Yes, you do have to import. You also require a mapping from the file to the RFC.

Hope this helps,

Greg

MG3
Contributor
0 Kudos

Thanks, Greg.

No, you do not overwrite the file. You create an additional file that contains the name and directory of the original file. Then you process this file with your additional interface "file to RFC".

I think I get what you're saying. This additional file would have the file and the path in it's content. I would then use this as a source (FCC?) for Mapping with the RFC. Right? Would you have a sample OS script to do the above?

Thanks

Manoj

former_member184681
Active Contributor
0 Kudos

I think I get what you're saying. This additional file would have the file and the path in it's content. I would then use this as a source (FCC?) for Mapping with the RFC. Right?

Exactly and yes, FCC would be helpful

Would you have a sample OS script to do the above?

Actually it depends on the operating system on which your PI system is standing. For instance for Windows, you might try with the following as a start point (but I was not able to test it, so I can't guarantee it will do the job):

cmd.exe /C "%f %F > C:\target_directory\%DATE%_%TIME%.txt"

In case you needed more, try googling on "windows batch script" or similar.

Hope this helps,

Greg

MG3
Contributor
0 Kudos

Hi Greg

Super! That's helped me a lot. Will give this a shot and update soon.

Thanks, again, for all your help.

Manoj

MG3
Contributor
0 Kudos

Hi Greg

Just another question - what happens if I have, say, 5files in the source directory and want to get the file names for each file? I assume the OS command will generate 5 text files? And in the subsequent File to RFC scenario, will the ABAP program be triggered 5 times? Or is there a way for me to pass the filenames all at once to the ABAP program?

Thanks

Manoj

former_member184681
Active Contributor
0 Kudos

Dear Manoj,

You are right, with the batch script above you will get one "additional" file for each "original" file. But with a simple change to the script, you could write all file names to the same "additional" file:

cmd.exe /C "%f %F >> C:\target_directory\filenames.txt"

Changes comparing to the original script:

- thanks to ">>" instead of ">", you will append the file instead of replacing it

- constant target file name in order to always write to the same file.

As a result, you will write all file names into one file "C:\target_directory\filenames.txt".

Hope this helps,

Greg

Answers (2)

Answers (2)

Former Member
0 Kudos

mightbe that is possiable with standad beans "RequestResponseBean " & "ResponseOnewayBean"

pls refer below doc:

http://wiki.sdn.sap.com/wiki/display/HOME/UsingRequestResponseBeanModuleinFILE+Adapter

responce mapping:

u can handle mapping based on naming convention of the creation file

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

simple way:

file - to file and OS command at the end

the OS command creates a new file with the filename and location (%f and %F)

and you can use this new file to do a file - RFC (or abap proxy) which will call the abap program (or RFC as it's a good practice to call abap reports from the interface anyway)

Regards,

Michal Krawczyk