Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Uploading file with comma separator

kesavadas_thekkillath
Active Contributor
0 Likes
1,240

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

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
886

Hi KSD, Try this way.


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.
<li>Text file

"CGH","CGH Hospital"
"KKH","KKH hospital"
"SGH","SGH Hospital"
Thanks Venkat.O

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

5 REPLIES 5
Read only

Former Member
0 Likes
886

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

Read only

0 Likes
886

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 ?

Read only

0 Likes
886

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

Read only

0 Likes
886

Thanks Vikranth,

I'll keep the thread opened.

Mean while i will code it

Keshu

Read only

venkat_o
Active Contributor
0 Likes
887

Hi KSD, Try this way.


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.
<li>Text file

"CGH","CGH Hospital"
"KKH","KKH hospital"
"SGH","SGH Hospital"
Thanks Venkat.O