Monday, December 6, 2010

Things to look out for Unicde Conversion

Hello,
Below are few hints which can be useful for Unicde conversion projetcs.
Transaction to check the objects which are relevant for Unicode conversion : UCCHECK

1. File Interface - OPEN DATASET

The majority of ABAP changes needed on SAP system for Unicode involve the file interface. This section describes the expected changes for OPEN DATASET, READ, and TRANSFER statements.

1.1 - OPEN...TEXT MODE

The non-Unicode syntax for accessing the file system in text mode is:

OPEN DATASET dsn FOR access IN TEXT MODE.

The expected change for this type of syntax for Unicode is:

OPEN DATASET dsn FOR access IN TEXT MODE ENCODING DEFAULT.

The value of FOR access (INPUT, OUTPUT, APPENDING, UPDATE) will remain the same.


1.2 - OPEN...BINARY MODE

The non-Unicode syntax for accessing the file system in binary mode is:

OPEN DATASET dsn FOR access IN BINARY MODE.

The expected change for this type of syntax for Unicode is:

OPEN DATASET dsn FOR access IN LEGACY BINARY MODE.

The value of FOR access (INPUT, OUTPUT, APPENDING, UPDATE) will remain the same.

1.3 - READ/TRANSFER

No change to the syntax of READ or TRANSFER is needed. However, a runtime error triggers if the OPEN statement does not exist for these statements.


2. WS_UPLOAD/WS_DOWNLOAD

Functions WS_UPLOAD, WS_DOWNLOAD, UPLOAD, and DOWNLOAD are being replaced. In all cases, the new function GUI_UPLOAD will replace functions WS_UPLOAD and UPLOAD, and function GUI_DOWNLOAD will replace functions WS_DOWNLOAD and DOWNLOAD.

The snippet below show examples of how GUI_UPLOAD and GUI_DOWNLOAD should be implemented. The designation implies carrying over the variable from

WS_UPLOAD, WS_DOWNLOAD, UPLOAD, or DOWNLOAD. Any new parameter supplied with GUI_UPLOAD or GUI_DOWNLOAD should remain commented out.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename =

filetype =

HAS_FIELD_SEPARATOR = ' '

header_length =

READ_BY_LINE = 'X'

dat_mode =

codepage =

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

CHECK_BOM = ' '

VIRUS_SCAN_PROFILE =

IMPORTING

filelength =

HEADER =

TABLES

data_tab =



CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize =

filename =

filetype =

WRITE_FIELD_SEPARATOR = ' '

col_select =

col_select_mask =

no_auth_check =

codepage =

wk1_n_format =

wk1_n_size =

wk1_t_format =

wk1_t_size =

IMPORTING

filelength =

TABLES

data_tab =

fieldnames = .

3. Character Strings and Byte Strings

The following statements can be used for processing character strings or byte strings.

CONCATENATE, FIND, SEARCH, REPLACE, SHIFT, SPLIT, CONDENSE, CONVERT TEXT, OVERLAY, TRANSLATE.

Research into the data object type used with the above statements must be done to find the appropriate syntax update. If the data object type is CHARACTER, no syntax changes are necessary. The addition IN CHARACTER MODE is made by default with no changes to the code. For example:

The addition IN CHARACTER MODE is not needed.

CONCATENATE x1 x2 INTO result.

If the data object type is BYTE, add the addition IN BYTE MODE. For example:

CONCATENATE x1 x2 INTO result IN BYTE MODE.

=4. Find Distance of Strings
DESCRIBE...DISTANCE

Research into the data object types used with DESCRIBE...DISTANCE must be done to find the appropriate syntax update.

If the data object type is CHARACTER, use:

DESCRIBE DISTANCE BETWEEN dobj1 AND dobj2 INTO off IN CHARACTER MODE.

If the data object type is BYTE, use:

DESCRIBE DISTANCE BETWEEN dobj1 AND dobj2 INTO off IN BYTE MODE.

Examples

OPEN.......TEXT

Non-Unicode

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.

Unicode

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. " Unicode

Unicode to Replace UPLOAD or WS_UPLOAD

Data: filename TYPE String.

Constants: c_tab TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab.

call function 'GUI_UPLOAD'

exporting

filename = filename

has_field_separator = c_tab

tables

data_tab = tl_upltext

exceptions

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_table_width = 4

invalid_type = 5

no_batch = 6

unknown_error = 7.



CONCATENATE

Non-Unicode

DATA: x1(1) TYPE x,

x2(1) TYPE x,

result(2) TYPE x.

. . .

CONCATENATE x1 x2 INTO result.

Unicode

DATA: x1(1) TYPE x,

x2(1) TYPE x,

result(2) TYPE x.

. . .

CONCATENATE x1 x2 INTO result IN BYTE MODE.


DESCRIBE

Non-Unicode

DATA: f1(10) TYPE c,

ilen TYPE i.

. . .

DESCRIBE FIELD f1 LENGTH ilen.

Unicode

DATA: f1(10) TYPE c,

ilen TYPE i.

. . .

DESCRIBE FIELD f1 LENGTH ilen IN CHARACTER MODE.

Cheers,
Sandeep

No comments:

Post a Comment