Skip to Content

SAP PI 7.4: Dynamic Archiving in SFTP

Hi Experts,

I have pass-through SFTP to SFTP scenario where I have to dynamically archive the PDF files based on the file name and in case the folder does not exist then I have to create one. I have thought of two solutions but I do not have the sandbox to try them out. I am mentioning below the two scenarios and any queries related to it. Kindly provide us with your opinion and feedback -

1. Two Interfaces Solution: In this, I will first create an interface that will pick the PDF file from source directory and place it in a temporary folder in the target. The second interface will pick PDF files from the temporary directory and using ASMA and UDF will create a dynamic target directory to place the files in the actual archive directory. My confusion here is that, since it is a pass-through scenario whether creating a dummy Data Type, Message Type, Service Interface, Message Mapping and Operation Mapping for the second interface will work or not (as I need to write a UDF to define the target directory).

2. Java Program/Script: I will create the pass-through interface and will call the java program/script from "Run OS command after file processing" but my challenge is that I have limited knowledge on scripting and I have never done this before. It will be helpful if someone can outline the steps on how to write the code, where to place the java code and how to call it from the receiver SFTP channel.

Regards,

Arkesh

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 22, 2016 at 12:43 PM

    Arkesh,

    can you please explain how directory name and filename are related ?

    Lets say your fileName is :

    ABC.pdf then folder would be /Test/ABC

    XYZ.pdf then folder would be /Test/XYZ

    if above is the case then you can create dynamic directory by using DynamicConfiguration module + variable substitution.

    And yes as above you have mentioned the pdf will miss for the first approach because before mapping the pdf will be the mainpayload but in mapping as you are using Dynamic UDF so the main payload will be your dummy message type .

    alternatively you can use java mapping to assign Dynamic Folder and also make the output as the pdf itself.

    Br,

    Manoj

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Arkesh,

      • I am reading the PDF file as main payload
      • I added two interfaces in the interface determination step, one for place the PDF file in receiver SFTP server, one for archive the PDF file to dynamic directory.
      • To send the PDF file to receiver SFTP server there will be no mapping
      • To send the PDF file to dynamic archive directory there will be java mapping to set the dynamic directory.
      • With in the java mapping i am just reading the original PDF file name and using this file name i am setting the dynamic directory for archive the PDF file, i am not touching the content of the payload, i am just sending as it is.
      • There will be no attachments, only main payload which is PDF file.
      • You just need to select the Adapter specific message attributes in the receiver SFTP channels.
      • For normal PDF file select the fileName attribute only, for dynamic directory select fileName and Directory.

      Regards,

      Praveen.

  • Posted on Aug 22, 2016 at 11:11 AM

    Hi Arkesh,

    The easiest solution is the first option which is creating two interfaces.

    First interface is for the main scenario (Source to Target Folder) and second interface is for your dynamic archiving. And use a receiver split with different operation mapping so you only have to pick the source file once.

    Best regards,

    Marc

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Marc,

      Thank you for taking time out to reply to my query.

      In my scenario, I have to transport PDF files from source SFTP to target SFTP server so it is a pass-through scenario.

      One of my friends just called me and said that this scenario is not possible because in the second interface, while creating dummy objects, the PDF file goes missing in the target dynamic directory.

      Regards,

      Arkesh

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.