Skip to Content
0
Former Member
Oct 18, 2006 at 02:34 PM

Error when transferring table data to a CSV format file.

30 Views

Hi

I am getting an error when I am passing the parameter value for the file name from the selection screen. If i hard code the path and name it works fine. can any one help me please. here is my code:

PARAMETERS: OUTFILE LIKE dxfile-filename

DEFAULT 'C:\Apositivepay.txt',

RUNDATE LIKE PAYR-LAUFD,

Bank LIKE T012K-HBKID. "List of Possible Banks

...

type-pools:TRUXS.

DATA: BEGIN OF OUTPUT_REC OCCURS 0, "Output file for USBANK

ACCT(12), "bank account no

...

Payee2(40) type c, "payee 2

END OF OUTPUT_REC.

data: itab1 type TRUXS_T_TEXT_DATA.

...

...

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = ','

TABLES

I_TAB_SAP_DATA = OUTPUT_REC

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 = OUTFILE "This doesn't work

filename = 'C:\Apositivepay.txt' "This works

TABLES

DATA_TAB = itab1

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_WRITE_ERROR = 2

INVALID_FILESIZE = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

OTHERS = 8.

Message was edited by: Anwarul Kabir