Tuesday 3 July 2018

File Counter in FileName Implementation - SAP CPI/HCI

We have a requirement to add the sequence number at target filename. In this we need to append the counter sequence number at the end of filename.

Whenever the file is processed at CPI, the file number need to generated and appended as below.
Output_(FileName)_0001.xml
Output_(FileName)_0002.xml
Output_(FileName)_0003.xml


Main Iflow process:


 File counter logic process:



This is SOAP to SFTP scenario, whenever the data received, it triggers the Counter sub process in parallel.

Content modifier:

Add the Global variable name in Property tab to retrieve the stored value (file count) in data store. 

Note: Add the Default value to 1.
Below Body tab shows the input data send from SOAP (C4C) with retrieved value in P_OPERATION field


Mapping :

Mapping is used to add the logic of increment from the retrieved global value.
P_OPERATION field value is  5 then it adds 1 to it and output will be 6 now.


Content modifier:

Frame the file in the content modifier itself.
Read the FileCount value from the mapping step and frame it in CamelFileName expression with value: /IncidentOUT/Output_POC_${header.FileCount}.xml

/IncidentOUT   -Directory

Output_POC_${header.FileCount}.xml    - Filename

${header.FileCount}  - 6 for our case


Write Variable:

Here we update the current file sequence number into the global variable at data store.


Receiver channel:

No need to specify directory and filename in the receiver SFTP channel



Happy Learning !!!



No comments:

Post a Comment