01-21-2005 3:00 AM
hey
i used below code to upload csv tab seperated file into internal table.
I want to check whether below code works perfectly in Enterprise.
Could you please verify my loop structure and Data declaration part
and tell me it will work or not.
In 4.6b i worked it works fine. only last parameter "MEMO" gets
added with junk of "00000000" before the text. other wise things are stored
properly. could you pls confirm.
this is my internal table.
DATA: BEGIN OF ETAB occurs 0,
TRKORRNUM LIKE ZMW0001-TRKORRNUM,
CLIENT LIKE ZMW0001-CLIENT,
IMPORTDAY LIKE ZMW0001-IMPORTDAY,
CONVERTFILENAME LIKE ZMW0001-CONVERTFILENAME,
TRANSNO LIKE ZMW0001-TRANSNO,
EXETIMING LIKE ZMW0001-EXETIMING,
PRETRKORRNUM LIKE ZMW0001-PRETRKORRNUM,
IMPRETURNCODE LIKE ZMW0001-IMPRETURNCODE,
STATUS LIKE ZMW0001-STATUS,
HOLD LIKE ZMW0001-HOLD,
JOBNAME LIKE ZMW0001-JOBNAME,
JOBCOUNT LIKE ZMW0001-JOBCOUNT,
UDATE LIKE ZMW0001-UDATE,
UTIME LIKE ZMW0001-UTIME,
MEMO LIKE ZMW0001-MEMO,
END OF ETAB.
my csv tab file storing internal table.
TYPES: BEGIN OF TTAB,
TRKORRNUM LIKE ZMW0001-TRKORRNUM,
CLIENT LIKE ZMW0001-CLIENT,
IMPORTDAY(10) TYPE C,
CONVERTFILENAME LIKE ZMW0001-CONVERTFILENAME,
TRANSNO LIKE ZMW0001-TRANSNO,
EXETIMING LIKE ZMW0001-EXETIMING,
PRETRKORRNUM LIKE ZMW0001-PRETRKORRNUM,
MEMO LIKE ZMW0001-MEMO,
END OF TTAB.
DATA: ITAB TYPE STANDARD TABLE OF TTAB INITIAL SIZE 0,
ITABWA TYPE TTAB.
/ Aim is only csv fields should store in real table,other fields must be empty.
FORM UPLOAD_FILE.
Concatenate DIR FILENAME into SOURCEPATH.
CALL METHOD FILEREAD->GUI_UPLOAD
EXPORTING
filename = Sourcepath
FILETYPE = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
IMPORTING
FILELENGTH =
HEADER =
*TABLES
changing
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.
SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *
IF sy-subrc <> 0.
MESSAGE ID 'ZMW' TYPE 'I' NUMBER '000'.
ENDIF.
LOOP AT ITAB INTO ITABWA.
MOVE-CORRESPONDING ITABWA TO ETAB.
SPLIT ITABwa-importday AT '/' INTO etab-importday+0(4)
etab-importday+4(2)
etab-importday+6(2).
APPEND ETAB.
ENDLOOP.
CLEAR ITAB.
LOOP AT ETAB.
INSERT INTO ZMW0001 VALUES ETAB.
COMMIT WORK.
ENDLOOP.
01-24-2005 4:00 PM
Chandra,
I believe it will work on Enterprise also.
About your field MEMO. Probably this is related to a RAW datafield. One attribute of these fields is, that they need a size parameter in front of them (if type INTEGER).
Because you read the datafile in ASC type mode, the GUI_UPLOAD method assumes NO value is present and will add room for a number in front of the text.
You could change the last MEMO field in such a way, that it has a fixed length (long enough to hold whatever it might contain).
Regards,
Rob.
01-24-2005 4:00 PM
Chandra,
I believe it will work on Enterprise also.
About your field MEMO. Probably this is related to a RAW datafield. One attribute of these fields is, that they need a size parameter in front of them (if type INTEGER).
Because you read the datafile in ASC type mode, the GUI_UPLOAD method assumes NO value is present and will add room for a number in front of the text.
You could change the last MEMO field in such a way, that it has a fixed length (long enough to hold whatever it might contain).
Regards,
Rob.
01-25-2005 3:03 AM