02-24-2021 9:58 AM
Dear Experts,
I am facing an issue while using the method cl_gui_frontend_services=>gui_download, as it downloads first row as F1 F2 F3 F4 F5 and so on.. which I do not want. Please suggest how can I eliminate it.
Best Regards,
Paavan
02-24-2021 10:02 AM
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = file
* filetype = 'DAT'
filetype = 'DBF'
* append = 'X'
write_field_separator = ' '
fieldnames = int_head[]
changing
data_tab = it_yes7.
02-24-2021 10:30 AM
We are going to need more information here, I believe... What do you have in "file"? What do you expect the first line to be? And why? 🙂
(Also 'DBF' is not supported anymore according to class documentation)
02-24-2021 10:33 AM
Hi Jörgen,
Thanks for replying, in FILE I have path where file will be stored
"\\192.168.4.129\RTGS\AXIS\NKPL\NKPL24022021_002.XLS"
Best Regards,
Paavan
02-24-2021 10:37 AM
I do not want
F1 F2 F3 F4 as the data in the excel file. Rest is all good..
02-24-2021 2:29 PM
DBF is made of 3 sections header, fields and rows. If you don't want the whole DBF format then don't use it. Note that the rows are simply aligned fields like that (example for table SFLIGHT), so it's easy to generate that yourself:
100AA 001720180116 422.94USD 747-400 385 369 190593.88 31 28 21 21
100AA 001720180406 422.94USD 747-400 385 372 1668.23 31 30 21 20
...
02-24-2021 2:57 PM
This will create a CSV file instead, with all the fields in the it_yes7 table, without the header line:
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = file
filetype = 'ASC'
write_field_separator = ','
changing
data_tab = it_yes7.
Excel will try to open it if it's named .XLS. Excel will say that it's no Excel file and ask if you still want to open it. If you do it will be fine.
02-25-2021 4:32 AM
Hi Jorgen,
It creates a file but if a fields contains zero in front of it then it disappears in the file. I have to retain the zero prefixed to a field.
Best Regards,
Paavan
02-25-2021 4:47 AM
I'd say that the leading zeros are most likely in your file, if it's in a char format in the table. But Excel displays them as number, because how would Excel know? 🙂 I'll add a new answer with a new proposal...
02-25-2021 4:53 AM
So the functionality in the cl_gui_frontend_services=>gui_download to generate these files is not what you need then. The DBF format is giving you headers and the CSV is not showing leading zeros for numeric fields.
Have a look at abap2xlsx to generate a real excel file, which you will have full control over.