Manuvidya change request , not worked with * split alternative is

reading csv file as array ; checking specific row and verifying coloums and modifying data and 

resending back, 

no xml convertion; read as array as lines; checking require index and change its content. 








see the output file

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[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.replaceAll("#","\\*"))
//message=message1;
    return message
}





input

ISA*00*          *00*          *01*002331536      *ZZ*PHOENIXUS2     *230911*1628*U*00401*1104     *0*P*^~
GS*IN*002331536*PHOENIXUS2*20230911*162848*1104*X*004010~
ST*810*1104~
BIG*20230904*6100001992**ANSI testing PHNINT~
REF*PK*6100001992~
DTM*011*20230904~
IT1*5*3*EA*600**BP****PL*5~
TDS*187200~
TXI*ST*72.00~
CTT*1*3~
SE*9*1104~
GE*1*1104~
IEA*1*1104~


output

ISA*00*          *00*          *01*002331536      *ZZ*PHOENIXUS2     *230911*1628*U*00401*1104     *0*P*^~
GS*IN*002331536*PHOENIXUS2*20230911*1628*1104*X*004010~
ST*810*1104~
BIG*20230904*6100001992**ANSI testing PHNINT~
REF*PK*6100001992~
DTM*011*20230904~
IT1*5*3*EA*600**BP****PL*5~
TDS*187200~
TXI*ST*72.00~
CTT*1*3~
SE*9*1104~
GE*1*1104~
IEA*1*1104~        

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