05-13-2011 12:24 PM
Hi everybody .
In my program, I use the fm GUI_UPLOAD to upload the flat file which separator is the pipe(|).
Exemple of line : AAA|BBB|CCC|DDD
HAS_FIELD_SEPARATOR='|' not working, so how can i use this fm and define SEPARATOR as pipe .
thank in advance
05-13-2011 12:40 PM
Hi ,
I believe the field separator parameter will work for Excel files..You have to get the internal table in a string format..and then use split statement..
Use the below code it work for me..
DATA: BEGIN OF it_tab OCCURS 0,
object_id TYPE string,
version_series_id TYPE string,
version_number TYPE string,
revision TYPE string,
doc_number TYPE string,
doctitle TYPE string,
filesize TYPE string,
mime_type TYPE string,
plantunit TYPE string,
END OF it_tab.
DATA: t_tab TYPE TABLE OF string,
v_string TYPE string.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEST.TXT'
has_field_separator = '|' "Actually not required.*
TABLES
data_tab = t_tab
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.
ENDIF.
LOOP AT t_tab INTO v_string.
SPLIT v_string AT '|'
INTO
it_tab-object_id
it_tab-version_series_id
it_tab-version_number
it_tab-revision
it_tab-doc_number
it_tab-doctitle
it_tab-filesize
it_tab-mime_type
it_tab-plantunit.
APPEND it_tab.
CLEAR: it_tab.
ENDLOOP.
Regards,
DHina..
Edited by: Dhina DMD on May 13, 2011 1:41 PM
Edited by: Dhina DMD on May 13, 2011 1:47 PM
05-13-2011 12:26 PM
05-13-2011 12:29 PM
Thanks for your repply
if i keep it as 'X' it will be defined as space .. so fm can't interpret file.
05-13-2011 12:38 PM
The GUI_UPLOAD function recognize only tab delimeted files when you pas 'X' at parameter
HAS_FIELD_SEPARATOR
try FM
CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
EXPORTING
I_FILENAME = S_IFILE
I_SERVERTYP = 'PPRS' "GUI UPLOAD
* i_fileformat = SFILEFORMAT
I_FIELD_SEPERATOR = ';'
* I_LINE_HEADER =
* IMPORTING
* E_BIN_FILELENGTH =
TABLES
I_TAB_RECEIVER = I_TABLE
EXCEPTIONS
FILE_NOT_FOUND = 1
CLOSE_FAILED = 2
AUTHORIZATION_FAILED = 3
OPEN_FAILED = 4
CONVERSION_FAILED = 5
OTHERS = 6 .
05-13-2011 12:40 PM
Hi ,
I believe the field separator parameter will work for Excel files..You have to get the internal table in a string format..and then use split statement..
Use the below code it work for me..
DATA: BEGIN OF it_tab OCCURS 0,
object_id TYPE string,
version_series_id TYPE string,
version_number TYPE string,
revision TYPE string,
doc_number TYPE string,
doctitle TYPE string,
filesize TYPE string,
mime_type TYPE string,
plantunit TYPE string,
END OF it_tab.
DATA: t_tab TYPE TABLE OF string,
v_string TYPE string.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEST.TXT'
has_field_separator = '|' "Actually not required.*
TABLES
data_tab = t_tab
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.
ENDIF.
LOOP AT t_tab INTO v_string.
SPLIT v_string AT '|'
INTO
it_tab-object_id
it_tab-version_series_id
it_tab-version_number
it_tab-revision
it_tab-doc_number
it_tab-doctitle
it_tab-filesize
it_tab-mime_type
it_tab-plantunit.
APPEND it_tab.
CLEAR: it_tab.
ENDLOOP.
Regards,
DHina..
Edited by: Dhina DMD on May 13, 2011 1:41 PM
Edited by: Dhina DMD on May 13, 2011 1:47 PM
05-13-2011 5:24 PM
thanks for reply
i need to know what's the type of V_STRING because i have the error :" a line of "t_tab" and "V_STRING" are not mutually convertible in a unicode program" when i try to do the same but the type STRING not work i think
and i have another field with data type is QUAN in my internal table!!!!
thanks
Edited by: Anouar ANNOUCH on May 13, 2011 6:29 PM
Edited by: Anouar ANNOUCH on May 14, 2011 12:05 PM
05-14-2011 12:19 PM
Hi,
The t_tab and V_STRING are string type only.
DATA: BEGIN OF it_tab OCCURS 0,
object_id TYPE string,
version_series_id TYPE string,
version_number TYPE string,
revision TYPE string,
doc_number TYPE string,
doctitle TYPE string,
filesize TYPE string,
mime_type TYPE string,
plantunit TYPE string,
END OF it_tab.
the t_tab should contains only character format or string format.
DATA: t_tab TYPE TABLE OF string,
v_string TYPE string.
if you have the Quantity field in you internal table you can change the type like character format or string format.
After calling the GUI_UPLOAD function module the t_tab contains all the records of what is there in the flat file.
v_string is for work area for the internal table t_tab.
if you have the quantity field in the internal table change it into character field. Why because split statement is working only
C, N format only.
Regards,
Dhina..
Edited by: Dhina DMD on May 14, 2011 1:31 PM
05-16-2011 11:24 AM