2006 Feb 14 2:32 AM
Hi,
How dynamically upload CSV file to customer table?
Import parameters:
1 Table name
2 Comma separate data (by function 'UPLOAD')
Could you gvie any ieda?
Reward points for you help.
Thanks and regards,
collysun
2006 Feb 14 2:58 AM
Create an internal table itab with your fields in the file and then use GUI_UPLOAD to upload your CSV file to the internal table.
TABLES: ztable.
DATA filename TYPE string.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
INSERT ZTABLE FROM TABLE ITAB.
Hi,
How dynamically upload CSV file to customer table?
Import parameters:
1 Table name
2 Comma separate data (by function 'UPLOAD')
Could you gvie any ieda?
Reward points for you help.
Thanks and regards,
collysun
2006 Feb 14 2:58 AM
Create an internal table itab with your fields in the file and then use GUI_UPLOAD to upload your CSV file to the internal table.
TABLES: ztable.
DATA filename TYPE string.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
INSERT ZTABLE FROM TABLE ITAB.
2006 Feb 14 3:05 AM
2006 Feb 14 3:09 AM
Do you mean that you want the filename to be dynamically specified?
PARAMETERS : file(128).
DATA filename TYPE string.
filename = file.
Now do GUI_UPLOAD.
2006 Feb 14 3:14 AM
2006 Feb 14 3:37 AM
You can create dynamic internal table structures using field-symbols like this.
TABLES: z538emp.
FIELD-SYMBOLS <fs> STRUCTURE z538emp DEFAULT z538emp.
"Define the structure of field symbol dynamically"
"Then assign it to your internal table"
DATA itab LIKE <fs> OCCURS 0.
DATA filename TYPE string.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |