2006 Jul 28 12:56 AM
Are there any tools that modify ABAP programs to correct Unicode syntax errors/warnings and automatically make the ABAP programs Unicode compliant?
(I know that if it were completely obvious what was intended SAP could have interpretted the ABAP statement that way without producing a message. So I know that this can't really be completely automatic with no human intelligence. But I'm looking for tools that make the job easier, perhaps with some notice to the programmer about what was done so he can change it - or perhaps with a question to the programmer about what the intent was, so he can direct the tool about which interpretation to make.)
/David Rosenberg << personal information removed >>
Edited by: Rob Burbank on Feb 19, 2010 9:22 AM
Are there any tools that modify ABAP programs to correct Unicode syntax errors/warnings and automatically make the ABAP programs Unicode compliant?
(I know that if it were completely obvious what was intended SAP could have interpretted the ABAP statement that way without producing a message. So I know that this can't really be completely automatic with no human intelligence. But I'm looking for tools that make the job easier, perhaps with some notice to the programmer about what was done so he can change it - or perhaps with a question to the programmer about what the intent was, so he can direct the tool about which interpretation to make.)
/David Rosenberg << personal information removed >>
Edited by: Rob Burbank on Feb 19, 2010 9:22 AM
2006 Jul 28 12:59 AM
hi,
you dont have any tool for automatic conversion of your ABAP Code into Unicode Complaint..
Cheers,
Abdul Hakim
2006 Jul 28 2:29 AM
David
Try using transaction UCCHECK which can give you the list of programs which have unicode compatable errors even with the line numbers referring to the statement.
I do have a document prepared personally which lists out the type of errors and action to be taken basing on the Error Code. Please let me know incase you are interested.
Thanks
Eswar
2006 Jul 28 4:34 AM
2006 Aug 24 5:50 AM
2006 Aug 25 5:59 AM
2007 Mar 22 1:18 PM
2007 Mar 22 1:24 PM
2007 Mar 22 2:51 PM
2007 Mar 26 10:50 PM
2007 Mar 27 5:01 AM
2007 Apr 07 7:20 AM
2007 Apr 11 7:24 PM
2007 Jun 05 11:15 AM
2007 Jun 06 9:34 AM
2007 Nov 23 11:35 AM
2007 Dec 07 11:26 AM
2008 Jan 09 4:13 AM
2008 Feb 05 9:25 AM
2008 Mar 02 7:31 PM
Several people have written to me asking for information mentioned in this thread.
I'm sorry to report that I never received the document referred to in this thread. My role in our Unicode work was modifying ABAP programs to be Unicode compliant. In our unicode conversion, we relied very heavily on SAP supplied documentation and a document titled "Obsolete ABAP Language Constructs" that was written by an SAP employee, but made available as an SDN Community Contribution which is not an official SAP document.
We found that the Unicode error that we encountered most frequently was the OPEN DATASET command (which now must explicitly specify BINARY MODE or TEXT MODE (and if TEXT MODE, what encoding is to be used).
Since 90% of our files are text files and all of the text files use NON-UNICODE encoding, my colleague Allan Davidson wrote a program to handle that one case. That is, the program read through ABAP source code and if it found an OPEN DATASET statement, it modified the statement to be Unicode compliant, making the assumption that the file was actually supposed to be a text file with non-Unicode encoding.
All of our other changes (including the small number of files that were actually binary files) were changed by programmers.
I am appending to this message, some notes that I wrote to help programmers who encountered certain situations.
I hope this is of some help.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Need to define a character which is an ASCII control character (such
as Horizontal-Tab, Line-Feed, Carriage-Return, Form-Feed, etc.)
In a Non-Unicode system, this was usually done by defining constant
(or variable) of type X and giving it the literal hexadecimal value of
the desired control character. (This could either be used as a
variable of type X or you could go though a few more tricks to create
a variable of type C with that value.) This doesn't work when Unicode
checks are active.
With Unicode checks active, you can do one of the following:
1. If you want one of the control characters Backspace, Form-Feed,
Horizontal-Tab, New-Line (= Line-Feed), Vertical-Tab, or the two
character sequence "Carriage-Return + Line-Feed" You can use the
SAP-defined constant attributes of the class CL_ABAP_CHAR_UTILITIES:
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: bs(1) TYPE c VALUE cl_abap_char_utilities=>backspace,
cr(1) TYPE c VALUE cl_abap_char_utilities=>cr_lf,
crlf(2) TYPE c VALUE cl_abap_char_utilities=>cr_lf,
ff(1) TYPE c VALUE cl_abap_char_utilities=>form_feed,
ht(1) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
lf(1) TYPE c VALUE cl_abap_char_utilities=>newline,
vt(1) TYPE c VALUE cl_abap_char_utilities=>vertical_tab,
mn(1) TYPE c VALUE cl_abap_char_utilities=>minchar,
mx(1) TYPE c VALUE cl_abap_char_utilities=>maxchar.
2. If you want an arbitrary control character, I don't know how to get
it into a constant, but you can do the following to get it into a
variable:
DATA: cc_char(1) TYPE C.
cc_char = cl_abap_conv_in_ce=>uccpi( decimal ).
(Where "decimal" is the decimal value of the desired ASCII control character.)
For example, an Escape character (= ESC) is hex 1B (= decimal 27).
So if you needed an Escape character, you could write:
DATA: esc(1) TYPE C.
esc = cl_abap_conv_in_ce=>uccpi( 27 ).
In one Unicode conversion, the 4.6C version of the program filled a
"low" field with the lowest possible character values and a "high"
field with the highest possible character values. To do this, it
defined one hex constant with the (hex) value '00000000' and another
hex constant with the (hex) value 'FFFFFFFF'. It then stored these
hex values in the low and high (character) fields.
In our 7.00 system, the static class attribute
cl_abap_char_utilities=>minchar is a '00' (or its 16-bit counterpart),
and cl_abap_char_utilities=>maxchar is a 'FF' (or its 16-bit
counterpart). One way to get a sequence of these characters as a
constant is to define a constant structure which is made of a bunch of
one-character components with these values. For example:
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: begin of min_4,
min01(1) TYPE c VALUE cl_abap_char_utilities=>minchar,
min02(1) TYPE c VALUE cl_abap_char_utilities=>minchar,
min03(1) TYPE c VALUE cl_abap_char_utilities=>minchar,
min04(1) TYPE c VALUE cl_abap_char_utilities=>minchar,
end of min_4.
and then use this structure as though it were a single four-character
field of type C.
Another suggestion that I've heard is that we follow the example SAP
set with the CL_ABAP_CHAR_UTILITIES class and define our own class
with public, read-only, static class attributes that are "MIT
constants". One of these read-only attributes could be a 255-character
field filled with MINCHARs and another could be a 255-character field
filled with MAXCHARs. Programs could then reference these attributes
with a length specification to use whatever size fragment was needed.
(We have not tried to create such a class yet.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing one or more of a set of similar fields within a structure
(for example 16 fields for 16 fiscal periods)
Rather than determine the length of each field and then computing the
offset to the desired field, consider using one of the following
methods instead:
If the similar fields are contiguous, use the ASSIGN .. INCREMENT
statement, like this:
DATA inc TYPE i.
FIELD-SYMBOLS <fs> TYPE table-field01.
inc = period - 1.
ASSIGN table-field01 INCREMENT inc TO <fs> RANGE table.
or, to loop over the fields
DO 16 TIMES.
inc = sy-index - 1.
ASSIGN table-field01 INCREMENT inc TO <fs> RANGE table.
..
ENDDO.
If the similar fields are regularly spaced, but not contiguous, and
you want to loop over all the fields, you can use the DO .. VARYING
statement, like this:
DO 16 TIMES
VARYING fielda FROM tablea-field01 NEXT tablea-field02 RANGE tablea
VARYING fieldb FROM tableb-field01 NEXT tableb-field02 RANGE tableb
VARYING fieldc FROM tablec-field01 NEXT tablec-field02 RANGE tablec.
..
ENDDO.
If the similar fields are regularly named, but not contiguous, and you
want to access one of them, you could use an ASSIGN statement with a
computed name, like this:
DATA name(60) TYPE c.
DATA number(2) TYPE n.
number = period.
CONCATENATE 'TABLEA-FIELD' number into name.
ASSIGN (name) TO <fs> RANGE table.
If the similar fields are regularly spaced, but not regularly named or
contiguous, and you want to access one of them, you could use a
DESCRIBE DISTANCE statement, like this:
DATA dist TYPE i.
DATA offset TYPE i.
FIELD-SYMBOLS <fs> TYPE field1.
DESCRIBE DISTANCE BETWEEN field1 AND field2 INTO dist IN BYTE MODE.
offset = dist * ( period - 1 ).
ASSIGN field1+offset TO <FS>.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Determining the directory separator character to use for file paths in
the SAPgui desktop operating system
(This is taken from SAP Note 861805)
When files are uploaded or downloaded, you sometimes need to create a
path with directory separators that are valid for the client operating
system. On Windows operating systems, this is the character \
(Backslash), and on UNIX-type operating systems such as Linux and Mac
OS X, it is / (Slash).
You can now use the method
cl_gui_frontend_services=>get_file_separator to get the appropriate
directory separator character for the operating system on which the
SAPgui is running. Here is an example:
DATA g_directory_separator(1) TYPE c.
CALL METHOD cl_gui_frontend_services=>get_file_separator
CHANGING
file_separator = g_directory_separator
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Selecting a desktop file for reading / opening
DATA: file_table TYPE filetable,
number_of_files TYPE I,
user_action TYPE I,
file_encoding TYPE abap_encod.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Title Text' " Type string
default_extension = 'txt' " Type string
default_filename = 'name' " Type string
* FILE_FILTER = FILE_FILTER " Type string
* WITH_ENCODING = WITH_ENCODING " Type ABAP_BOOL
* " abap_true or abap_false
* INITIAL_DIRECTORY = INITIAL_DIRECTORY" Type string
multiselection = abap_false " Type ABAP_BOOL
* " abap_false = just one file;
* " abap_true = Multiple files permitted
CHANGING
file_table = file_table " TYPE filetable (Table of file path(s))
rc = number_of_files " Type I (Number of files selected)
user_action = user_action " Type I
* " cl_gui_frontend_services=>ACTION_OK, or
* " cl_gui_frontend_services=>ACTION_CANCEL
file_encoding = file_encoding " Type abap_encod
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Selecting a desktop file for writing / saving
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
WINDOW_TITLE = 'Title Text' " Type string
DEFAULT_EXTENSION = 'txt' " Type string
DEFAULT_FILE_NAME = 'name' " Type string
* WITH_ENCODING = WITH_ENCODING " Type ABAP_BOOL
* " abap_true or abap_false
* FILE_FILTER = FILE_FILTER " Type string
* INITIAL_DIRECTORY = INITIAL_DIRECTORY" Type string
PROMPT_ON_OVERWRITE = 'X' " Type ABAP_BOOL
* " abap_false = Don't prompt if file exists
* " abap_true = Prompt if file exists
CHANGING
filename = filename " Type string (filename user selected)
path = path " Type string (path to directory
* " containing the file)
fullpath = fullpath " Type string (Full path = Path + filename)
USER_ACTION = USER_ACTION " Type I
* " cl_gui_frontend_services=>ACTION_OK,
* " cl_gui_frontend_services=>ACTION_CANCEL,
* " cl_gui_frontend_services=>ACTION_APPEND, or
* " cl_gui_frontend_services=>ACTION_REPLACE
FILE_ENCODING = FILE_ENCODING " Type abap_encod
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Uploading a tab-delimited desktop file into a multi-column table
DATA: file_table TYPE filetable,
filepath TYPE string.
FIELD-SYMBOLS: <filepath> type line of filetable,
READ TABLE file_table INDEX 1 ASSIGNING <filepath>.
filepath = <filepath>.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = filepath " Type string
filetype = 'ASC' " Type char10 ('ASC' or 'BIN')
has_field_separator = 'X' " Type char01 (space = no separaters
* " 'X' = tabs separate fields)
* HEADER_LENGTH = 0 " Type I (only for binary files)
read_by_line = 'X' " Type char01 (space = Pack input
* " into table which must have just
* " one field; 'X' = Put each input
* " record in a separate internal
* " table row)
* DAT_MODE = SPACE " Type char01 (space = store as
* " characters; 'X' = I, N, P, F, D,
* " or T will be stored properly
* " if input is in WS_DOWNLOAD "DAT"
* " format)
* CODEPAGE = SPACE " Type abap_encod
ignore_cerr = abap_false " Type ABAP_BOOL ( abap_false =
* " raise an exception for a character
* " conversion error; abap_true =
* " ignore a character conversion
* " error)
replacement = '#' " Type ABAP_REPL (character with
* " which to replace a character
* " which can't be converted)
* VIRUS_SCAN_PROFILE = VIRUS_SCAN_PROFILE " Type VSCAN_PROFILE
* IMPORTING
* FILELENGTH = FILELENGTH " Type I (Number of bytes(???)
* " transferred)
* HEADER = HEADER " Type Xstring (only for a binary
* " file)
CHANGING
data_tab = sf2_tab " Type standard table
* " The internal table into which the
* " file will be uploaded
EXCEPTIONS
file_open_error = 1 " File Does not Exist and Cannot be Opened
file_read_error = 2 " Error reading file
no_batch = 3 " Front-End Function Cannot Be Executed in Backgrnd
gui_refuse_filetransfer = 4 " Incorrect front end, or error in front end
invalid_type = 5 " Incorrect parameter FILETYPE
no_authority = 6 " No Upload Authorization
unknown_error = 7 " Unknown Error
bad_data_format = 8 " Cannot Interpret Data in File
header_not_allowed = 9 " Header not allowed
separator_not_allowed = 10 " Separator not allowed
header_too_long = 11 " Information Currently Restricted to 1023 Bytes
unknown_dp_error = 12 " Error Calling Data Provider
access_denied = 13 " Access to File Denied
dp_out_of_memory = 14 " Not Enough Memory in Data Provider
disk_full = 15 " Storage Medium full
dp_timeout = 16 " Timeout of Data Provider
not_supported_by_gui = 17 " GUI does not support this
error_no_gui = 18 " GUI not Available
OTHERS = 19.
Note that the UPLOAD and WS_UPLOAD function modules accepted a
variable of type "C" for the filename parameter and a table with a
header line as the data table. CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
requires that the filename be passed as a STRING and that the data
table not have a header line. The easiest way to modify an existing
program to handle these issues when calling
CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD are:
1. Define a variable of type STRING and pass that variable for the
filename parameter. Set that variable equal to the TYPE C variable
just before calling CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD.
2. If the table with the header line is INTERNAL_TABLE, then pass
INTERNAL_TABLE[] for the data table parameter.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Downloading a multi-column table into a tab-delimited desktop file
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
* BIN_FILESIZE = BIN_FILESIZE " Type I
filename = filename " Type string
FILETYPE = 'ASC' " Type char10 ('ASC' or 'BIN')
* APPEND = SPACE " Type char01 ('X' = Append, Space = Overwrite)
WRITE_FIELD_SEPARATOR = 'X' " Type char01 ('X' = Separate columns with tabs;
* " Space = don't put in tabs as separaters)
* " NOTE: If you are writing a tab-delimited file,
* " this parameter should be 'X". If you are writing
* " a file with fixed-length fields, this parameter
* " should be SPACE.
* HEADER = '00' " Type xstring (Byte chain written to beginning of
* " file in binary mode)
trunc_trailing_blanks = 'X' " Type char01 (space = Write blanks at the end of
* " char fields; 'X' = Don't write trailing blanks)
* " Space = don't put in tabs as separaters)
* " NOTE: If you are writing a tab-delimited file,
* " this parameter should be 'X". If you are writing
* " a file with fixed-length fields, this parameter
* " should be SPACE.
* WRITE_LF = 'X' " Type char01 ('X' = Write end-of-line sequence at
* " the end of each row in char mode; Space - don't)
* COL_SELECT = SPACE " Type char01 ('X' download only selected columns
* " of the table; space = download all columns)
* COL_SELECT_MASK = SPACE " Type char255 (Vector containing an 'X' for each
* " column to downloaded or space for each column to
* " be skipped)
* DAT_MODE = SPACE " Type char01 ('X' = Numeric and date fields are
* " in WS_DOWNLOAD DAT format; space = no special
* " handling of numeric and date fields)
* CONFIRM_OVERWRITE = 'X' " Type char01 ('X' = Overwrite file only after
* " confirmation; space = Just do it)
* NO_AUTH_CHECK = SPACE " Type char01 (Space = Check for access rights;
* " 'X' = Switch off check for access rights)
* CODEPAGE = SPACE " Type ABAP_ENCODING (Character Representation for
* " Output)
* IGNORE_CERR = ABAP_TRUE " Type ABAP_BOOL (ABAP_TRUE = Ignore errors
* " converting char. sets; ABAP_FALSE = ???)
* REPLACEMENT = '#' " Type ABAP_REP (Replacement character for
* " characters which can't be converted)
* WRITE_BOM = SPACE " Type ABAP_BOOL (ABAP_TRUE = Write a Byte
* " Order Mark at the beginning of the downloaded
* " file; ABAP_FALSE = Don't write a Byte Order Mark)
* TRUNC_TRAILING_BLANKS_EOL = 'X' " Type char01 ('X' = Remove trailing blanks in
* " last column; Space = Don't)
* WK1_N_FORMAT = SPACE " Type C (Format for value columns in files of the
* " type WK1. '0' = Standard Format;
* " '1x' - Fixed point format with x decimal places
* " '2x' = Currency format with x decimal places)
* WK1_N_SIZE = SPACE " Type C (Column width for value columns in files
* " of the type WK1)
* WK1_T_FORMAT = SPACE " Type C (Format for text columns for files of the
* " type WK1. '0' = left-justified;
* " '1' :right-justified; '2' :centered)
* WK1_T_SIZE = SPACE " Type C (Column width for text columns for files
* " of the type WK1)
IMPORTING
FILELENGTH = FILELENGTH " Type I (Number of bytes transferred)
CHANGING
data_tab = data_tab " Type Standard Table (Table to be downloaded)
EXCEPTIONS
FILE_WRITE_ERROR = 1 " Cannot Write to File
NO_BATCH = 2 " Front-End Function Cannot Be Executed in Backgrnd
GUI_REFUSE_FILETRANSFER = 3 " Incorrect Front End
INVALID_TYPE = 4 " Invalid value for parameter FILETYPE
NO_AUTHORITY = 5 " No Download Authorization
UNKNOWN_ERROR = 6 " Unknown Error
HEADER_NOT_ALLOWED = 7 " Header not allowed
SEPARATOR_NOT_ALLOWED = 8 " Separator not allowed
FILESIZE_NOT_ALLOWED = 9 " File Size Must Not Be Specified
HEADER_TOO_LONG = 10 " Information Currently Restricted to 1023 Bytes
DP_ERROR_CREATE = 11 " Cannot create Data Provider
DP_ERROR_SEND = 12 " Error sending data with Data Provider
DP_ERROR_WRITE = 13 " Error writing data with Data Provider
UNKNOWN_DP_ERROR = 14 " Error calling Data Provider
ACCESS_DENIED = 15 " Access to file denied
DP_OUT_OF_MEMORY = 16 " Not enough memory in Data Provider
DISK_FULL = 17 " Storage medium full
DP_TIMEOUT = 18 " Timeout of Data Provider
FILE_NOT_FOUND = 19 " Cannot find file
DATAPROVIDER_EXCEPTION = 20 " General exception error in Data Provider
CONTROL_FLUSH_ERROR = 21 " Error in Control Framework
NOT_SUPPORTED_BY_GUI = 22 " GUI does not support this
ERROR_NO_GUI = 23 " GUI not available
others = 24.
Note that the DOWNLOAD and WS_DOWNLOAD function modules accepted a
variable of type "C" for the filename parameter and a table with a
header line as the data table. CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
requires that the filename be passed as a STRING and that the data
table not have a header line. The easiest way to modify an existing
program to handle these issues when calling
CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD are:
1. Define a variable of type STRING and pass that variable for the
filename parameter. Set that variable equal to the TYPE C variable
just before calling CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD.
2. If the table with the header line is INTERNAL_TABLE, then pass
INTERNAL_TABLE[] for the data table parameter.
2008 Jun 20 9:15 PM
2010 Feb 19 12:39 PM
Hi,
Just now we completed upgrade. I have to check 1000 Z programs with unicode compliance.
if possible please help to send the document to << personal information removed >>
Thanks in advance.
sharma
Edited by: Rob Burbank on Feb 19, 2010 9:22 AM
2006 Aug 25 6:51 AM
Hello David
You have transaction <b>UCCHECK</b> available (>= 6.20) to check if your customer programs are already unicode-enabled. Another testing transaction is <b>SAKB5</b> which checks the enhancement category of tables/structures (while it was no problem to append tables/structures in any way in a non-unicode system we may run into trouble here in a unicode system).
On the ALV list that is displayed by UCCHECK you can directly jump to the coding of the program objects that are not yet unicode-enabled. To make it unicode-enabled you have to change the coding yourself.
The only thing where SAP automates conversion are maintenance views. Using report <b>RSVIMT_NON_UC_VIM_AREAS</b> you get a list of function modules and views that need to be converted to unicode.
Using report <b>RSVIMT_UC_VIEW_MAINT_GEN</b> you can automatically convert the views.
However, if you have defined events in your views you have to correct them yourself because SAP does and cannot take care of them.
I have already converted a large software package that we have developed inhouse to unicode including maintenance views and it worked fine.
Regards
Uwe
2007 Oct 18 3:30 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |