11-25-2009 5:54 AM
Hi firends,
I have a text file in the format below.
"abc","dedffrt","asd"
The value of field is enclosed in double quotes and each values are separated by comma.
I have tried with the function modules available for upload but of no use.
Im aware of the methods uploading and splitting ...
But i want to know is there any other function modules available to upload the file of this type.
Keshav
11-25-2009 6:55 AM
Hi KSD,
Try this way.
<li>Text file
REPORT ztest_notepad.
DATA: BEGIN OF it_t001 OCCURS 0,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
END OF it_t001.
DATA: BEGIN OF it_file OCCURS 0,
data TYPE char255,
END OF it_file.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\hor_file.txt'
filetype = 'ASC'
TABLES
data_tab = it_file.
REPLACE ALL OCCURRENCES OF '"' IN TABLE it_file WITH space.
LOOP AT it_file.
SPLIT it_file-data AT ',' INTO it_t001-bukrs it_t001-butxt.
APPEND it_t001.
CLEAR it_t001.
ENDLOOP.
LOOP AT it_t001.
WRITE:/ it_t001-bukrs, it_t001-butxt.
ENDLOOP.
Thanks
Venkat.O
"CGH","CGH Hospital"
"KKH","KKH hospital"
"SGH","SGH Hospital"
11-25-2009 5:59 AM
Hello Keshu,
I dont think there are any standard upload FM's which would accept a custom seperator while uploading. We had a similar requirement and we ended up in creating a Z FM which accepts any custom seperator as this is used frequently.
Vikranth
11-25-2009 6:19 AM
Hi Vik,
So what you say is to upload it into a line of a itab and the spli it.
Or did you follow some othe logic ?
11-25-2009 6:35 AM
Hello Keshu,
We used just the usual way of splitting at itab with the seperator. Lets see if anyone can point to a standard FM or method way of doing it, else i dont think you have any other option.
Vikranth
11-25-2009 6:44 AM
Thanks Vikranth,
I'll keep the thread opened.
Mean while i will code it
Keshu
11-25-2009 6:55 AM
Hi KSD,
Try this way.
<li>Text file
REPORT ztest_notepad.
DATA: BEGIN OF it_t001 OCCURS 0,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
END OF it_t001.
DATA: BEGIN OF it_file OCCURS 0,
data TYPE char255,
END OF it_file.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\hor_file.txt'
filetype = 'ASC'
TABLES
data_tab = it_file.
REPLACE ALL OCCURRENCES OF '"' IN TABLE it_file WITH space.
LOOP AT it_file.
SPLIT it_file-data AT ',' INTO it_t001-bukrs it_t001-butxt.
APPEND it_t001.
CLEAR it_t001.
ENDLOOP.
LOOP AT it_t001.
WRITE:/ it_t001-bukrs, it_t001-butxt.
ENDLOOP.
Thanks
Venkat.O
"CGH","CGH Hospital"
"KKH","KKH hospital"
"SGH","SGH Hospital"