This is the simple IFlow for generating a file name with a sequential number in SAP CPI and you can easily implement this flow in any IFlows in CPI to create a sequentially numbered File name and also the same can be used in the message mapping.
Below is the iFlow to generate the sequential number.
- Content Modifier: Declared the local variable [count] in Exchange property and the first filename starts with 5000(default value).
2.Groovy Script: Incrementing the [count value] by using the below script. First imported the property value of count to script then incrementing the value by 10(based on need, we can change the increment count) and finally the increased value set to the count property.
def Message processData(Message message)
def body = message.getBody(java.lang.String) as String;
def messageLog = messageLogFactory.getMessageLog(message);
def out= message.getProperty(“count”);
messageLog.setStringProperty(“Logging#1”, “Printing Payload As Attachment”)
messageLog.addAttachmentAsString(“ResponsePayload:”, out, “text/plain”);
3. Write Variable: Once the count value set by the script, we need to store the property value. So the write variable is used to store the updated value of count property, whenever the iFlow starts the respected value will be storing in this Variable.
4. Receiver: Adding the count property value in the filename of the receiver.
The configuration part is over. Go ahead and deploy the iFlow, we will get a sequential number in the filename like (5000,5010,5020,50++) shown below.
Hope this blog post will help the beginners, to generate the files with a sequence number.