This guide describes how to send data from a custom Z table in SAP to a remote system using the class ZONCL_FETCH_DATA_V2
. The process supports optional filters and allows update/delete operations on the target system.
Start by declaring the necessary objects and structures:
DATA:
lo_fetch_data TYPE REF TO zoncl_fetch_data_v2, " Object for data transfer
lt_where TYPE ZONTTRSDSWHERE, " WHERE conditions table
ls_where TYPE ZONTRSDSWHERE. " Individual condition line
Instantiate the processing class:
CREATE OBJECT lo_fetch_data.
Apply one or more logical filters to limit the data being sent:
ls_where = '( LIFNR NE ''999'' )'.
APPEND ls_where TO lt_where.
Example with multiple conditions:
ls_where = '( BUKRS EQ ''1000'' AND LIFNR NE ''999'' )'.
APPEND ls_where TO lt_where.
Note: These filters are applied on the source system before transmission.
Call the method send_json_any_table
with the relevant parameters:
CALL METHOD lo_fetch_data->send_json_any_table
EXPORTING
iv_tabname = 'ZONTA_APAGING' " Table name
iv_update = 'X' " 'X' allows updates on destination
iv_delete = ' ' " 'X' allows deletion; space disables it
it_where = lt_where " WHERE conditions
iv_alias = ' ' " Optional alias
iv_dest = 'ONIBEX'. " RFC destination (defined in SM59)
Basic error control can be added as follows:
IF sy-subrc <> 0.
MESSAGE 'Error sending table data' TYPE 'E'.
ENDIF.
SM59
.ZONTA_APAGING
available.