‎2006 Feb 08 6:59 AM
Hey, everyone.
How can I create an Excel file by using OPEN DATASET command ??
The file is created but the columns are no seperated like thay should.
I need to seperate the internal table's fields with a comma - How can I do it ?
Here's my code:
OPEN DATASET filename1 FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
LOOP AT gt_vend_info into gwa_vend_info.
TRANSFER gwa_vend_info TO filename1.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
Thanks in advance.
‎2006 Feb 08 7:03 AM
Hi Beki,
Hope the gt_vend_info is having the data with comma separated and is a single string which you'll be writing into the file. In that case your internal table goes in as a line with fields separated with commas.
For writing it as a excel file (.csv file) try passing the filename1 as "try.csv" and check whether its working properly by creating a excel file.
Cheers
JK
‎2006 Feb 08 7:05 AM
For ur requirement, one way,what we can do is :
a) open the file using open dataset.
b) read and load it into internal table.
c) save this internal table to front-end
using GUI_DOWNLOAD.
D) then again read the file
using GUI_UPLOAD
‎2006 Feb 08 7:08 AM
Hi,
make these changes to the above code.
OPEN DATASET filename1 FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
LOOP AT <b>itab1</b> into <b>wa_itab</b>.
TRANSFER <b>wa_itab</b> TO filename1.
IF SY-SUBRC <> 0.
EXIT.ENDIF.
ENDLOOP.
ENDIF.just modify my above code..
regards
vijay
‎2006 Feb 08 7:05 AM
Hi Beki,
REPORT ZTESTAA.
TYPE-POOLS:TRUXS.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
DATA:
ITAB1 TYPE TRUXS_T_TEXT_DATA.
SELECT VBELN
POSNR
UP TO 10 ROWS
FROM VBAP
INTO TABLE ITAB.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ';'
TABLES
I_TAB_SAP_DATA = ITAB
CHANGING
I_TAB_CONVERTED_DATA = ITAB1
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1
SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
OPEN DATASET filename1 FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
LOOP AT gt_vend_info into gwa_vend_info.
TRANSFER gwa_vend_info TO filename1.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.the above code give CSV format file, all fields will be separated by ';'
Regards
vijay