‎2021 Jan 12 5:54 AM
Hi Friends,
My requirement is that just get the data from the table send the data(excel file) to the shared folder.
Kindly provide the steps. I have searched the existing threads but no fruitful result.
Thanks with Regards,
Vallamuthu M
‎2021 Jan 12 6:12 AM
Hello Vallamuthu Madeswaran,
Pls. find the below code, it may useful to you for this requirement.
REPORT ZFILE.
TABLES mara.
data it_mara TYPE TABLE OF mara.
data wa_mara like LINE OF it_mara.
data lv_file TYPE rlgrap-filename.
data lv_data type string.
START-OF-SELECTION.
SELECT * FROM mara INTO TABLE it_mara UP TO 10 ROWS.
lv_file = 'sample.xls'.
OPEN DATASET lv_file FOR OUTPUT In TEXT MODE ENCODING DEFAULT.
loop AT it_mara INTO wa_mara.
CONCATENATE wa_mara-matnr
wa_mara-mtart
wa_mara-mbrsh
wa_mara-meins
wa_mara-ernam
wa_mara-ersda
INTO lv_data SEPARATED BY ','.
TRANSFER lv_data to lv_file.
clear: wa_mara.
ENDLOOP.
if sy-subrc IS INITIAL.
MESSAGE 'File stored to FTP path Successfully' TYPE 'I'.
ENDIF.
CLOSE DATASET lv_file.
Thanks
Sathish Kumar Sidhaiyan
‎2021 Jan 12 12:16 PM
That's a CSV, not an Excel file
It's not going to a shared folder.
‎2021 Jan 12 6:14 AM
After executing the code the excel file will store into shared file folder and you can check this in Home directory using Transaction AL11.
Thanks
Sathish Kumar Sidhaiyan
‎2021 Jan 12 7:18 AM
Hi Sathish,
Thanks for your update.
We'll not stored in AL11. Shared folder is not in SAP system. it's separate storage path, which was provided by our company.
Thanks with Regards,
Vallamuthu M.
‎2021 Jan 12 9:45 AM
Then you need to ask your Basis consultants to map the directory, otherwise you won't be able to write to it.
‎2021 Jan 12 10:19 AM
In addition to c5e08e0478aa4727abc4482f5be390b2 's words, if the shared folder is mapped on users' PC, you can use the download on local file (but you cannot run the report in background, of course)
‎2021 Jan 12 12:24 PM
Hello Vallamuthu,
Try the below FM to download your Internal table records as excel file (Any file path).
FM: MS_EXCEL_OLE_STANDARD_DAT
Also go-through the link.
Internal Table to Excel http://abaplovers.blogspot.com/2008/05/abap-internal-table-to-excel-sheet.html
Thanks
Sathish Kumar Sidhaiyan
‎2021 Jan 13 11:51 AM
Hi Sathish,
Thanks for your update.
But it'll not download the file in the background.
Thanks with Regards,
Vallamuthu M