CL_ABAP_UTF8STRING_TAB - Obsolete: Strings <-> UTF-8 conversions

ROGBILLS - Synchronize billing plans   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Functionality

This class is obsolete in releases higher than 4.6x and only exists for reasons of backward compatibility. The RFC itself supports Unicode.

This class converts character-type data into a suitable format for transfer using Remote Function Call. The data is stored in a table with a fixed line length using UTF-8 (Unicode Transformation Format, 8 bit).

The table has the type UTF8STRTAB. A table represents a list of strings. Each object contains a reference to a table.

This class is a temporary solution until RFC supports Unicode and the data type STRING. It allows older systems to communicate with Unicode systems.

Class Methods:

CREATE: Creates and initializes an object.

Instance Methods:

PUT: Converts data to UTF-8 and appends it to the table. The parameters can be alphanumeric or numeric, or be a structure containing these types.

GET_NEXT: Gets the next UTF-8 string from the table. If the parameter is a structure,it gets the corresponding number of strings. The first GET_NEXT call gets one or more strings starting at the beginning of the table.

DECREMENT_ITERATOR: Decreases the iterator by one string, so that the next GET_NEXT call rereads the last string to be read.

SET_ITERATOR: Sets the iterator to the n-th string.

CLEAR: Deletes the contents of the table.

Relationships

Example

REPORT utf8str_test.

DATA:
  o1 TYPE REF TO cl_abap_utf8string_tab,
  xtab TYPE utf8strtab,
  rc TYPE utf8str_rc,
  str TYPE string,
  BEGIN OF struc,
    cc(3) TYPE c,
    nn(5) TYPE n,
  END OF struc.

START-OF-SELECTION.

* The function 'ZTEST_UTF8STR' puts some data into the table.
  CALL FUNCTION 'ZTEST_UTF8STR' DESTINATION 'NONE'
                TABLES tab = xtab.

  CALL METHOD cl_abap_utf8string_tab=>create
              IMPORTING ref = o1
              CHANGING  tab = xtab.

* Get the first string from xtab into str.
  CALL METHOD o1->get_next
              IMPORTING  obj = str
              EXCEPTIONS OTHERS = 7.
  IF sy-subrc <> 0.
* Some error handling
  ENDIF.

* Get the 2nd and 3rd string from xtab into struc.
  CALL METHOD o1->get_next
              IMPORTING  obj = struc
              CHANGING   rc = rc
              EXCEPTIONS non_fatal = 1
                         OTHERS = 7.
  IF sy-subrc <> 0.
* Some error handling
  ENDIF.

  WRITE :/ 'str:', str.
  WRITE :/ 'cc:' , struc-cc.
  WRITE :/ 'nn:' , struc-nn.


FUNCTION ztest_utf8str.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      TAB TYPE  UTF8STRTAB
*"----------------------------------------------------------------------

  DATA:
    o1 TYPE REF TO cl_abap_utf8string_tab,
    str TYPE string,
    BEGIN OF struc,
      cc(3) TYPE c,
      nn(5) TYPE n,
    END OF struc.

  str = 'Some Text to be sent.'.
  struc-cc = 'ABC'.
  struc-nn = '01234'.

  CALL METHOD cl_abap_utf8string_tab=>create
              IMPORTING ref = o1
              CHANGING  tab = tab[].

  CALL METHOD o1->put
                  EXPORTING  obj = str
                  EXCEPTIONS OTHERS = 5.
  IF sy-subrc <> 0.
* Some error handling
  ENDIF.

  CALL METHOD o1->put
                  EXPORTING  obj = struc
                  EXCEPTIONS OTHERS = 5.
  IF sy-subrc <> 0.
* Some error handling
  ENDIF.

ENDFUNCTION.

Notes

Tables with the type UTF8STRTAB contain data with the type RAW. The first line of thetable contains administrative information. Each string starts in a new table line. The first byte ofeach line specifies how many of the following bytes belong to the string. The first byte contains 'FF' (hexadecimal) if the string is continued in the next line.

Further information

Refer to the documentation of the individual methods.


PERFORM Short Reference   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.


Length: 6630 Date: 20120526 Time: 083448     triton ( 186 ms )