on 06-20-2017 3:10 PM
Hi Experts,
We are working on File to IDoc scenario where the input file would like below:
Input :-
"Name","Employee_No","Dept","Location" ==> Header line
"Ramu","439554","Manlog","Newyork" ==> Line item
"Raju","837823","ISU","Chicago ==> Line item
We need to remove " " characters from the input flat file & convert it to as below without " ":
Output :-
Name,Employee_No,Dept,Location ==> Header line
Ramu,439554,Manlog,Newyork ==> Line item
Raju,837823,ISU,Chicago ==> Line item
Bold letters above is the content of file. Once I remove the " " characters then using CSV to XML converter I can transform it to XML and map it to IDoc structure.
Hence, kindly help me with groovy script to remove " " as above or any other alternate solution you can provide in HCI.
-Ramu.
Hello Ramu,
Standard converter will work with only one level data.
If I am not wrong you need to populate fields under Header and LineSplit(as per the above screenshot),if that's the case refer my blog.
If both line and lineaplit fields needs to be populated from input CSV in one shot then no other go you have to write a script and do you have any identifier in your CSV so that we can differentiate line and linesplit values.
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shivaram,
Thank you for your useful & valuable glog 🙂
In my case we need to populate data to two sub nodes Header & Line as shown below:
Also input file consists of header line which we need to exclude while populating the data to subnodes.
Please find snippet of input file:
Please help me to achieve this requirement.
Thanks,
Ramu.
Hello Ramu,
As per my understanding CSV to XML converter will automatically remove those double quotes post conversion..I dont think its required to remove those manually before conversion.
Also those double quotes are very much important to differentiate the fields from converter perspective.
Please give a try from your end with Converter( Its working fine for me ) and still if you are able to locate the double quotes post conversion please do reply back.Will try to help on that if required.
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shivaram,
Thanks for your response. My input file will have header names in top column * line item values below. In my case we need to convert that CSV to XML with 3 sub-nodes and under that sub-nodes actual fields exist. Just like below.
For eg: I have given "Header" node fields as below, similarly fields are present under "Line" & "LineSplit" subnodes.
Kindly suggest me on CSV to XML converter configuration in HCI as below to achieve this requirement.
- Ramu.
Hi
You can try this in groovy script ---
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String;
body = body.replaceAll('\\"','');
def messageLog = messageLogFactory.getMessageLog(message);
if(messageLog != null){
messageLog.setStringProperty("Logging#1", "Printing Payload As Attachment")
messageLog.addAttachmentAsString("ResponsePayload:", body, "text/plain");
}
return message;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Experts,
Kindly help on this.
-Ramu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.