Application Development 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: 

Empty fields in STRUCTURE_TO_CSV are converted to double quotes after conversion.

yutngc
Explorer
0 Kudos
662
  LR_CONVERTER = CL_RSDA_CSV_CONVERTER=>CREATE(
                    I_DELIMITER = SPACE
                    I_SEPARATOR = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB ).

  LR_LINE = CL_RSDA_CSV_CONVERTER=>GET_CHAR_WORKAREA( <L_S_DATA> ).
  ASSIGN LR_LINE->* TO <L_LINE>.
  CLEAR L_ITEMS.
  LR_CONVERTER->STRUCTURE_TO_CSV( EXPORTING I_S_DATA = <L_S_DATA>
                                  IMPORTING E_DATA = <L_LINE> ).

In this case, the content of <L_LINE> is

" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "#" "

and double quotes.
What should I set to I_DELIMITER to convert without double quotes?

2 REPLIES 2

Sandra_Rossi
Active Contributor
0 Kudos
512

Beware the <BR> in your post.

Your code better formatted:

  LR_CONVERTER = CL_RSDA_CSV_CONVERTER=>CREATE(
                    I_DELIMITER = SPACE
                    I_SEPARATOR = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB ).

  LR_LINE = CL_RSDA_CSV_CONVERTER=>GET_CHAR_WORKAREA( <L_S_DATA> ).
  ASSIGN LR_LINE->* TO <L_LINE>.
  CLEAR L_ITEMS.
  LR_CONVERTER->STRUCTURE_TO_CSV( EXPORTING I_S_DATA = <L_S_DATA>
                                  IMPORTING E_DATA   = <L_LINE> ).

matt
Active Contributor
512

Run the program in debug. When you get to the CREATE method, that calls the constructor. In the constructor you'll see that if i_delimiter is initial (i.e. space), then the default delimiter " is used instead.

It looks like you're trying to create tab delimited output. The CL_RSDA_CSV_CONVERTER class is used to create CSV files, and you can't use space as a delimiter.