How to read table from remote SAP system - reading HU from SAP EWM from SAP ECC
Sample code to read HU number VLENR from table /SCWM/ORDIM_C in SAP EWM from another SAP.
DATA: T_OPTIONS TYPE TABLE OF RFC_DB_OPT WITH HEADER LINE.
DATA: T_FIELDS TYPE TABLE OF RFC_DB_FLD WITH HEADER LINE.
DATA: T_DATA TYPE TABLE OF TAB512 WITH HEADER LINE.
* Connection to EWM in order to read table /SCWM/ORDIM_C
CALL FUNCTION 'RFC_READ_TABLE'
DESTINATION P_DEST
EXPORTING
QUERY_TABLE = '/SCWM/ORDIM_C'
* DELIMITER = ' '
* NO_DATA = ' '
* ROWSKIPS = 0
ROWCOUNT = 999
TABLES
OPTIONS = T_OPTIONS
FIELDS = T_FIELDS
DATA = T_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
.
IF SY-SUBRC = 0.
P_DEST = 'RFC name of the EWM system'.
* Field we are going to read
T_FIELD-fieldname = 'VLENR'.
append T_FIELD TO T_FIELDS.
T_FIELD-fieldname = 'VLENR'.
append T_FIELD TO T_FIELDS.
* Filter over warehouse task field
CONCATENATE 'TANUM = 100012344'.
append T_OPTIONS TO T_OPTIONS.
CONCATENATE 'TANUM = 100012344'.
append T_OPTIONS TO T_OPTIONS.
* Connection to EWM in order to read table /SCWM/ORDIM_C
CALL FUNCTION 'RFC_READ_TABLE'
DESTINATION P_DEST
EXPORTING
QUERY_TABLE = '/SCWM/ORDIM_C'
* DELIMITER = ' '
* NO_DATA = ' '
* ROWSKIPS = 0
ROWCOUNT = 999
TABLES
OPTIONS = T_OPTIONS
FIELDS = T_FIELDS
DATA = T_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
.
IF SY-SUBRC = 0.
* result to be retrieved from T_DATA
ENDIF.
No comments:
Post a Comment