‎2008 Jun 17 5:23 PM
I have a flat file with space (multiple spaces between different fields) as a delimiter. The problem is, file is coming from 3rd party and they don't want to change the separator as comma or tab delimited CSV file. I have to load data in ODS (BW 3x).
Now I am thinking to load line by line and then split data into different objects in Transfer rules.
The Records looks like:
*009785499 BC 2988 244 772 200
*000000033 AB 0 0 0 0
*000004533 EE 8 3 2 4
Now I want data to split like:
Field1 = 009785499
Field2 = BC
Field3 = 2988
Field4 = 244
Field5 = 772
Field6 = 200
After 1st line load, go to 2nd line and split the data as above and so on. Could you help me with the code pleaseu2026?
Is it a good design to load data? Any other idea?
Thanks.
‎2008 Jun 17 7:19 PM
Hi Mau,
First capture the data into the internal table (say itab).
Loop at itab.
it_final-field1 = itab+1(9).
it_final-field2 = itab+12(2).
it_final-field1 = itab+16(4).
it_final-field1 = itab+21(3).
it_final-field1 = itab+25(3).
it_final-field1 = itab+29(3).
Append it_final.
Endloop.
&*********** Reward Point if helpful**********&
‎2008 Jun 17 5:25 PM
I think, you have to split the records, record by record.
Like:
LOOP AT ITAB.
SPLIT ITAB-TEXT AT SPACE INTO IT_DATA-FLD1 IT_DATA-FLD2.
APPEND IT_DATA.
ENDLOOP.
Regards,
Naimesh Patel
‎2008 Jun 18 3:38 PM
SPLIT command works between single space. What about for multiple spaces as in my case spaces are multiple and there are no fixed spaces between fields?
‎2008 Jun 17 5:27 PM
you probably have to upload this into a 1 field itab (let's say 1000char length).
loop at your itab into an work area
split work_area-field at space into f1 f2 f3 f4 etc...
move those fields to another itab for processing.
‎2008 Jun 17 6:29 PM
‎2008 Jun 17 6:38 PM
Yes, I will have exactly six fields but different spaces between fields.
‎2008 Jun 17 7:19 PM
Hi Mau,
First capture the data into the internal table (say itab).
Loop at itab.
it_final-field1 = itab+1(9).
it_final-field2 = itab+12(2).
it_final-field1 = itab+16(4).
it_final-field1 = itab+21(3).
it_final-field1 = itab+25(3).
it_final-field1 = itab+29(3).
Append it_final.
Endloop.
&*********** Reward Point if helpful**********&
‎2008 Jun 18 3:41 PM
check this..
DATA: BEGIN OF ITAB OCCURS 10,
WORD(20),
END OF ITAB.
SPLIT 'STOP Two STOP Three STOP ' AT 'STOP' INTO TABLE ITAB.
Now, ITAB has three lines. The first line is blank, the second contains 'Two' and the third contains 'Three' .
‎2008 Jun 18 7:56 PM