How to convert flat file to XMl without key field value
Hi experts,
I have a input CSV Flat file which has got one HEADER line and Multiple Detail records.
I do not have any key field value to convert this FLAT file to XML using normal file content conversion.
Is there any module or Bean which can be used to convert this Flat File to XML.
Or any other remedy to overcome this problrm.
Thanks in advance.
Regards
Pradeep
Hi Saurabh,
Thanks for the reply.
Ur understanding is perfectly alright.Lets say my file is like below.
Account Number,Account Name,Currency,Unclear Balance,Account Balance010205000033,VAISHNAVI SALES CORPN,0.00,0.00,350000.00
010205000034,CHAKKA ENTERPRISES,0.00,-641350.47,8649.53
010205000035,SEHGAL TRADING COMPANY,338665.00,-220.00,461115.00
010205000036,SHUBH LAXMI AGENCIES,0.00,0.00,0.00
010205000037,EMPIRE AGENCIES,0.00,-245.11,0.00
010205000038,PIONEER AGENCIES,0.00,-696386.00,303614.00
I am not using the first line in the mappiing.
Are you saying that I need to ignore the first line while doing the conversion using Recordset OFFSET ?
Or do I need to make a single structure taking all the fields from header as well as details and while defining the structure I need to ignore the fields from header?
Please suggest.
Similar Messages
-
Converting flat file to XML using JMS
Hi,
I want to convert flat file to xml. My sender adapter is JMS,
Can anyone tell me that how to do that conversion ? Conversion is very simple.
Can we use File content conversion in JMS Sender ? any link or blog ? or any other idea to achieve this ?
Regards
KulwinderHi,
The pdf has been removed from that link i suppose.
Anyways, go through the below help, everything that is there in "HowToConveModuleJMS.pdf" has been mentioned in this...
http://help.sap.com/saphelp_nw04/helpdata/en/24/4cad3baabd4737bab64d0201bc0c6c/content.htm
Hope it would surely help you.
You can go through the below link, for better understanding..
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a05b2347-01e7-2910-ceac-c45577e574e0
Regards,
Swetha.
Edited by: Swetha Reddy on Feb 26, 2009 5:30 AM -
URGENT : Program to convert flat file to XML file.
Hello,
Good Morning. I want an urgent program to convert a flat file seperated by '/' to an XML file format and store that in the the application server. If any one has done such a developement, could you please send me the code.
The flat file format is as below :
72/070414/114147/11973//100-//EA/00000000///04198//RRT0/RC23///////353825001511172/72/070414/123620/11973//1000//EA/00000000///04198//RRT0/RC23///////354762008125236/72/070414/125411/13814//1000//EA/00000000///04198//INV/ID06///////90000000002697/72/070414/140820/11973//1000//EA/00000000///04198//RRT0/RC23///////353057002479718/72/070414/145438/13814//1000//EA/00000000///04198//INV/ID06///////90000000002739/72/070414/145438/11973//1000-//EA/00000000///04198//INV/ID06///////353057002479718/72/070414/150008/13814//1000
It needs to be filtered by removing the '/' and also grouped based on two fields namely store number and transaction number. The sample XML output required is as below :
<?xml version="1.0" encoding="ISO-8859-1"?>
<MT_POLL07 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../MT_POLL07.xsd">
<MessageHeader>
<File>
<Name>C:/kai/perl/storemaster_home/stores/09100/inbound/POLL07.DOS</Name>
<CreatedDate>Wed Feb 7 13:09:15 2007</CreatedDate>
<TotalRecordNo>19</TotalRecordNo>
</File>
</MessageHeader>
<Transaction>
<TransactionHeader>
<TRANSACTION>20070414001559</TRANSACTION>
<STORE_NO>09100</STORE_NO>
<BOFTTP>72</BOFTTP>
</TransactionHeader>
<Item>
<BOFTDT>070414</BOFTDT>
<BOFTTM>114147</BOFTTM>
<BOFSKU>11973</BOFSKU>
<BOFUPC></BOFUPC>
<BOFQTY>100</BOFQTY>
<BOFQTN>-</BOFQTN>
<BOFCST>0</BOFCST>
<BOFCSN>+</BOFCSN>
<BOFUM>EA</BOFUM>
<BOFHRF>00000000</BOFHRF>
<BOFSRF></BOFSRF>
<BOFVND></BOFVND>
<BOFLOC>04198</BOFLOC>
<BOFEQT></BOFEQT>
<BOFEQN>+</BOFEQN>
<BOFRTP>RRT0</BOFRTP>
<BOFREA>RC23</BOFREA>
<BOFCID></BOFCID>
<BOFAUT></BOFAUT>
<BOFCUR></BOFCUR>
<BOFPTP></BOFPTP>
<BOFUPT></BOFUPT>
<BOFUMR></BOFUMR>
<BOFSRN>353825001511172</BOFSRN>
<GMNUMBER>1</GMNUMBER>
</Item>
<Item>
<BOFTDT>070414</BOFTDT>
<BOFTTM>123620</BOFTTM>
<BOFSKU>11973</BOFSKU>
<BOFUPC></BOFUPC>
<BOFQTY>1000</BOFQTY>
<BOFQTN>+</BOFQTN>
<BOFCST>0</BOFCST>
<BOFCSN>+</BOFCSN>
<BOFUM>EA</BOFUM>
<BOFHRF>00000000</BOFHRF>
<BOFSRF></BOFSRF>
<BOFVND></BOFVND>
<BOFLOC>04198</BOFLOC>
<BOFEQT></BOFEQT>
<BOFEQN>+</BOFEQN>
<BOFRTP>RRT0</BOFRTP>
<BOFREA>RC23</BOFREA>
<BOFCID></BOFCID>
<BOFAUT></BOFAUT>
<BOFCUR></BOFCUR>
<BOFPTP></BOFPTP>
<BOFUPT></BOFUPT>
<BOFUMR></BOFUMR>
<BOFSRN>354762008125236</BOFSRN>
<GMNUMBER>2</GMNUMBER>
</Item>
</Transaction>
</MT_POLL07>
Please send me the code : It is urgent. Thanks in advace. Points to be rewarded.hi !
Check with this thread discuss the same
http://www.sap-img.com/abap/sample-xml-source-code-for-sap.htm
Flat file to XML
CONVERTION OF FLAT FILE TO XML : NO OUT PUT FOUND
Converting Idoc flat file representation to XML
how to convert flat file into IDOC-XML
Regds
Abhishek -
How to convert Flat file(.txt) data to an Idoc format(ORDERS05)
Hi,
How to convert Flat file(.txt) data to an Idoc format(ORDERS05). If any FM does the same work please let me know.
thanks in advance,
Chand
Moderator message : Duplicate post locked. Read forum rules before posting.
Edited by: Vinod Kumar on Jul 26, 2011 11:11 AMHi,
For more information, please check this link.
http://sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a
Have a look at the FM IDOC_XML_FROM_FILE. May be it helps...
Regards -
How to convert .stl file into .xml file. Subtitles to IMPORT INTO FCPro
I have a subtitles file which was created in dvd studio pro. I exported that file and made a .stl file (which can be opened with TextEdit).
I need to import that file into FCP to then make a quicktime file w/subs to be exported.
I'm trying to use TitleExchange which tells you you CAN convert .stl files into .xml (FCPro type of file) but when I try to import the .stl subtitle file into TitleExchange to be converted to .xml I get the following error:
Can't make "" into type boolean. (-1700)
Can someone help?
Thanks!!!
PaulaCan anyone help me?
I absolutely need to import the subtitles into Final Cut and re-writing all of them manually would take forever.
Please let me know if there is any program I need to use.
Thanks for all tips
Paula -
How to convert Xls file into Xml file
Hi,
I am trying to convert Xls file into Xml but there is no any direct procedure for it
Pls help me out to convert Xls file into Xml file
Thanks
Anushreeyou will require to write a module in your file adapter for the same.
ref: /people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter as mentioned in the earlier post.
Else you can also use Conversion Agent to read the same.
Ref: http://help.sap.com/saphelp_nw04/helpdata/en/43/4c38c4cf105f85e10000000a1553f6/content.htm -
File content conversion without key field
Hi,
i have a input file with the following format:
posvalue1;posvalue2;posvalue3;posvalue4
posvalue1;posvalue2;posvalue3;posvalue4
posvalue1;posvalue2;posvalue3;posvalue4
posvalue1;posvalue2;posvalue3;posvalue4
posvalue1;posvalue2;posvalue3;posvalue4
footervalue1;footervalue2;footervalue3
footervalue1;footervalue2;footervalue3
i just need the information from pos lines and the footer is not needed. the only indicators are:
the empty line between
the number of fields
maybe i could use the keyfieldvalue:
in posvalue2 i have only numbers (diffrent) in footervalue2 i have only chars (diffrent)
has anyone an idee?
regards
J.Hi
yes you have to use the key field value as the posvalue1.
if you do not want the footer informatuion in the target side then inthe grahical mapping do not map footer fields with the target structure.
to convert the text file into XML file you can use the following parameters
RECORD.fieldSeparator :;
RECORD.fieldNames :KEY,FNAME,LNAME,AGE
RECORD.keyFieldValue :1
DETAIL.fieldSeparatr :;
DETAIL.fieldNames :KEY,SALARY,EMPID
DETAIL.fieldNames :2
Note:these parameters are accoding to the structure given below.
suppose you have a structure like as below
data (0..unbounded)
record (0..unbounded)
key (1..1)
fname (1..1)
lname (1..1)
age (1..1)
detail (0..unbounded)
key (1..1)
salary (1..1)
empid (1..1)
and the input file will look like as below
1,aaa,bbb,23
2,12000,10838
1,ccc,ddd,23
2,13000,10830
if you still face the problem please reply me back
Thanks
Rinku -
Content Conversion without key field value
Hi all,
I want to do a content conversion which includes a record structure Header,1,Detail,*
I dont have any key field value in the header nor in the detail. Can this be achived using FCC or should i go for Java.
Rgds
AdityaHi Aditya,
I think if u having multiple records then one shud hav key fields,
pls check 4th point in this guide
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/troubleshooting%2bthe%2bfile%2badapter
Also check this discussion::File Content Conversion(SenderFileadapter) fields parameters
Thanks, -
Problem converting flat file to XML using JMS Adapter
I need to take an MQSeries message in a flat file format and convert it to XML before processing. I have configured the modules as described by the screenshot located here:
http://www.radesix.com/JMSConfig.jpg
The message is received however it isn't converting to XML. When I view the payload I get the message indicated by the screenshot located here:
http://www.radesix.com/JMSError.jpg
I am new to XI. Any ideas?For simple plain conversion here is a config, which works in our system:
(left parameter key, right parameter value, module key always the same)
Transform.Class com.sap.aii.messaging.adapter.Conversion
TransformContentType text/xml;charset=utf-8
xml.conversionType SimplePlain2XML
xml.addHeaderLine 0
xml.processFieldNames fromConfiguration
xml.documentName SA02_Identnummer
xml.documentNamespace urn:mycompany-com:logistics:DFT:HWL
xml.structureTitle SA02_Identnummer_Satz
xml.fieldNames Satzart,Identnummer,Status
xml.fieldFixedLengths 2,10,3
Be aware, that you must delete all spaces in the config, especially when you copy and paste values.
For struct. conversion the entries are a little bit more complex.
Regards
Stefan -
Convert flat file to XML document and store into Oracle database
First:
I have a flatfile and created external table to read that file in Oracle
Now I want to create an XML document for each row and insert into Oracle database, I think that XMLtype.
Could you please provide me some information/steps.
Second:
Is there performance issues, because everyday I need to check that XML document stored in the database against the in coming file.
Thank You.Oracle 11g R2 Sun Solaris
Flat file is | (pipe delimited), so I did create an EXTERNAL Table
row1 a|1|2|3|4
row2 b|2|3|4|5
row3 c|6|7|8|9
I want to store each record as XML document. So it will be easy to compare with next day's load and make insert or update.
The reason is:
First day the file comes with 5 columns
after some days, the file may carry on some additional columns more than 5
In this case I do not want to alter table to capture those values, if I use XML than I can capture any number of columns, CORRECT!. Please make me correct If I am wrong.
This is the only reason to try to use the XMLType (XML Document)
On Everyday load we will be matching these XML documents and update it if there is any column's value changes
daily average load will be 10 millions and initial setup will be 60-80 millions
Do I have anyother option to capture the new values without altering the table.
Please advise!. -
Hi
i just want to read flat file and convert it into xml but there are some problem ,it throws a ArrayIndexOutOfBoundException.Here is code.
import java.io.*;
import java.util.*;
class FlatXMLBudget {
public static void convert(List data, OutputStream out)
throws IOException {
Writer wout = new OutputStreamWriter(out, "UTF8");
wout.write("<?xml version=\"1.0\"?>\r\n");
wout.write("<Budget>\r\n");
Iterator records = data.iterator();
while (records.hasNext()) {
wout.write(" <LineItem>\r\n");
Map record = (Map) records.next();
Set fields = record.entrySet();
Iterator entries = fields.iterator();
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
String name = (String) entry.getKey();
String value = (String) entry.getValue();
// some of the values contain ampersands and less than
// signs that must be escaped
//value = escapeText(value);
wout.write(" <" + name + ">");
wout.write(value);
wout.write("</" + name + ">\r\n");
wout.write(" </LineItem>\r\n");
wout.write("</Budget>\r\n");
wout.flush();
public static String escapeText(String s) {
if (s.indexOf('&') != -1 || s.indexOf('<') != -1
|| s.indexOf('>') != -1) {
StringBuffer result = new StringBuffer(s.length() + 4);
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '&') result.append("&");
else if (c == '<') result.append("<");
else if (c == '>') result.append(">");
else result.append(c);
return result.toString();
else {
return s;
public static void main(String[] args) {
try {
/*if(args.length<1)
System.out.println("Usage: FlatXMLBudget infile outfile");
return;
InputStream in = new FileInputStream("d:\\file.txt");
OutputStream out;
int a=in.available();
System.out.println("dd:"+a);
/*if (args.length < 2) {
out = System.out;
else {*/
List results = BudgetData.parse(in);
int aa=results.size();
System.out.println("dd:"+aa);
out = new FileOutputStream("d:\\flattoxml.xml");
convert(results, out);
catch (IOException e) {
System.err.println(e);
import java.io.*;
import java.util.*;
class BudgetData
public static List parse(InputStream src) throws IOException
// The document as published by the OMB is encoded in Latin-1
InputStreamReader isr = new InputStreamReader(src, "8859_1");
BufferedReader in = new BufferedReader(isr);
List records = new ArrayList();
String lineItem;
while ((lineItem = in.readLine()) != null)
records.add(splitLine(lineItem));
return records;
// the field names in order
public final static String[] keys = {
"AgencyCode",
"AgencyName",
"BureauCode",
"BureauName",
"AccountCode",
"AccountName",
"TreasuryAgencyCode",
"SubfunctionCode",
"SubfunctionTitle",
"BEACategory",
"On-Off-BudgetIndicator",
"FY1976", "TransitionQuarter", "FY1977", "FY1978", "FY1979",
"FY1980", "FY1981", "FY1982", "FY1983", "FY1984", "FY1985",
"FY1986", "FY1987", "FY1988", "FY1989", "FY1990", "FY1991",
"FY1992", "FY1993", "FY1994", "FY1995", "FY1996", "FY1997",
"FY1998", "FY1999", "FY2000", "FY2001", "FY2002", "FY2003",
"FY2004", "FY2005", "FY2006"
private static Map splitLine(String record)
record = record.trim();
int index = 1;
Map result = new HashMap();
for (int i = 1; i < keys.length; i++)
//find the next comma
StringBuffer sb = new StringBuffer();
char c;
boolean inString = false;
while (true)
c = record.charAt(index);
if (!inString && c == '"') inString = true;
else if (inString && c == '"') inString = false;
else if (!inString && c == ',') break;
else sb.append(c);
index++;
if (index == record.length()) break;
String s = sb.toString().trim();
result.put(keys, s);
index++;
return result;
[output/error]
java.lang.StringIndexOutOfBoundsException: String index out of range: 71
at java.lang.String.charAt(String.java:444)
at BudgetData.splitLine(BudgetData.java:55)
at BudgetData.parse(BudgetData.java:16)
at FlatXMLBudget.main(FlatXMLBudget.java:79)
Exception in thread "main"
[output/error]
Can any one help me about this problem.Off-by-one error.
In a String of length 70, for example, the characters are numbered from 0 to 69 in Java. Your program is written as if they were numbered from 1 to 70. So when you try to get #70, the exception occurs.
But if you want to use commas as a delimiter to break a string into substrings, it's much easier just to use the split() method of String than to write all that code you have there. -
How to convert text file into xml file format with and check that with DTD
I have an text file with | seperator . I have to convert this to an xml file and check with DTD present with me..
plz help me outcan i get some code that how to compare the xml with dtd or just give the DTD name with an XML
-
How should convert text file into XML file?
I do a project "WEB SERVER LOG ANALYZER" using JSP. For that i copy the content of log file into the other file . how i convert it into XML file . xplain with coding
Read this [page.|http://www.devx.com/getHelpOn/10MinuteSolution/20356]
-
How to convert flat file type from DAT to ASC
hello all
i am trying to download a flat file and trying to upload it in another program.
for this i am using gui_upload and gui_download function modules.
if i download the file as ASC and upload with ASC there is no problem.
if i download the file as DAT and upload with DAT its giving an exception invalid file type
if i download the file as DAT and upload with ASC its giving an exception bad data format.
but in real senario my customer is sending a flat file with DAT type and i am unable to upload it.
how to solve this problem?Hi,
when uploading DAT pass file type as 'ASC' and give HAS_FIELD_SEPARATOR = 'X'.
For other types see the code below.
CASE P_RECTYP.
WHEN 'DAT'.
MOVE 'X' TO L_FLDSEP.
MOVE 'ASC' TO L_TYPE.
WHEN 'ASC'.
MOVE ' ' TO L_FLDSEP.
MOVE P_RECTYP TO L_TYPE.
WHEN 'BIN'.
CLEAR L_TYPE.
MOVE P_RECTYP TO L_TYPE.
MOVE ' ' TO L_FLDSEP.
WHEN OTHERS.
MOVE 'X' TO L_FLDSEP.
MOVE 'ASC' TO L_TYPE.
ENDCASE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILENAME
FILETYPE = l_type
HAS_FIELD_SEPARATOR = l_fldsep
Regards,
Vasanth -
How to convert text file into xml file
Hi Folks,
I am genarating list of data into text file, but i want to genarate xml file for this text file. How to achive this , please let me know. Thanks.
regards
Vishalhi Vishal,
Use<b> GUI_DOWNLOAD</b> FM and give the file name as <b>file.xml</b> with BIN Mode....
i.e,
Download internal table to presentation server file(PC)
DATA: ld_filename TYPE string value <b>file.xml</b>,
Pre version 4.7 declaration e_file like rlgrap-filename.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
call function 'GUI_DOWNLOAD'
exporting
filename = ld_filename
<b>filetype = 'BIN'</b>
tables
data_tab = it_datatab[]
exceptions
file_open_error = 1
file_write_error = 2
others = 3.
Regards,
Santosh
Maybe you are looking for
-
Interest on customer early payments
Hi All, As we have a FINT kind of SAP functionality to calculate interest on arrears, we need a similar kind of functionality for automatic calculation of customer incentives in the form of interest expense. For e.g. If a customer invoice is raised o
-
Issue in table control scroll bar
Hi experts, In Table control I used the following code, Refresh control 'TCDATA' from screen '200'. If i use this code i cant able to scroll the data when the table control having multiple lines. Can any one suggest me?. what i need to do for this..
-
My iPod touch home button doesn't work how can I fix it
My iPod touches home button doesn't work how can I fix it and how much will it cost if I get apple to fix it ?
-
Hi all, What's the command to see the uptime server?. With 'top' monitor, I can't see it. Thanks for all. Álvaro
-
How to consider the frieght cost
Hi All, I want to add my transportation cost (frieght cost) for the PO. Can you please explain different ways to do this. Thanks in advance! Thanks, Jana