‎2005 Dec 28 6:57 AM
Hi ..
I'm new to ABAP.I'm trying to insert into Ztable from a file in presentation server.My ztable has a currency fields. I upload using gui_upload into an internal table itext.I split the itext
SPLIT ITEXT-TEXT AT ',' INTO ITAB-EMPNUM ITAB-NAME ITAB -SAL.
I'M GETTING AN ERROR HERE SAYING ITAB-EMPSAL MUST BE CHARACTER TYPE DATA OBJECT(DATA TYPE C,N,D,T OR STRING)
HOW TO RECTIFY THIS.IF THERE IS NO CURRENCY FIELD THEN THERE ISN'T ANY PROBLEM.WHAT SHUD I DO WHEN I HAVE A CURRENCY FIELD.
‎2005 Dec 28 7:14 AM
Hi,
The internal table you are pssing in the GUI_UPLOAD should contain char data type.And the table you are passing should have the same structure as of the z table.
Here is the sample code.
DATA: BEGIN OF T_INPUT OCCURS 0, " Flat file data
PERNR(9) TYPE C,
AMOUNT(15) TYPE C,
W_TYPE(5) TYPE C,
END OF T_INPUT,
G_FILE1 TYPE STRING.
G_FILE1 = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = G_FILE1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = T_INPUT
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.
insert z_table from table t_input.
Kindly reward points by clicking the star on the left of reply,if it helps.
‎2005 Dec 28 7:03 AM
Hi tharun,
1. Why splitting is required ?
2. If the data in text file
is in proper format
(ie. based upon the columns in your internal table,
which has all fields as character fields,
and proper length,)
then, no splitting is required.
3. the FM GUI_UPLOAD
will fill your internal table with
perfect data.
4. Why dont u use the text file
which is TAB separated, instead of comma separted ?
regards,
amit m.
Message was edited by: Amit Mittal
‎2005 Dec 28 7:04 AM
Instead of itab-empsal, move the value to a temporary variable of charactor type in the spilt statement.
later on you can move the value of temporary variable to itab-empsal.
‎2005 Dec 28 7:04 AM
hi
if you are uploading the comma delimetd file then
use this FM(no need to split also).
KCD_CSV_FILE_TO_INTERN_CONVERT.
regards
vijay
‎2005 Dec 28 7:08 AM
Hi Tharun,
Declare a second internal table in the program.
with currency field type NUMC.
Get the data from GUI_UPLOAD in this table. Now use move-corresponding to move the contents of table2 to table1.
Hope it helps...
Lokesh
Pls. reward appropriate points
‎2005 Dec 28 7:14 AM
CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
EXPORTING
I_FILENAME = 'C:test.xls'
I_SEPARATOR = ','
TABLES
E_INTERN = itab
EXCEPTIONS
UPLOAD_CSV = 1
UPLOAD_FILETYPE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Vijay
‎2005 Dec 28 7:14 AM
Hi,
The internal table you are pssing in the GUI_UPLOAD should contain char data type.And the table you are passing should have the same structure as of the z table.
Here is the sample code.
DATA: BEGIN OF T_INPUT OCCURS 0, " Flat file data
PERNR(9) TYPE C,
AMOUNT(15) TYPE C,
W_TYPE(5) TYPE C,
END OF T_INPUT,
G_FILE1 TYPE STRING.
G_FILE1 = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = G_FILE1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = T_INPUT
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.
insert z_table from table t_input.
Kindly reward points by clicking the star on the left of reply,if it helps.
‎2005 Dec 28 7:29 AM
hi .Everyone's suggestion was valuable.
I tried Jayanthi's suggestion and rectified the error.I'll try other solutions also