manvidya payload read , without using split * * not working, replaced split with tokenize

 import com.sap.gateway.ip.core.customdev.util.Message

import groovy.util.XmlParser

import java.util.HashMap;

import java.util.*;


def Message processData(Message message) {

   

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

      //  body=body.replaceAll("\\*","#")

        

    def lines = body.split('\n')


// Split the second line by '*' delimiter (escape the asterisk *)

def fields = lines[1].tokenize('*')


// Modify the 5th field (index 4) to substring the first 4 characters

fields[5] = fields[5][0..3]


// Reconstruct the second line with modified field

lines[1] = fields.join('*')


// Join the lines back to form the output string

 def outputString = lines.join('\n')

 message.setBody(outputString)

//message=message1;

    return message

}

/*

import com.sap.gateway.ip.core.customdev.util.Message

import groovy.util.XmlParser

import java.util.HashMap;

import java.util.*;


def Message processData(Message message) {

   

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

        body=body.replaceAll("\\*","#")

        

    def lines = body.split('\n')


// Split the second line by '*' delimiter (escape the asterisk *)

def fields = lines[1].split("#")


// Modify the 5th field (index 4) to substring the first 4 characters

fields[4] = fields[4][0..3]


// Reconstruct the second line with modified field

lines[1] = fields.join('#')


// Join the lines back to form the output string

 def outputString = lines.join('\n')

 message.setBody(outputString)

//message=message1;

    return message

}

*/


Popular posts from this blog

pss book : శ్రీకృష్ణుడు దేవుడా, భగవంతుడా completed , second review needed. 26th April 2024

pss book: గురు ప్రార్థనామంజరి . completed 21st july 2024

pss book: కధల జ్ఞానము read review pending. 25th june 2024