Introduction:

Being SAP PI consultant we all know how Dynamic Configuration works with File adapter and how to set the target filename dynamically.Now we have started with SAP HCI era and need to find how to achieve the same.Here is the blog which showcase the same by using Apache Camel File Processing Parameters in Content Modifier.

Lets discuss various use cases in detail.

1. How to set Source File Name to Target File Name

Create integration Project like below

SAP_HCI_DC_SCENARIO1_1.png

Step 1: Configure the Sender SFTP Channel

SAP_HCI_DC_SCENARIO1_2.png

Step 2: Configure Content Modifier to set the source file name to target file name.


SAP_HCI_DC_SCENARIO1_3.png

CamelFileName: Parameters which holds File Name in Apache Camel Framework (Upon which SAP HCI-PI is built on).

file:onlyname.noext: Holds the filename text without considering Extension.


There are also other parameters which can utilized( See the below table )

 

Expression Returns
file:name HCI\InputFile.xml
file:name.ext xml
file:name.noext HCI\InputFile
file:onlyname InputFile.xml
file:onlyname.noext InputFile
file:ext xml

 

Step 3:Configure the receiver SFTP Channel like below

SAP_HCI_DC_SCENARIO1_4.png

Go ahead and deploy the integration project.Now you will have a file in the target SFTP folder with filename same as source filename.


2. How to set target filename dynamically based on key field from incoming message.

Configuration: Create integration project similar to Use Case 1 and repeat the Steps 1 and 3 .


Step 2: Content Modifier configuration


SAP_HCI_DC_SCENARIO2_3.png

Below are parameters used in the content modifier.

${date:now:yyyyMMdd}: Captures current date of file processing.

${header.User}, ${header.Group}: Captures values from incoming file.


Go ahead and deploy the integration project.Now you will have a file in the target SFTP folder with dynamic filename based on input file.


3. How to set target filename and target folder structure directly (By leaving the Directory and FileName Blank)

Configuration: Create integration project similar to Use Case 1 and repeat the Step1


Step2:

SAP_HCI_DC_SCENARIO3_3.png

${date:now:yyyyMMdd}: Captures current date of file processing.

${header.RecordCount}: Holds number of records in the input file.

${header.User}, ${header.Group}: Captures values from incoming file.


Step3:

SAP_HCI_DC_SCENARIO3_5.png

Go ahead and deploy the integration project.Now you will have a file in the target SFTP server with dynamic filename based on input file and in the target folder which is set in the content modifier step.


Conclusion:

Hope this blog helped beginners to dynamically set filename and target folder in SAP HCI using Content Modifier.


Reference:

[1] Content Modifier:

SAP HANA Cloud Integration (Internal, SAP HCI OEM)

[2] SFTP Adapter:

SAP HANA Cloud Integration (Internal, SAP HCI OEM)

[3] Apache Camel File Configuration:

Apache Camel: File Language


Regards,

Sriprasad Shivaram Bhat

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. Apu Das

    Hi Sriprasad,

    thanks a lot for the awesome blog. I have made my life easy. I was looking for that badly.

    Thanks,

    Apu

    (0) 
  2. Eng Swee Yeoh

    Hi Sriprasad

    Thanks for sharing this. It is indeed useful reference especially as PI/PO developers get themselves familiar with Apache Camel.

    May I suggest that you include a link to the appropriate Apache Camel resource which lists the various parameter reference available?

    Regards

    Eng Swee

    (0) 
  3. Aditya Mani

    Hi Sriprasad,

    I want to pick current date file from SFTP server , in File name i am giving as abc${date:now:yyyyMMdd}.txt but it is not working.

    Can you Please help me on this.

    Regards,
    Aditya

    (0) 
    1. Hemachandan A S

      Hi Aditya,

      Your expression is trying to capture the current date of file processing so if i am right first you need to capture the last modification date of the file and then try to compare it with current date which could be done with the help of any scripting code.

       

      In order to capture the last modification date a file then modify your expression with help of below :

       

      https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

       

      Also try to match your consumer folder date format something like MM/dd/yyyy HH:mm and if any luck works let me know the result.

      Cheers!

      Chandan

      (0) 

Leave a Reply