远程主动读取数据 RFC_READ_TABLE
IF IM_UDATE1 <> IM_UDATE2."get data from bw
CLEAR IT_SEL_TAB.
IT_SEL_TAB = '( /BIC/Z01CH0184 >= '''.
IT_SEL_TAB+20(1) = ''''.
IT_SEL_TAB+21(8) = IM_UDATE1.
IT_SEL_TAB+29(1) = ''''.
IT_SEL_TAB+30(24) = ' AND /BIC/Z01CH0184 <= '''.
IT_SEL_TAB+54(8) = IM_UDATE2.
IT_SEL_TAB+62(1) = ''''.
IT_SEL_TAB+63(2) = ' )'.
APPEND IT_SEL_TAB.
ELSE.
CLEAR IT_SEL_TAB.
IT_SEL_TAB = '( /BIC/Z01CH0184 = '''.
IT_SEL_TAB+20(8) = IM_UDATE1.
IT_SEL_TAB+28(1) = ''''.
IT_SEL_TAB+29(2) = ' )'.
APPEND IT_SEL_TAB.
ENDIF.
*--------------------OPTIONS(WHERE)----------------------*
*-------------------get field catalog--------------------*
NAMETAB1-FIELDNAME = '/BIC/Z01CH0165'.
APPEND NAMETAB1.
NAMETAB1-FIELDNAME = '/BIC/Z01CH0173'.
APPEND NAMETAB1.
NAMETAB1-FIELDNAME = '/BIC/Z01CH0174'.
APPEND NAMETAB1.
NAMETAB1-FIELDNAME = '/BIC/Z01CH0175'.
APPEND NAMETAB1.
NAMETAB1-FIELDNAME = '/BIC/Z01CH0183'.
APPEND NAMETAB1.
NAMETAB1-FIELDNAME = '/BIC/Z01CH0184'.
APPEND NAMETAB1.
*-------------------get field catalog--------------------*
*-------------------get data from BW---------------------*
CALL FUNCTION 'RFC_READ_TABLE'
* DESTINATION LS_DESTINATIN
DESTINATION 'BWPCLNT001' "BW SYSTEM
EXPORTING
QUERY_TABLE = '/BIC/AZ01CM00400' "The table from BW system
* DELIMITER = ' '
* NO_DATA = ' '
* ROWSKIPS = 0
* ROWCOUNT = 0
TABLES
OPTIONS = IT_SEL_TAB[]
FIELDS = NAMETAB1[]
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
.
IF SY-SUBRC <> 0.
CASE SY-SUBRC.
WHEN 1.
E_MSGTY = 'E'.
E_ERMSG = 'RFC Error : Internal Error'.
WHEN 2.
E_MSGTY = 'E'.
E_ERMSG = 'RFC Error : No fields in table' .
WHEN 3.
E_MSGTY = 'E'.
E_ERMSG = 'RFC Error : Table is not active'.
WHEN 4.
E_MSGTY = 'E'.
E_ERMSG = 'RFC Error : No authorization' .
WHEN OTHERS.
E_MSGTY = 'E'.
E_ERMSG = 'RFC Error : No records selected'.
ENDCASE.
ENDIF.