Enhancement for RFC_READ_TABLE to read tables wider than 512 characters

RFC_READ_TABLE is a function module to read the content of a table from a remote system via RFC. The classic way works only for tables with a maximum row width of 512 characters. Attempting to read wider tables, such as ACDOCA, results with the exception DATA_BUFFER_EXCEEDED and the error message AD-559 “Table ACDOCA is too wide to display (512 bytes).”

Here an example:

TYPES:
  ts_data TYPE tab512,
  tt_data TYPE STANDARD TABLE OF ts_data WITH DEFAULT KEY.

DATA:
  lt_data TYPE tt_data.

CALL FUNCTION 'RFC_READ_TABLE'
  EXPORTING
    query_table          = 'ACDOCA'
*   DELIMITER            = ' '
*   NO_DATA              = ' '
*   ROWSKIPS             = 0
    rowcount             = 10 " max rows
*   GET_SORTED           =
*   USE_ET_DATA_4_RETURN =
* IMPORTING
*   ET_DATA              =
  TABLES
*   OPTIONS              =
*   FIELDS               =
    data                 = lt_data
  EXCEPTIONS
    table_not_available  = 1
    table_without_data   = 2
    option_not_valid     = 3
    field_not_valid      = 4
    not_authorized       = 5
    data_buffer_exceeded = 6
    OTHERS               = 7.

* SY-SUBRC = 6
" Message AD-559: Table ACDOCA is too wide to display (512 bytes).

As described in SAP Note 3291780 – Enhancement RFC_READ_TABLE (7.31) the function module has been enhanced with:

  • import parameter USE_ET_DATA_4_RETURN
  • export parameter ET_DATA.

These parameters allow reading tables wider than 512 characters. Here is an example:

DATA:
  lt_data      TYPE sdti_result_tab,
  lv_delimiter TYPE c VALUE '|',
  lv_max_rows  TYPE i VALUE 10.

CALL FUNCTION 'RFC_READ_TABLE'
  EXPORTING
    query_table          = 'ACDOCA'
    delimiter            = lv_delimiter
*   NO_DATA              = ' '
*   ROWSKIPS             = 0
    rowcount             = lv_max_rows
*   GET_SORTED           =
    use_et_data_4_return = 'X'
  IMPORTING
    et_data              = lt_data
* TABLES
*   OPTIONS              =
*   FIELDS               =
*   DATA                 =
  EXCEPTIONS
    table_not_available  = 1
    table_without_data   = 2
    option_not_valid     = 3
    field_not_valid      = 4
    not_authorized       = 5
    data_buffer_exceeded = 6
    OTHERS               = 7.

DATA:
  lt_acdoca TYPE STANDARD TABLE OF acdoca,
  ls_acdoca TYPE acdoca.

LOOP AT lt_data INTO DATA(ls_data).
  SPLIT ls_data-line AT lv_delimiter INTO TABLE DATA(lt_field).
  ASSIGN ls_acdoca TO FIELD-SYMBOL(<fs_acdoca>).
  LOOP AT lt_field INTO DATA(lv_field).
    ASSIGN COMPONENT sy-tabix OF STRUCTURE <fs_acdoca> TO FIELD-SYMBOL(<fs_field>).
    ASSERT sy-subrc = 0.
    <fs_field> = lv_field.
  ENDLOOP.
  APPEND ls_acdoca TO lt_acdoca.
ENDLOOP.

See other related notes on my website:

Scroll to Top