Thursday, 10 June 2021

Groovy Script for removing the first two line from the csv/flat file in SCI/CPI/HCI

 Groovy script to remove first two lines from the string or csv file or flat file:


Remove first 2 lines:

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import com.sap.it.api.mapping.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;

def Message processData(Message message) {

def body = message.getBody(java.lang.String) as String;

def lines=body.split("\n").drop(2).join("\n")

message.setBody(lines)
return message;
}

Input:

1Bricks measurement 24/60cm
2Ravikumar
3RAmu
4Dinesh
5Vishnu
6Pradab

Output:

3RAmu
4Dinesh
5Vishnu
6Pradab


Take first two lines:













Thursday, 3 June 2021

Split the value by special character @ from the string using groovy script in SAP CPI/SCPI

Split the value by special character @ from the string using groovy script in mapping level in SAP CPI/SCPI.

Written a script to handle the logic on the splitting of two string using a special character

Groovy script:

import com.sap.it.api.mapping.*

def void filterStatus(String[] values, Output output, MappingContext context) {
def filtered = values.findAll { v -> v.startsWith('1')|| v.startsWith('Z6')}
filtered.each { v -> output.addValue(v.split(/@/)[1]) }

}


Input: 1@2020-05-23 22:00:00

Output: 2020-05-23 22:00:00




SAP CPI Testing tool -Figaf introduced

 Testing Tool for CPI message testing. Figaf Tool.


You can test without writing code or enabling the trace in the iflow.
  • Mock Testing
  • Secured Testing
  • Testing with multiply endpoints

Figaf Testing Tool