cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Archive Folder (based on date) on FTP server

suwandi_cahyadi
Contributor
0 Kudos

Dear Experts,

I have some interface scenarios of XML -> IDoc.

I archive the XML file on the FTP server every time PI process the XML file to an archive folder. Can I dynamically archive the XML file to another sub folder which is named by the date.

For example, if today is March, 3rd 2014. The XML files will be archived to archive/20140303/file.xml

To achieve this, I realize I need a way to dynamically set the date subfolder.

Can we use the Run Operating System Command? Because I think the command will be run at the server which hosts the Adapter Engine instead of the FTP server.

Thank you,

Suwandi C.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hello Suwandi,

I had pretty the same task few days ago. I dit it using Java mapping.

1) I use the standard archiving procedure to some folder in a FTP.

2) I made file channel, which takes files from archive folder.

3) In java mapping I set the new directory, which depends from the date from the current file.

4) Profit!

If you need an example of Java mapping, I can post it for you. However, it wasn't so hard.

iaki_vila
Active Contributor
0 Kudos

Hi Dimitry,

You can share the code with a brief explanation in the wiki section or in a blog for further help to SCN members.

Regards.

suwandi_cahyadi
Contributor
0 Kudos

Hi Dmitry,

Thank you for the reply.

Sorry for re-visiting this issue, I've just got the chance to check for this.

Can we create an Integrated Configuration solution in which it will be just moving/passing the file from source to target? Because I have many type of files (with different filename and different content structure) in the archive folder and I want to arrange them to per-date subfolder.

Because AFAIK, I have no Message Mapping or any mapping logic in the Integrated Configuration.

Thank you,

Suwandi C.

Former Member
0 Kudos

Yeah, why not? However, if you pay for traffic in SAP PI, it's not the best solution.

You can check it here. Moreover, if you do it not in FTP, you can use OS-commands for that.

ankit_srivastava3
Participant
0 Kudos

Hello Suwandi,

If your XML contains any tag with date on which it is generated? If yes, then try using variable substitution.

Regards,

Ankit

iaki_vila
Active Contributor
0 Kudos

Hi Suwandi,

If i was you i would use a java mapping or UDF to do the archive work, it's easier to develop, debug and to maintain it that to do with OS commands, at least for me.

Regards

Former Member
0 Kudos

Hello,

>>Can we use the Run Operating System Command? Because I think the command will be run at the server which hosts the Adapter Engine instead of the FTP server.

Yes, u can use OS commands, but IMO error handling in case of OS command is not very efficient - that's the only drawback with this option.

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Suwandi,

Yes you can use Run OS command to move the archive files to other directory.

Write a script to move the files from one directory to other directory.

Thanks,

Satish.


former_member184720
Active Contributor
0 Kudos

Hi Suwandi  - Can we use the Run Operating System Command? Because I think the command will be run at the server which hosts the Adapter Engine instead of the FTP server

This is true. Command will run on the OS on which your AE is hosted.

However you can write a java script to move the the files to desired archive directory and execute it with OS commands.

Incase you would like to avoid the scripts then define another file-file interface(pass through) and place the file.. We have a blog on dynamic file name in pass through interface. You can make use of it..

suwandi_cahyadi
Contributor
0 Kudos

Hi Hareesh,

Thank you for the reply.

From the links given from you. I see that I must create the DT, MT, etc..

In my scenario, I have many kinds of file in the archive folder with different filename and content structure. Does this mean I have to create many pass-through interface for each type of file?

Can I use an Integrated Scenario which will just move the file from source to target for all kinds of file?

Thank you,

Suwandi C.