‎2009 Jan 22 12:25 PM
Hi Guys,
I have taken a text file into my inernal table. Now i want to separate the entries in the internal table whenever a tab occurs and place the formatted entries into a new internal table.
How do i go about this?
Thanks and regards,
Frank
‎2009 Jan 22 12:30 PM
Hi ,
You can split the string at horizontal tab .
You can use the Split command and split the string at
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB , e.g.
split g_f_str at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into g_f_str1 g_f_str2.
Regards
Arun
‎2009 Jan 22 12:28 PM
hi,
ur requiremnet is not clear........do u have it in an internal table or after getting the file how to insert..r u using any functional mosule for text..
‎2009 Jan 22 12:30 PM
Hi ,
You can split the string at horizontal tab .
You can use the Split command and split the string at
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB , e.g.
split g_f_str at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into g_f_str1 g_f_str2.
Regards
Arun
‎2009 Jan 22 12:30 PM
see help on SPLIT statement and to specify the TAB character you can use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
‎2009 Jan 22 12:32 PM
I am using an FM to upload the text file separated by tabs in an internal table. Now, the internal table consists of a single row for every entry.
Now i need to transfer the contents of this internal table to another Internal table containing for e.g 10 fields so that after the 1st tab, the entry is placed inot the 1st field, and after the 2nd tab the entry is place into the 2nd field and so on....
‎2009 Jan 22 12:41 PM
Hi,
When you are uploading the tab delimited text file then you can use the internal table with fields instead of flat internal table.
USE FM GUI_UPLOAD
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'.
Pass the values to the FM parameter and data will be uploaded in to the correcsponding fields. the order of the fields in file and internal table should be same.
‎2009 Jan 22 7:25 PM
Hi, Frank
Following Code help you in this way but you must Saparate the Entries by an Saparater Char, like in the following Example i Saparated all entries by ',' hope this will solve your problem
loop at it_crow.
clear: zfsl_stinfo.
split it_crow at ',' into zfsl_stinfo-mandt "here is the solution of you problem i think
zfsl_stinfo-st_id
zfsl_stinfo-st_n
zfsl_stinfo-st_fn
zfsl_stinfo-st_reg
zfsl_stinfo-st_ph
zfsl_stinfo-st_pm.
insert zfsl_stinfo.
if sy-subrc = 0 .
commit work.
count = count + 1.
else.
write: / , 'Insert Failed for', zfsl_stinfo-mandt,
zfsl_stinfo-st_id,
zfsl_stinfo-st_n,
zfsl_stinfo-st_fn,
zfsl_stinfo-st_reg,
zfsl_stinfo-st_ph,
zfsl_stinfo-st_pm..
endif.
endloop.
write: count , 'Records were inserted'.Please Reply if any Issue,
Kind Regards,
Faisal
Edited by: Faisal Altaf on Jan 23, 2009 12:25 AM
‎2009 Jan 23 6:20 AM
Hi,
The code that you have given above inserts in only the first field. Thereafter, it is left blank.
‎2009 Jan 23 6:49 AM
Hi Frank,
Try it this way:
DATA:
W_CHAR TYPE C VALUE ' '. " Variable for Field Separator
LOOP AT ITAB1 INTO WA1.
SPLIT WA1 AT W_CHAR INTO WA2-FIELD1
WA2-FIELD1
WA2-FIELD1
WA2-FIELD1.
APPEND WA2 TO ITAB2.
ENDLOOP.With luck,
Pritam.
‎2009 Jan 23 6:55 AM
as u r using FM in paramters u can find separator
Use separator = 'X'.