2009 May 28 10:23 AM
Hi to all experts
i have a tab delimited text file which is to be uploaded .Im using gui_upload to upload the fields but internal table is empty no records are uploaded. The file is in the format of the internal table structure .what could be the problem.
data declarations
DATA: BEGIN OF itab OCCURS 0,
cost_center TYPE c, "Cost Center
fund_center(16) TYPE c, "Fund Center
gl_account TYPE c, "GL Account/Cost Element
commitment_item(24) TYPE c, "Commitment Item
budget_version(1), "I = Indicative, A = Active
budget_type(1), "O = Original, S = Supplement, R = Returns
mth01(16),
mth02(16),
mth03(16),
mth04(16),
mth05(16),
mth06(16),
mth07(16),
mth08(16),
mth09(16),
mth10(16),
mth11(16),
mth12(16),
total(16), "Year value
END OF itab.
upload
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file1
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.
2009 May 28 10:25 AM
Check whether all fields are separated by tabspace in the flat file.
Did you check in debugging mode why it is not getting populated ?
2009 May 28 10:25 AM
Check whether all fields are separated by tabspace in the flat file.
Did you check in debugging mode why it is not getting populated ?
2009 May 28 10:32 AM
Hi,
Please re check if all the fields in your text file correspond to those that you have declared in your internal table.
Also check if you are trying to upload a file of type ASCII.
The FM seems to be perfectly right.
2009 May 28 10:29 AM
Dear Abdul,
I think you are taking file typ RLGRAP-FILENAME type.
This should be ok but once you have got the file path you need to convert it into String type .
For that you need to declare another parameter as type string.
see example.
Parameter : p_file type rlgrap-filename.
data : d_file type string.
Start-of-selection.
if not p_file is initial.
d_file = p_file.
endfi.
Then pass this d_file to your FM GUI_UPLOAD.
you will get the record.
Hope this is helpful for you.
Regards,
Vijay
2009 May 28 10:35 AM
hi vijay,
im not using rlgrap-filename im using string.If i would be using rlgrap-filename it would give me runtime error . Please do u r home work before answering.
2009 May 28 10:55 AM
Dear Abdul again,
My dear friend I trying to give you my thoughts. You are into need. you are asking for suggestion. May be you are smart enough. Not an issue for that. But sometimes we may make small mistakes in coding and that creates problem.
I will advice you if possible give your initial lines of code i.e. till uploading data do that we can analysis.
Regards,
Vijay
2009 May 28 10:29 AM
try debuging the program , check wether u have authority to executr gui_upload or not
2009 May 28 10:34 AM
check the FILETYPE parameter....it can be DAT or TXT or sthg else...
2009 May 28 10:38 AM
hi,
just try this
selection-screen begin of block b1.
parameters : p_file type rlgrap-filename.
selection-screen end of block b1.
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
importing
file_name = p_file.
*START-OF-SELECTION.
data : f_file type string.
f_file = p_file.
call function 'GUI_UPLOAD'
exporting
filename = f_file
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = it_data
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.
Hope this solves your issue
2009 May 28 12:11 PM
it is showing as 1 record but there is no data in the fields
what could be the reason
2009 May 28 12:16 PM
Hi,
How did you find out that there is one record ?. What is the return code after GUI_UPLOAD
Regards
2009 May 28 12:19 PM
return code is 0
and in debugging mode i could see itab(1X4096)
2009 May 28 12:19 PM
hi,
pls. tell how many records are there in the file.....
Regards,
Siddarth
Edited by: Siddharth Chordia on May 28, 2009 1:20 PM
2009 May 28 12:22 PM
Hi,
Check whether Internal table has record only in header line.
If so, write a code to append workarea to internal table.
append itab.
2009 May 28 1:05 PM
HI,
You need pass DAT in the FILETYPE not the ASC
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file1
FILETYPE = 'DAT' "--> Change
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.
2009 May 29 9:57 AM