cancel
Showing results for 
Search instead for 
Did you mean: 

Export to excel in WD ABAP, Numeric conversion

Former Member
0 Kudos

Hi All,

We have a requirement in WD ABAP to export table contents to excel. As we do not need any other ALV functionalities for the table we have been using the manual export to excel using the below approach.

DATA text   TYPE string.

DATA xtext  TYPE xstring.

LOOP AT LT_int_table INTO ls_structure.

   
CONCATENATE TEXT
                ls_structure
-field1
                ls_structure
-field2
                ls_structure
-field3
                CL_ABAP_CHAR_UTILITIES
=>NEWLINE into text separated by
                CL_ABAP_CHAR_UTILITIES
=>HORIZONTAL_TAB.
 
ENDLOOP.

 
IF text IS NOT INITIAL.
   
call function 'SCMS_STRING_TO_XSTRING'
     
exporting
       
TEXT   = TEXT
     
importing
       
BUFFER = XTEXT.

    WDR_TASK
=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(
      I_FILENAME
= 'Document.xls'
      I_CONTENT
XTEXT
      I_MIME_TYPE
= 'EXCEL' ).
 
ENDIF.

The issue is - One of these fields <String field> have comma separated numbers like 123456,783241 etc i.e. it is two serial numbers separated by a comma.While converting to excel it is picking this field as a number and displaying 123,456,783,241 though the data type is string. Is there anyway the format can be preserved as on screen with just one comma as in the table, like a string field?

Any inputs or pointers will be of great help.

Thanks & Regards,

Gayathri Shanbhag

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

The problem is that excel automatically formats the numbers.

If you can work with a tab delimited text file,you would be able to retain the formatting.

Thanks,

Sowmya

Former Member
0 Kudos

Hi,

try putting a single quote (') before the number.

i.e. '12345,67890

Regards,

Rohit