‎2008 Apr 25 7:13 AM
can any one tell what is the solution for the unicode error for the following upload function module.
I have used the class gui_frontend_services
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
but there is no cancel parameter in this method.
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = datei
filetype = 'ASC'
IMPORTING
cancel = cancel
TABLES
data_tab = satz
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
OTHERS = 6.
IF cancel NE space.
WRITE 'Upload abgebrochen.'(001) COLOR COL_NEGATIVE. STOP.
ENDIF.
IF sy-subrc NE 0.
WRITE: 'Upload mit Fehler'(002) COLOR COL_NEGATIVE,
sy-subrc COLOR COL_NEGATIVE.
STOP.
ENDIF.
Regards,
Vaasu.
‎2008 Apr 25 10:17 AM
Hi,
Can u please provide the exact error message while u execute the upload function?
Please go thru the below information.
Character String Processing
In the following example, components of type X are used to store characters. In Unicode programs, this is no longer possible.
Before Unicode conversion
data: begin of L_LINE,
TEXT1(10) type c,
MARK1(1) type x value '00',
TEXT2(10) type c,
MARK2(1) type x value '00',
TEXT3(10) type c,
MARK3(1) type x value '00',
BLANK(100) type c,
end of L_LINE,
HEX0(1) type x value '00',
CRLF(2) type x value '0D0A'.
L_LINE-TEXT 1 = 'SYSTEM: '.
L_LINE-TEXT 2 = 'USER: '.
L_LINE-TEXT 3 = 'CLIENT: '.
replace: HEX0 with SY-SYSID into L_LINE,  Unicode error
HEX0 with SY-UNAME into L_LINE,  Unicode error
HEX0 with SY-MANDT into L_LINE.  Unicode error
condense L_LINE.  Unicode error
concatenate L_LINE CRLF into L_LINE.  Unicode error
*Further processing of L_LINE.
After Unicode conversion
By using constants from the class CL_ABAP_CHAR_UTILITIES, you can avoid using any X fields.
data:
begin of L_LINE,
TEXT1(10) type c,
MARK1(1) type c
value CL_ABAP_CHAR_UTILITIES=>MINCHAR,
TEXT2(10) type c,
MARK2(1) type c
value CL_ABAP_CHAR_UTILITIES=>MINCHAR,
TEXT3(10) type c,
MARK3(1) type c
value CL_ABAP_CHAR_UTILITIES=>MINCHAR,
BLANK(100) type c,
end of L_LINE,
HEX0(1) type c,
CRLF(2) type c.
HEX0 = CL_ABAP_CHAR_UTILITIES=>MINCHAR.
CRLF = CL_ABAP_CHAR_UTILITIES=>CR_LF.
L_LINE-TEXT1 = 'SYSTEM: '.
L_LINE-TEXT2 = 'USER: '.
L_LINE-TEXT3 = 'CLIENT: '.
replace: HEX0 with SY-SYSID into L_LINE,
HEX0 with SY-UNAME into L_LINE,
HEX0 with SY-MANDT into L_LINE.
condense L_LINE.
concatenate L_LINE CRLF into L_LINE.
*Further processing of L_LINE.
Note: This example, which was found in a similar fashion in a real application, is unnecessarily complicated and certainly not an example of a good programming style. The following is an example of a much clearer solution:
class CL_ABAP_CHAR_UTILITIES definition load.
data: L_LINE(133) type c.
concatenate SYSTEM: SY-SYSID
USER: SY-UNAME
CLIENT: SY-MANDT
CL_ABAP_CHAR_UTILITIES=>CR_LF into L_LINE.
File Interface
This example deals with the opening and closing of files.
Before Unicode conversion
data:
begin of STRUC,
F1 type c,
F2 type p,
end of STRUC,
DSN(30) type c value 'TEMPFILE'.
STRUC-F1 = 'X'.
STRUC-F2 = 42.
Write data to file
open dataset DSN in text mode.  Unicode error
transfer STRUC to DSN.
close dataset DSN.
Read data from file
clear STRUC.
open dataset DSN in text mode.  Unicode error
read dataset DSN into STRUC.
close dataset DSN.
write: / STRUC-F1, STRUC-F2.
This example program cannot be executed in Unicode for two reasons. Firstly, in Unicode programs, the file format must be specified more precisely for OPEN DATASET and, secondly, only purely character-type structures can still be written to text files.
Depending on whether the old file format still has to be read or whether it is possible to store the data in a new format, there are various possible conversion variants, two of which are introduced here.
After Unicode conversion
Case 1: New textual storage in UTF-8 format
....
data:
begin of STRUC2,
F1 type c,
F2(20) type c,
end of STRUC2.
Put data into text format
move-corresponding STRUC to STRUC2.
Write data to file
open dataset DSN in text mode for output encoding utf-8.
transfer STRUC2 to DSN.
close dataset DSN.
Read data from file
clear STRUC.
open dataset DSN in text mode for input encoding utf-8.
read dataset DSN into STRUC2.
close dataset DSN.
move-corresponding STRUC2 to STRUC.
write: / STRUC-F1, STRUC-F2.
The textual storage in UTF-8 format ensures that the created files are platform-independent.
After Unicode conversion
Case 2: Old non-Unicode format must be retained
...
Write data to file
open dataset DSN in legacy text mode for output.
transfer STRUC to DSN.
close dataset DSN.
read from file
clear STRUC.
open dataset DSN in legacy text mode for input.
read dataset DSN into STRUC.
close dataset DSN.
write: / STRUC-F1, STRUC-F2.
Using the LEGACY TEXT MODE ensures that the data is stored and read in the old non-Unicode format. In this mode, it is also possible to read or write non-character-type structures. However, be aware that data loss and conversion errors can occur in Unicode systems if there are characters in the structure that cannot be represented in the non-Unicode codepage.
With regards,
Ramalakshmi
‎2008 Apr 25 12:11 PM
Hi,
Instead of using method, use following..
PARAMETERS: FILENAME TYPE IBIPPARMS-PATH.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILENAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'DATASET'
IMPORTING
FILE_NAME = FILENAME.
REWARD IF USEFUL