‎2013 Nov 15 9:25 AM
Hi experts,
My requirement is to create .csv file which when opened in excel, the fields in the table are aligned in each cell (e.g. A, B. C.), and when opened in notepad, the fields are delimited by ';'. So far I was successful in notepad; the excel part is unsuccessful. Need your opinion, thanks in advance, here is my code:
CONCATENATE c_fexfolder v_l_date '.csv' INTO fpath.
OPEN DATASET fpath FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
IF sy-subrc NE 0.
MESSAGE 'ERROR CREATING FILE' TYPE 'E'.
ENDIF.
LOOP AT gt_tab.
*CLEAR v_l_str.
wa_l_tab-markt = gt_tab-markt.
wa_l_tab-brand = gt_tab-brand.
wa_l_tab-matkl = gt_tab-matkl.
wa_l_tab-matnr = gt_tab-matnr.
wa_l_tab-normt = gt_tab-normt.
wa_l_tab-maktx = gt_tab-maktx.
wa_l_tab-stock = gt_tab-stock.
wa_l_tab-stpal = gt_tab-stpal.
wa_l_tab-netpr = gt_tab-netpr.
wa_l_tab-indat = gt_tab-indat.
wa_l_tab-oudat = gt_tab-oudat.
wa_l_tab-destr = gt_tab-destr.
wa_l_tab-costs = gt_tab-costs.
wa_l_tab-prdha = gt_tab-prdha.
wa_l_tab-meins = gt_tab-meins.
wa_l_tab-daterun = v_l_date.
CONCATENATE
wa_l_tab-markt
wa_l_tab-brand
wa_l_tab-matkl
wa_l_tab-matnr
wa_l_tab-normt
wa_l_tab-maktx
wa_l_tab-stock
wa_l_tab-stpal
wa_l_tab-netpr
wa_l_tab-indat
wa_l_tab-oudat
wa_l_tab-destr
wa_l_tab-costs
wa_l_tab-prdha
wa_l_tab-meins
wa_l_tab-daterun
v_l_date INTO v_l_str SEPARATED BY ';'.
TRANSFER v_l_str TO fpath.
ENDLOOP.
CLOSE DATASET fpath.
‎2013 Nov 15 9:52 AM
After downloading into Notepad file. Open the same file With Excel.
Then click on Data -> Text to columns (as show below)
‎2013 Nov 15 9:52 AM
After downloading into Notepad file. Open the same file With Excel.
Then click on Data -> Text to columns (as show below)
‎2013 Nov 15 9:55 AM
Hi Jack,
as the file looks correct in notepad, this is no file-export-ABAP-problem but an file-import issue with Excel. To make Excel use the correct separator you could try the following:
At least one of theese should work for you.
Regards,
markus
‎2013 Nov 15 10:16 AM
Hi,
Just create a file following the rules of CSV http://en.wikipedia.org/wiki/Comma-separated_values
Look at the "Basic rules and examples"
Regards.