0

I have a problem with the Function Module "GUI_DOWNLOAD" because of the date converting. I want to get the date like I have it in my internal table but CSV (Excel) keeps converting it everytime. The internal table contains the line like this: 12345678;GroupDate;2021-12-31;

The Output in the .csv-File should be "2021-12-31" but it keeps converting to "31.12.2021".

I also tried to put an ' (apostroph) before the date but the output will be '2021-12-31

Does anybode have an Idea ?

      lv_conv = '2021-12-31'.
  CONCATENATE TEXT-001 LV_CONV INTO LV_CONV.

    CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME = IV_PATH
  TABLES
    DATA_TAB = LT_FILE.

LT_FILE is a string table.

Thanks for the help.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Mogera
  • 37
  • 1
  • 9
  • 2
    Don't confuse what ABAP does (when it saves the file) and what Excel does (when it displays the file). ABAP saves the file with `2021-12-31` as you wish, but Excel displays it like `31.12.2021` (on your laptop; on mine it's `12/31/2021` because of my MS Office regional settings). If you don't want Excel to interpret the values from the CSV file, you have several strategies available for Excel, but which may only apply to Excel, so you must be sure that this file is to be opened only with Excel. I guess there are many existing answers in Stack Overflow about how to format CSV for Excel. – Sandra Rossi Jul 18 '21 at 13:56
  • agree with Sandra, I faced this problem with Excel many times when opened CSV w/o any ABAP, it's an Excel locale problem – Suncatcher Jul 19 '21 at 07:12
  • Does this answer your question? [Excel Date Formatting](https://stackoverflow.com/questions/15664709/excel-date-formatting) – Suncatcher Jul 19 '21 at 07:14
  • 1
    also check this https://stackoverflow.com/questions/165042/stop-excel-from-automatically-converting-certain-text-values-to-dates/15107122#15107122 – Suncatcher Jul 19 '21 at 07:14
  • thanks both of you. I looked into it and it is really the settings of excel, the solution I found is in https://stackoverflow.com/questions/165042/stop-excel-from-automatically-converting-certain-text-values-to-dates/15107122#15107122 – Mogera Jul 19 '21 at 07:38

1 Answers1

0

Like Suncatcher and Sandra said the file is right but it is only the settings from excel which convert the date. If the Output file won´t be needed for other purposes than showing the code could be something like this

CONCATENATE '=("' LV_CONV '")' INTO LV_CONV.

The csv-Output would be a date like this 1960-01-01 but in the cell the value would look like =("1960-01-01").

Mogera
  • 37
  • 1
  • 9