Converting csv separated by ','
REPORT ZTEST.
TYPE-POOLS:TRUXS.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
DATA: ITABT LIKE ITAB OCCURS 0 WITH HEADER LINE.
DATA: ITAB1 TYPE TRUXS_T_TEXT_DATA,
ITAB2 TYPE TRUXS_T_TEXT_DATA.
SELECT VBELN POSNR
UP TO 100 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.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\TEMP\TEST.TXT'
TABLES
DATA_TAB = ITAB1
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = ','
I_TAB_RAW_DATA = ITAB1
* I_FILENAME = 'C:\TEMP\TEST.TXT'
TABLES
I_TAB_CONVERTED_DATA = ITABT
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment