Common Errors Unicode New1
Common Errors Unicode New1
Errors
(SAP Version ECC 6.0)
o The Normal Black Ones are the codes that were existing in the Program/
Object.
o The Blue Ones with an asterisk (*) in front are the lines that were
commented out in the existing code to make it Unicode Compliant.
o The Red Ones are the codes which were inserted into the object/ program
to compensate the functionalities provided by the lines that were
commented out during Unicode compliant check.
The Black, Blue and Red lines are actual piece of ABAP code.
3. “Error” mentioned henceforth are the actual errors that were generated after
executing UCHECK transaction in UNICODE environment.
4. The errors having similar solution/ resolutions have been clubbed under same
“TYPE” for better understanding.
After resolving all the errors under the Unicode Check, we can set the Unicode Flag.
This can be done in either of the two ways.
1. From the Transaction UCCHECK itself, by selecting the success message of the
object and then clicking on the Set Unicode Attribute button .
2. Go directly to the object, Go To -> Attributes -> Change Display -> Check the
Unicode Flag Active -> Save -> Activate.
Case - 1:
Solution: All the UPLOAD / WS_UPLOAD function modules need to be replaced with
GUI_UPLOAD FM and all the DOWNLOAD / WS_DOWNLOAD with the
GUI_DOWNLOAD function modules.
*{ REPLACE EMPK900094
1
*\ call function 'WS_UPLOAD'
*\ exporting
*\ filename = p_filel
*\ filetype = 'DAT' "'ASC' "'DAT'
*\ tables
*\ data_tab = record
*\ exceptions
*\ conversion_error = 1
*\ file_open_error = 2
*\ file_read_error = 3
*\ invalid_type = 4
*\ no_batch = 5
*\ unknown_error = 6
*\ invalid_table_width = 7
*\ gui_refuse_filetransfer = 8
*\ customer_error = 9
*\ others = 10.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Note : Please make sure that default location is given if its not then dont use default
filename parameter in your Function module.
*{ REPLACE RE2K900049
1
*\ CALL FUNCTION 'UPLOAD'
*\ EXPORTING
*\ FILENAME = I_NFILE "NOME FILE
*\ FILETYPE = 'ASC'
*\ TABLES
*\ DATA_TAB = FILIN
*\ EXCEPTIONS
*\ CONVERSION_ERROR = 1
*\ INVALID_TABLE_WIDTH = 2
*\ INVALID_TYPE = 3
*\ NO_BATCH = 4
*\ UNKNOWN_ERROR = 5
*\ OTHERS = 6.
*\
l_p_file_temp = p_file.
l_p_file = l_ft-filename.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
l_i_nfile = l_ft-filename.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Endif. “for i_action
** End of Changes - 46C To ECC6 - IN9KHOSLA
**UPLOAD
******* Dheeraj if Import parameters have cancel option & we use
action variable
data: ft type filetable,
rc type i,
l_i_nfile type string,
l_i_nfile_temp type string,
l_action type i.
Clear W_CANCEL.
l_i_nfile = l_ft-filename.
w_filename = l_i_nfile.
w_filetype = 'DAT'.
endif.
DOWNLOAD is obsolete function module for storing SAP data in a file in the file
system of the presentation server.
EXAMPLE :
l_filename_temp = PC_FILE.
Case - 2 :
Cause: Here WG_CRLF may be a variable or an internal table which contains variables
which are of type X. Type X is used to represent hexadecimal values. Each
Hexadecimal value can hold two characters (8 bits). These Hexadecimal values may also
represent the codes for performing some actions like Horizontal Tab, Line Feed, etc. Till
Solution: So we need to change all the X type variables to the C type Variables with
their values unchanged. This can be tackled by declaring a variable as Type C, and then
use the method UCCP('XXXX') of the Class CL_ABAP_CONV_IN_CE where XXXX
represents the 8-bit hexadecimal value represented as 16 bits. Before this we need to load
the definition of the Class CL_ABAP_CONV_IN_CE.
Example:
is not possible. CLASS CL_ABAP_CHAR_UTILITIES DEFINITION
LOAD statement
Note - 1: There are some meths of class CL_ABAP_CHAR_UTILITIES which are used
to remove Errors related to Hexadecimal variables :
cl_abap_char_utilities=>horizontal_tab --- 09
cl_abap_char_utilities=>CR_LF --- 0D0A
cl_abap_char_utilities=>VERTICAL_TAB --- 0B
cl_abap_char_utilities=>NEWLINE --- 0A
cl_abap_char_utilities=>FORM_FEED --- 0C
cl_abap_char_utilities=>BACKSPACE --- 08
Note – 2: For e.g, the variable of type X has length more than one. Then an internal
table must be created for the variable.
Example :
Case - 3:
Error : In Unicode, DESCRIBE LENGTH can only be used with the IN BYTE
MODE or IN CHARACTER MODE addition.
Cause: In some cases, the syntax rules that apply to Unicode Programs are different than
those for non-Unicode programs For example, if one uses the addition LENGTH, one
must also use one of the two additions IN CHARACTER MODE or IN BYTE MODE
in Unicode systems.
This addition can only be used for character-type fields and in combination with the
addition
LENGTH. The length of the field f is determined in characters.
This addition can only be used in combination with the addition LENGTH. The
length of the
field f is determined in bytes.
Example:
DATA: FLD(8),
LEN TYPE I,
* DESCRIBE FIELD FLD LENGTH LEN.
DESCRIBE FIELD FLD LENGTH LEN IN CHARACTER MODE.
CASE-4
Error: Could not specify the access range automatically. This means that you need a
RANGE addition.
With these statements, the fields f, f1 and f2 must be type-compatible with one another.
Solution:
If the RANGE addition is not specified, it is implicitly defined with FROM f1 NEXT f2
as follows:
If a deep structure is defined as a RANGE addition, the system checks for every loop
pass that there are no field references, object references, tables, or strings within the
accessed range.
Example:
Alternative method :
WA_SOLISTI1-P$_TXT03 = P$_TXT01.
WA_SOLISTI1-P$_TXT04 = P$_TXT02.
Case - 5:
Type - I
Cause: Usually, while passing parameters, we need to pass the variable as a whole or at
least its position with length must be specified. Till Version 4.6C (Non Unicode
complaint environment), there was no need to specify the length, it didn’t throw any error
but used to take till the full length of the variable. But from Version ECC 6 .0 , it throws
an error.
Solution: For any parameter, if we need to specify the position, it should always be
accompanied by its length.
Example:
DATA:HEAD(100).
* PERFORM APPEND_XFEBRE USING HEAD+2.
PERFORM APPEND_XFEBRE USING HEAD+2(98).
-----------------------------------------------------------------------
Type - II
Error: You cannot use ASSIGN f+offset. Always use an explicit length (or '*').
Cause: In Unicode environment, it needs the exact length. We can’t say starting from
2nd position. Till Version 4.6C, it will take the entire variable starting from 2 nd position.
But in Unicode Environment, it is not possible.
Example:
Case - 6:
Type - I
Solution: Both the data types first need to be compatible and then can be used to assign
the contents.
In the below ABAP code, SOLISTI1 is a table with a single field. - Line char (16)
* OBJCONT = OUT_REC.
OBJCONT+0(3) = OUT_REC-DTYPE.
OBJCONT+3(5) = OUT_REC-GRPCO.
OBJCONT+8(6) = OUT_REC-RECNR.
OBJCONT+14(2) = OUT_REC-XSTRING.
Note: If the error is in reversed order, (i.e) OUT_REC and OBJCONT are not mutually
convertible. In Unicode programs, "OBJCONT" must have the same structure layout
as "OUT_REC", independent of the length of a Unicode character. , then we have to
follow the same procedure in reversed order.
* OUT_REC = OBJCONT.
OUT_REC-DTYPE = OBJCONT+0(3).
OUT_REC-GRPCO = OBJCONT+3(5).
OUT_REC-RECNR = OBJCONT+8(6).
OUT_REC-XSTRING = OBJCONT+14(2).
-----------------------------------------------------------
Type - II
Error: REC and "T" are not mutually convertible. In Unicode programs, "REC"
must have the same structure layout as "T", independent of the length of a Unicode
character.
Example:
* REC = T.
** Begin of Changes - 46C To ECC6 - IN9KHOSLA
MOVE-CORRESPONDING T TO REC.
** End of Changes - 46C To ECC6 - IN9KHOSLA
Type - III
Error : ""DTABC"" and ""' '"" are not mutually convertible in a Unicode program.
Type - I
Error: The sum of the offset and length (=1016) exceeds the length of the start
(=1000) of the structure. - not allowed in Unicode programs.
Cause: Till Version 4.6C, even if we don’t specify the length, the system wont throw
any error but will take to the full length of the variable. But from Version ECC6.0, it is
not possible. We need to mention the length explicitly.
Solution: We are supposed to specify the length of the variables without fail for Unicode
compliance.
Example:
* record_tab = ufkt-zuser_id.
* record_tab+10 = ufkt-fktc.
* record_tab+11 = ufkt-zname.
record_tab = ufkt-zuser_id.
record_tab+10(1) = ufkt-fktc.
record_tab+11(50) = ufkt-zname.
----------------------------------------------------------------------------------------------------
Type - II
Example:
Cause: Till Version 4.6C, when we open a Dataset it is not necessary to specify the
encoding format. In Non-Unicode systems, this is not mandatory. But from Version ECC
6.0, it has been made mandatory.
Solution: After opening the dataset, specify the encoding format. There are three types
of Encoding format.
on ENCODING (DEFAULT|UTF-8|NON-UNICODE)
DEFAULT
Corresponds to UTF-8 in Unicode systems and to NON-UNICODE in non-
Unicode systems.
UTF-8
Characters are represented in the file in the format UTF-8.
NON-UNICODE
Characters are represented in the file in the code page defined by the text
environment current at the time a READ or TRANSFER command is executed
Example:
Case - 9:
Cause: In programs without active Unicode check, the file usually opens for reading in binary
mode, if one does not use any additions for OPEN DATASET. But for those Unicode Enabled
Programs, it is not possible and it requires the mode to be specified.
Solution: In programs with active Unicode check, one must specify the access type
(such as ... FOR INPUT, ... FOR OUTPUT, and so on) and the mode (such as ... IN
TEXT MODE, ... IN BINARY MODE, and so on). If the file is opened using ... IN
Example:
Case - 10:
Cause: If OPEN DATASET is not executed in a Unicode Program, and if the user has
“Write” authorization for the file, the file is opened in Read and Write mode. Otherwise,
its opened only in “Read” mode. But if the OPEN DATASET is executed in a Unicode
Program, we need to mention in which mode it should open the dataset.
Solution:
In the Unicode Environment, there are four modes in which the dataset can be opened.
Depending upon the requirement, the user should open the dataset in any of the four
modes to make the program Unicode Compatible.
Example:
CASE 11 :
Solution :
Case - 16:
Solution: Data that is not available in ABAP format (that is, text data that is not in the
system code page format, or numeric data that is not in the byte order used on the
application server), is stored in an X field or XSTRING in binary form.
When converting to an ABAP format from another format, data is read from a
byte sequence and written to an ABAP data object.
When converting from an ABAP format to another format, data is read from an
ABAP data object and written as a byte sequence.
CL_ABAP_CONV_IN_CE
Converting other formats to ABAP data objects. (Reading a binary input stream).
CL_ABAP_CONV_OUT_CE
Converting ABAP data objects to another format. (Writing to a binary output stream).
CL_ABAP_CONV_X2X_CE
Converting data from one format to another. (Reading from a binary input stream and
writing to a binary output stream).
CL_ABAP_CONV_OBJ
Converting data from one format to another.
Example :
zzmbbpsysm-cpcodepage = '1100'.
* TRANSLATE context-fieldcont
* FROM CODE PAGE zzmbbpcath-cpcodepage
* TO CODE PAGE zzmbbpsysm-cpcodepage.
Clear: l_out,
l_converter,
l_fromcode,
l_tocode.
l_fromcode = L_CODEPAGE.
l_tocode = L_UNICODECP.
IF sy-subrc eq 0.
* Do Nothing.
ENDIF.
Clear: l_out,
l_converter,
l_fromcode,
l_tocode.
Before Unicode
TRANSLATE T143T-TBTXT FROM CODE PAGE '1100' TO CODE PAGE '1105'.
After Unicode
Use class for Translate codepage to codepage.
Data : g_codepage LIKE tcp0c-charco VALUE '1100'.
CONSTANTS: c_unicodecp(4) VALUE '1105'.
*here its not mentioned that from which code page it has to be translated.
This will give an information on from which codepage we have to transfer it from.
Case - 17:
Error : "SSFCOMPOP" must be a flat structure. You cannot use internal tables,
strings, references, or structures as components. .
Example :
Here SSFCOMPOP is a flat structure .So we have to declare variable PRINTER of type
Data element of field TDDEST which is ‘RSPOPNAME’.
Case - 18:
Solution :
lv_title = text-007.
l_def_file = lv_def_filename.
l_def_file = ''.
l_def_file = ''.
FILE_TABLE = lt_files
RC = l_subrc
USER_ACTION = l_usr_act
* FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
.
LOOP AT lt_files INTO l_file.
MOVE l_file-filename TO l_def_file.
MOVE l_def_file TO file_pc.
EXIT.
ENDLOOP.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
***************************************************************
The Equivalent Function Module for WS_QUERY-File Exist in ABAP 4.7 is
CL_GUI_FRONTEND_SERVICES=>FILE_EXIST or WS_QUERY-Directory Exist is
CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST.
W_FILENAME = WK_DIRECTRY.
if sy-subrc 0.
ndone = -1.
else.
ndone = 1.
case nplatform.
when cl_gui_frontend_services=>platform_windows95.
return = 'WN32_95'.
when cl_gui_frontend_services=>platform_windows98.
return = 'WN32_98'.
when cl_gui_frontend_services=>platform_nt351.
return = 'WN32'.
when cl_gui_frontend_services=>platform_nt40.
return = 'WN32'.
when cl_gui_frontend_services=>platform_nt50.
return = 'WN32'.
when cl_gui_frontend_services=>platform_mac.
return = 'MC'.
when cl_gui_frontend_services=>platform_os2.
return = 'PM'.
when cl_gui_frontend_services=>platform_linux.
return = 'MF'.
when cl_gui_frontend_services=>platform_hpux.
return = 'MF'.
when cl_gui_frontend_services=>platform_tru64.
return = 'MF'.
when cl_gui_frontend_services=>platform_aix.
return = 'MF'.
when cl_gui_frontend_services=>platform_solaris.
return = 'MF'.
when cl_gui_frontend_services=>platform_macosx.
return = 'MF'.
when 14. "PLATFORM_WINDOWSXP
return = 'WN32'.
when cl_gui_frontend_services=>platform_unknown.
return = '??'.
when others.
return = '??'.
endcase.
endif.
***************************************************************