2007 Aug 24 7:00 AM
please help me with upoloading an excel file into an internal table using GUI_UPLOAD.
please help me with upoloading an excel file into an internal table using GUI_UPLOAD.
2007 Aug 24 7:01 AM
Retrieve data file from presentation server(Upload from PC)
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = i_file
filetype = 'ASC'
TABLES
data_tab = it_datatab "ITBL_IN_RECORD[]
EXCEPTIONS
file_open_error = 1
OTHERS = 2.
2007 Aug 24 7:01 AM
Hi Anand,
Save your Excel Sheet as Tab Delmited and use GUI_UPLOAD FM and use that in this way it works as per your requirement.
V_FILENAME = P_FILE.
CALL FUNCTION 'GUI_UPLOAD' EXPORTING
FILENAME = V_FILENAME
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '|'
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.
Ravi.
2007 Aug 24 7:02 AM
Hi,
Use FM 'ALSM_EXCEL_TO_INTERNAL_TABLE'
Then it will come into Row and Column and then rearrange the data into your required format.
Reward if useful!
2007 Aug 24 7:13 AM
for this use ALSM_EXCEL_TO_INTERNAL_TABLE,and declare internal table of type ALSMEX_TABLINE.
for FM pass exp parameters
file name.
imp parameters
internal table.
<b>reward points if helpful.</b>
2007 Aug 24 7:16 AM
Hi Anand
here check this program i am spliting the record depend upon ',' and dont use ws_upload etc fm's are obsolete....
data: begin of itab_string occurs 0,
record type char255,
end of itab_string.
data: L_FILETABLE TYPE FILETABLE,
L_FILETAB_H TYPE FILETABLE WITH HEADER LINE.
data: p_file1 type string.
selection screen .
PARAMETERS: P_FILE TYPE LOCALFILE.
initialization.
at selection-screen on value-request for P_FILE.
IF THE USER SELECT EXTENTION BUTTON IT WILL OPEN THE LOCAL DIRECTORY FOR SELECTING THE FILE LOCATION.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION = 'CSV'
DEFAULT_FILENAME = 'C:\Documents and Settings\196093\Desktop\STATUS.csv'
FILE_FILTER =
INITIAL_DIRECTORY = 'C:\Documents and Settings\196093\Desktop\'
MULTISELECTION =
WITH_ENCODING =
CHANGING
FILE_TABLE = L_FILETABLE
RC = RC
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
.
IF SY-SUBRC <> 0.
ELSE.
LOOP AT l_filetable INTO L_FILETAB_H.
P_FILE = L_FILETAB_H-FILENAME.
move p_file to p_file1.
EXIT.
ENDLOOP.
ENDIF.
passing the selected file name to gui_upload for loading the data
into internal table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = p_file1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = itab_string
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 I000(Z00) WITH 'PLEASE PROVIDE CORRECT FILE NAME'.
ENDIF.
loop at itab_string.
now split the statuses
split itab_string at ',' into itab_status-aufnr itab_status-asttx itab_status-asttx1.
and move one internal table
append itab_status.
clear itab_status.
endloop.
reward points to all helpful answers
kiran.M
2007 Aug 24 8:28 AM
Hi anand,
Report ZUpload
TABLES: KNA1.
PARAMETERS: STATE LIKE KNA1-REGIO DEFAULT 'MA'.
TYPES: BEGIN OF OUTREC,
KUNNR LIKE KNA1-KUNNR,
REGIO LIKE KNA1-REGIO,
TELF1 LIKE KNA1-TELF1,
END OF OUTREC.
DATA: OUT_ITAB TYPE STANDARD TABLE OF OUTREC
INITIAL SIZE 10 WITH HEADER LINE.
DATA: OUT_ITAB_Upload TYPE STANDARD TABLE OF OUTREC
INITIAL SIZE 10 WITH HEADER LINE.
UPLOADIND THE LOCAL FILE BEEN DOWNLOADED , INTO ABAP PROGRAM AS NEW
INTERNAL TABLE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\upload.xls'
FILETYPE = 'ASC'
TABLES
DATA_TAB = out_itab_Upload.
LOOP at out_itab_upload.
write : / out_itab_upload-kunnr, out_itab_upload-regio,
out_itab_upload-telf1.
try this.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |