Converting an XML file to a DAT pipe delimited file
Hi
I'm trying to create an SSIS Package which converts an XML file into a dat file which is pipe delimited.
I want the package to be generic so that once that minimal modification is needed when using for different files.
I've so far had no luck with this and need some help/assistance.
All help fully appreciated.
Thank you
Umar Javed
The XML file can vary from fixed to variable.
for Fixed, i've done the same thing as you've suggested and parametrized the flat file connection manager.
For The XML source is there any way we can parametrize the location of the XML or XSD files?
For Variable, unfortunately due to restrictions we can not create an intermediate table and then export.
is there any other way?
Thanks
Umar Javed
XSD path can be made dynamic as below
http://picnicerror.net/development/sql-server/define-xsd-file-for-ssis-xml-source-using-expression-2012-04-21/
For variable you can even add them to configurations and then pass them from a file using xml configuration option.
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page
Similar Messages
-
File content conversion for Pipe delimited file
Hi
i have a scenario ( file-xi-proxy) in whch file is coming in a pipe delimited.
my data type is like
DT_ XXXXX
AwardInfo
Header contains some fileds
DetailRecord contains some fileds
trailer contains some fields
what are content conversion parameters i have to use
venkatSedamkar,
Expecting you have one header, multiple details and one trailer then give recordset structure in sender file communication channel as:
Header,1,DetailRecord ,*,trailer,1
In content conversion you should give parameters:
Header.fieldSeparator : |
Header.endSeparator : 'nl'
DetailRecord.fieldSeparator : |
DetailRecord.endSeparator : 'nl'
trailer.fieldSeparator : |
trailer.endSeparator : 'nl'
You may need to change the parameters also according to your strcuture and the file layout. See this SAP help for file content conversion:
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm
Regards,
---Satish -
If you have answer, please provide specific and detailed steps.
Situation 1:
Start:
150+ files in .xls OR .xlsx format
data contains many characters EXCEPT "Tab"
Process:
Use Automator to:
Select Files from Finder window
Convert selected files from xls/xlsx to TAB-DELIMITED file format
End:
150+ files in .txt format
files have identical names to those from "Start:"
data is TAB-DELIMITED
Situation 2:
Start:
150+ files in .xls OR .xlsx format
data contains many characters EXCEPT | (pipe, vertical bar)
Process:
Use Automator to:
Select Files from Finder window
Convert selected files from xls/xlsx to |-delimited file format
End:
150+ files in .txt format
files have identical names to those from "Start:"
data is "|"-delimitedIf your post is addressed to my response then the answer is you have to write your own or search on-line to see if something exists to do what you want.
As you note there is no pre-built script for this.
regards
Message was edited by: Frank Caggiano - Are you certain there isn;t something in Excel to export as a tab delimited file?
This link Convert An Excel Spreadsheet To A Tab Delimited Text File seems to indicate that the function is in Excel already. -
Extract data from Pipe Delimited file
Hi everybody,
Could someone provide me the command to extract data from a pipe delimited file ("|") using Open/Read Data set.
I mean eliminating the delimiter ("|") and just picking the data.
Thanks
MHere you go.. this code snippet parses the input file record by using pipe (variable lv_pipe) as separator, for tab separated file you can use lv_tab like wise...
TYPES: BEGIN OF ts_field,
field(50) TYPE c,
END OF ts_field,
tt_field TYPE TABLE OF ts_field.
DATA: ls_record TYPE string,
ls_input_data TYPE ts_input_data,
lv_tab TYPE x VALUE '09',
lv_pipe TYPE C VALUE '|',
ls_field TYPE ts_field,
lt_field_tab TYPE tt_field,
lv_field_index TYPE syindex,
lv_record_no TYPE syindex.
FIELD-SYMBOLS: <fs_field> TYPE ANY.
OPEN DATASET fv_file_path IN TEXT MODE FOR INPUT.
IF sy-subrc = 0.
DO.
lv_record_no = lv_record_no + 1.
READ DATASET fv_file_path INTO ls_record.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT ls_record AT lv_pipe INTO TABLE lt_field_tab.
CLEAR: lv_field_index, ls_input_data.
LOOP AT lt_field_tab INTO ls_field.
lv_field_index = lv_field_index + 1.
ASSIGN COMPONENT lv_field_index OF STRUCTURE
ls_input_data TO <fs_field>.
IF sy-subrc = 0.
<fs_field> = ls_field-field.
ENDIF.
ENDLOOP.
APPEND ls_input_data TO ft_input_data.
ENDIF.
ENDDO.
CLOSE DATASET fv_file_path. -
Download data into a pipe delimited file
I want to download data from an internal table into a pipe delimited file.
I plan to use FM: SAP_CONVERT_TO_TEX_FORMAT but the system I am working on is BW 3.1.
This FM does not exists in BW 3.1
How can I download data from an internal table into a pipe delimited file?
Please help,
Thanks,
CDPlease use Search before posting, this has been discussed many times already. Not necessarily as "pipe delimited", but delimiter doesn't really matter here. Here is just one of the recent posts:
Write internal table to file GUI_DOWNLOAD or TRANSFER?
Note that all GUI functions only work in the foreground. There are also some solutions in "pure ABAP", like looping through the internal table fields and adding a delimiter. Or a quick and dirty solution - define an internal table with the extra fields for delimiters (mainframe legacy!).
Also questions specific to BW should be posted in the BW forum IMHO, not in ABAP General. Otherwise you'll get a lot of "valuable" suggestions here... -
Pipe delimited file on application server.
Hi , i m creating a text file on application server, i have written below code and file is getting created correctly. however, i want to create pipe delimited file. is there any method for this?
DATA : lv_line(173).
DATA : l_wa_itab_length(4) TYPE c VALUE '173'.
IF NOT p_tab[] IS INITIAL.
SORT p_tab.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
IF sy-subrc NE 0.
MESSAGE 'Error on output file read' TYPE 'E'.
ELSE.
LOOP AT p_tab.
lv_line = p_tab.
TRANSFER lv_line TO p_file LENGTH l_wa_itab_length.
CLEAR p_tab.
CLEAR lv_line.
ENDLOOP.
CLOSE DATASET p_file.
ENDIF.
ENDIF.
REFRESH p_tab.i m pasting below my entire code.
REPORT zmigration_data_download.
FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE.
DATA: d_table_ref TYPE REF TO data.
DATA: d_rfc_db_opt TYPE rfc_db_opt.
DATA: it_opt LIKE rfc_db_opt OCCURS 0 WITH HEADER LINE.
DATA: d_file TYPE string.
PARAMETERS: p_tab TYPE dd02l-tabname OBLIGATORY.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY DEFAULT '/usr/sap/tmp/test.txt'.
SELECT-OPTIONS: s_opt FOR d_rfc_db_opt NO INTERVALS.
START-OF-SELECTION.
REFRESH it_opt.
LOOP AT s_opt WHERE sign = 'I' OR option = 'EQ'.
it_opt-text = s_opt-low.
APPEND it_opt.
ENDLOOP.
CREATE DATA d_table_ref TYPE TABLE OF (p_tab).
UNASSIGN <fs_table>.
ASSIGN d_table_ref->* TO <fs_table>.
IF <fs_table> IS ASSIGNED.
CLEAR <fs_table>.
SELECT * FROM (p_tab) INTO TABLE <fs_table>
WHERE (it_opt).
IF sy-subrc EQ 0.
PERFORM download_file TABLES <fs_table> USING p_file.
MESSAGE i398(00) WITH 'Upload from SAP Successfull'.
ENDIF.
ENDIF.
*& Form download_file
text
-->P_<FS_TABLE> text
-->P_P_FILE text
FORM download_file TABLES p_tab USING p_file.
DATA : lv_line(173).
DATA : l_wa_itab_length(4) TYPE c VALUE '173'.
IF NOT p_tab[] IS INITIAL.
SORT p_tab.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
IF sy-subrc NE 0.
MESSAGE 'Error on output file read' TYPE 'E'.
ELSE.
LOOP AT p_tab.
lv_line = p_tab.
TRANSFER lv_line TO p_file LENGTH l_wa_itab_length.
CLEAR p_tab.
CLEAR lv_line.
ENDLOOP.
CLOSE DATASET p_file.
ENDIF.
ENDIF.
REFRESH p_tab.
ENDFORM. " download_file -
What is the best and most efficient way to read a .xls File and create a pipe-delimited .csv File?
Thanks in advance for your review and am hopeful for a reply.
ITBobbyP85You should have no trouble doing this in SSIS. Simply add a data flow with connection managers to an existing .xls file (excel connection manager) and a new .csv file (flat file). Add a source to the xls and destination to the csv, and set the destination
csv parameter "delay validation" to true. Use an expression to define the name of the new .csv file.
In the flat file connection manager, set the column delimiter to the pipe character. -
Hi
can anybody tell me how the pipe delimited file look like ?? If possible with example. What is the difference between tab delimited, pipe delimited, CSV, flat file, fixed with fomat file and text file ??
Thanks
KumarHey
here is the thing
you have two different words, <i>Delimited</i> and <i>Separated</i>
now if u go with the dictionary meaning then <i>Delimited</i> means in the end which means Pipe should be in the end,and going with the dictionary meaning of <i>Separated</i> means it should be in between .but since we are not English authors i guess u can consider Raj's reply as more authentic.
Its all Business jargo so don't worry too much about it,you have to handle these files in FCC so if u have Pipe in between the entries then give .fieldSeparator as Pipe(|) and if u have Pipe(|) only in the end give .endSeparator as Pipe(|).
Thanx
Aamir -
HI Guys,
can some body explain what a pipe delimited file format is.
thanks
Column Name = WRKAREA_CODE
Format of Pipe Delimited File = 20 Digits
SAP DB Type = CHAR (20)
Description = Work Area Code
WRKAREA_CODE is a field of the table WFAV_WRKAREAHI,
a pipe delimited file is a file in which the content of the file is seperated by a pipe symbol..
example
100|Name|School|age|
*-- Read the File From PC
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V_FILENAME
TABLES
DATA_TAB = I_FILE
EXCEPTIONS
OTHERS = 17.
*-- Split the Record into Individual Fields
SPLIT X_FILE-LINE AT '|' INTO X_PRSTR-VCODE
X_PRSTR-CURR
X_PRSTR-ODLEVEL
X_PRSTR-DLEVEL
X_PRSTR-EDATE
X_PRSTR-SCODE
X_PRSTR-TCODE
X_PRSTR-DCODE
Thanks
Mahesh
Thanks
Mahesh -
Writing schema for pipe delimited file
Hi all,
I have to write a pipe delimited file (|) in .txt at a particular location. I am not seeing this option in native schema creation.
The file should be written in following format:
Header1
Line1
Line2
Line3
Header2
Line1
Line2
Line3
Can we write a schema for such kind of scenario?
Here is an example for the format specified above:
Orderno1|Customer1|site1
Partno1|price1|Quantity1
Partno2|price2|Quantity2
Partno3|price2|Quantity1
Orderno2|Customer2|site2
Partno1|price2|Quantity2
Partno1|price2|Quantity2
Partno2|price2|Quantity3
Please help me out.
Thanks in advance,
Abhishek.Hi Abhishek,
You are right there is no option in native schema creation wizard for generating '|' delimiter file.
But you can achieve this problem with another approach.
step 1: Create schema file for ',' (comma) delimiter through native format builder wizard.
step 2: open the created XSD file and replace ',' with '|' option in terminatedBy command of each element.
step 3: Attach this updated XSD file to your outbound(write) service.
Thanks
Praveen
Edited by: PraveenT2 on Nov 19, 2008 11:01 PM -
The selected file does not appear to be a valid comma separated values (csv) file or a valid tab delimited file. Choose a different file.
I guess your question is, "what's wrong with the file?"
You're going to have to figure that out yourself, as we cannot see the file.
Importing into Address book requires either a tab-delimited or a comma-delimited file. You can export out of most spreadsheets into a csv file. However, you need to make sure you clean up the file first. If you have a field that has commas in the field, they will create new fields at the comma. So, some lines will have more fields than the others, causing issues like the error you saw. -
Converting lower case to upper case data of flat file
Hi All,
I have a requirement purche order creation by using bapi function module.My requirement is when I am uploading the flat file and if flat file contains the data in lower case then before passing it to the function module i want to convert it in to Upper case. please tell me how can I do this.
its very urgent.
Regards,
Amit.hi,
Use translate statement ..
DATA letters(3) TYPE C.
MOVE 'abc' TO letters.
TRANSLATE letters TO UPPER CASE.
write : letters.
Also refer
/people/alvaro.tejadagalindo/blog/2006/12/21/does-abap-lacks-of-string-processing
Regards,
Santosh -
Hi guys,
I am uploading the data from a file which is in the application server and in pipe delimiter format.
This file in the format like .... let us take 100 records among those one record is header, 98 data records and one trailer record. These are seperated by the record locater like header with 0, data record with 1 and trailer with 9.
So what i am doing is uploading that file first of all into one internal table I_ARFILE, then splitting the data at pipe into 3 different internal tables. In the mean time I am doing the validations also for the number of records...
like there should not be more than one header, and one trailer........
here I am pasting my code.....
IF l_subrc = 0.
LOOP AT I_ARFILE.
READ TABLE I_ARFILE INTO WA_ARFILE.
SPLIT WA_ARFILE AT C_PIPE INTO WA_ARHEADER-P_RECTYPE
WA_ARHEADER-P_PRCID
WA_ARHEADER-P_SENDR
WA_ARHEADER-P_CDATE
WA_ARHEADER-P_CTIME
WA_ARHEADER-P_OBTYP
WA_ARHEADER-P_SEQNO
WA_ARHEADER-P_FRTXT.
IF WA_ARHEADER-P_RECTYPE = 0.
APPEND WA_ARHEADER TO I_ARHEADER.
DESCRIBE TABLE I_ARHEADER LINES V_ITABLINES.
VALIDATION FOR NUMBER OF HEADER RECORDS
IF V_ITABLINES <> 1.
MESSAGE 'NUMBER OF LINES READ ARE NOT SAME' TYPE 'E'.
LEAVE PROGRAM.
ENDIF.
CLEAR V_ITABLINES.
ELSE.
SPLIT I_ARFILE AT C_PIPE
INTO WA_ARITEM-P_RECTYPE
WA_ARITEM-p_xblnr
WA_ARITEM-p_bldat
WA_ARITEM-p_budat
WA_ARITEM-p_blart
WA_ARITEM-p_awkey
WA_ARITEM-p_kunnr
WA_ARITEM-p_xref1
WA_ARITEM-p_xref2
WA_ARITEM-p_xref3
WA_ARITEM-p_wrbtr
WA_ARITEM-p_zterm
WA_ARITEM-p_zuonr
WA_ARITEM-p_rstgr
WA_ARITEM-p_wskto
WA_ARITEM-p_sgtxt.
IF WA_ARITEM-P_RECTYPE = 1.
APPEND WA_ARITEM TO I_ARITEM.
ENDIF.
VALIDAITON FOR THE NUMBER OF DATA RECORDS.
DESCRIBE TABLE I_ARITEM LINES V_ITABLINES.
DESCRIBE TABLE I_ARFILE LINES V_ITABLINES1.
V_ITABLINES1 = V_ITABLINES1 - 2.
IF V_ITABLINES1 <> V_ITABLINES.
MESSAGE 'NUMBER OF LINES READ ARE NOT SAME' TYPE 'E'.
LEAVE PROGRAM.
ENDIF.
LOOP AT I_ARITEM.
V_BAL1 = V_BAL1 + I_ARITEM-P_WRBTR.
V_DIS = V_DIS + I_ARITEM-P_WSKTO.
ENDLOOP.
CHECKING THE SUM OF THE BALANCE AMOUNT OF ALL THE RECORDS AND BALANCE AMOUNT IN TRAILER RECORD
IF V_BAL1 <> WA_ARTRAILER-TOBAL.
MESSAGE 'TOTAL AMOUNT IS NOT EQUAL TO THE SUM OF ALL THE AMOUNTS' TYPE 'E'.
ELSE.
CHECKING THE SUM OF THE DISCOUNT AMOUNT OF ALL THE RECORDS AND BALANCE AMOUNT IN TRAILER RECORD
IF V_DIS <> WA_ARTRAILER-TODIS.
MESSAGE 'TOTAL DISCOUNT AMOUNT IS NOT EQUAL TO THE SUM OF ALL THE DISCOUNT AMOUNTS' TYPE 'E'.
ENDIF.
CLEAR V_BAL1.
APPEND WA_ARITEM TO I_ARITEM.
CLEAR WA_ARITEM.
CLEAR WA_ARFILE.
CLEAR V_ITABLINES.
CLEAR V_ITABLINES1.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
ELSE.
READ TABLE I_ARFILE INTO WA_ARFILE INDEX V_ITABLINES.
SPLIT WA_ARFILE AT C_PIPE INTO WA_ARTRAILER-P_RECTYPE
WA_ARTRAILER-COUNT
WA_ARTRAILER-TOBAL
WA_ARTRAILER-TODIS.
IF WA_ARTRAILER-P_RECTYPE = 9.
APPEND WA_ARTRAILER TO I_ARTRAILER.
ENDIF.
DESCRIBE TABLE I_ARTRAILER LINES V_ITABLINES.
IF V_ITABLINES <> 1.
MESSAGE 'NUMBER OF LINES READ ARE NOT SAME' TYPE 'E'.
LEAVE PROGRAM.
ENDIF.
CLEAR WA_ARFILE.
CLEAR V_ITABLINES.
ENDIF.
*CLEAR WA_ARFILE.
CLEAR V_ITABLINES.
CLEAR V_ITABLINES1.
ENDIF.
ENDLOOP.
In this code something wrong like....
I have to modify this code so that i can split the file based on the record indicator to different internal tables.
if you see my code I am going wrong after i split the data into header internal table... did the validations then I put the else condition and split the same record again into 2nd internal table. But I have to take the second record once the first one is filled..........
Can any one guide me how to do that plz...... I am bit confused with this
SRIHi,
Please check , first you need to split the file and move header, item, trailer , then using these internal tables do your validations
DESCRIBE TABLE I_ARFILE LINES V_LIN
READ TABLE I_ARFILE INTO WA_ARFILE INDEX 1.
IF SY-SUBRC EQ 0.
SPLIT WA_ARFILE AT C_PIPE INTO WA_ARHEADER-P_RECTYPE
WA_ARHEADER-P_PRCID
WA_ARHEADER-P_SENDR
WA_ARHEADER-P_CDATE
WA_ARHEADER-P_CTIME
WA_ARHEADER-P_OBTYP
WA_ARHEADER-P_SEQNO
WA_ARHEADER-P_FRTXT.
APPEND WA_ARHEADER TO I_HEADER.
ENDIF.
READ TABLE I_ARFILE INTO WA_ARFILE INDEX v_LIN.
IF SY-SUBRC EQ 0.
SPLIT WA_ARFILE AT C_PIPE INTO WA_ARTRAILER-P_RECTYPE
WA_ARTRAILER-COUNT
WA_ARTRAILER-TOBAL
WA_ARTRAILER-TODIS.
APPEND WA_ARTRAILER TO I_TRAILER.
ENDIF.
* FIRST DELETE TRAILER THEN GO FOR HEADER
READ TABLE I_ARFILE INTO WA_ARFILE INDEX V_LIN.
DELETE I_ARFILE INDEX SY-TABIX
READ TABLE I_ARFILE INTO WA_ARFILE INDEX 1.
DELETE I_ARFILE INDEX SY-TABIX.
LOOP AT I_ARFILE INTO WA_ARFILE.
SPLIT I_ARFILE AT C_PIPE
INTO WA_ARITEM-P_RECTYPE
WA_ARITEM-p_xblnr
WA_ARITEM-p_bldat
WA_ARITEM-p_budat
WA_ARITEM-p_blart
WA_ARITEM-p_awkey
WA_ARITEM-p_kunnr
WA_ARITEM-p_xref1
WA_ARITEM-p_xref2
WA_ARITEM-p_xref3
WA_ARITEM-p_wrbtr
WA_ARITEM-p_zterm
WA_ARITEM-p_zuonr
WA_ARITEM-p_rstgr
WA_ARITEM-p_wskto
WA_ARITEM-p_sgtxt.
APPEND WA_ARITEM TO I_ITEM.
ENDLOOP.
aRs -
FCC for Broken pipe delimited file
Hi Fellow SDNer's
I have a broken pipe delimited flat file . I want to do file content conversion for the same .
Can you please help me with the parameters
I am on PO 7.4 dual stack
Thanks
Ninad SaneHi Ninad
It looks like the broken pipe character is outside the US-ASCII character set.
ASCII Code - The extended ASCII table
You can try using the ASCII character to see if it works or not:-
Header.fieldSeparator = '0xA6'
Check also the following thread that mentions the use of non US-ASCII character.
Content conversion - endSeparator and fieldSeparator with unusual separators
In particular, it mentions OSS note 1936206 - if you have the corrections in place, you can try using MessageTransformBean and specifying the encoding with the following additional parameter.
xml.fieldSeparator.encoding=ISO-8859-1
Rgds
Eng Swee -
Pipe Delimited file with comma
Hi Guys,
I have a pipe '|' delimited csv file. One of the field contains ',' (comma) for few records. The data loads fine uptill the PSA but when I load the data in the cube, that field is coming empty as well as some other feilds which donot have a comma in it.
The delmiter in IP and DS is used '|' pipe.A pipe within quotes? I don't think you can do that with regex. But you can simply itearate through the chars of the String with an "isInsideQuotes" boolean flag and do a manual replacement using StringBuffer.
Maybe you are looking for
-
New symptoms since latest firmware update
OK I have a 1tb sky hd box which hasn't had any really annoying issues up until the new firmware update (the one with the new Kids tile which is annoying in its own right). Anyway, I have been watching the cricket on SS2 and every so often when they
-
Need some help in ARCHITECTURE level for upgrading SAP BW 3.5 to SAP BI 7.0
HI all, I am a consultant in a small company, i am curently handling upgradation project i need some help in ARCHITECTURING this complete project, please share me your knowledge, like process flows what information i need to get from clients before s
-
Final Cut Fails to Launch - No Error Message
I have tried the following: -Trashed Prefs. -Loaded and used FCP Rescue -Completely wiped the machine of Final Cut Studio and reloaded Still, the following happens: Once I trash the prefs or run rescue, FCP loads fine. I can work on saved projects, e
-
How can I scroll down with Mavericks OSX10.9.4? The right-hand scroll bar is missing.
-
AF_Modules/XMLAnonymizerBean Question
All, I have been using the Anonymizer for changing my XML prefix on output and it has been working great. I ran into a problem with the anonymizer and I received the following in the MDT. Error encountered during parsing of RNIF message type RNIF Req