【应用场景】BW模块定时增量抽取SAP的销售案场收款单的业务主数据
【关键语法】
FUNCTION ZBWFM_ZTSD0011 .
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZBWST_ZTSD0011 OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------
RANGES: r_zdelta FOR zbwst_ztsd0011-zdelta, "增量字段-创建时间
r_id FOR zbwst_ztsd0011-id, "编码
r_pzgs FOR zbwst_ztsd0011-pzgs. "公司代码
DATA: lt_ztsd0011 TYPE TABLE OF zbwst_ztsd0011.
DATA: l_s_select TYPE srsc_s_select.
STATICS: s_s_if TYPE srsc_s_if_simple,
s_cursor TYPE cursor,
s_counter_datapakid TYPE i.
CLEAR l_s_select.
IF i_initflag = sbiwa_c_flag_on.
APPEND LINES OF i_t_select TO s_s_if-t_select.
s_s_if-requnr = i_requnr.
s_s_if-dsource = i_dsource.
s_s_if-maxsize = i_maxsize.
APPEND LINES OF i_t_fields TO s_s_if-t_fields.
ELSE. "
IF s_counter_datapakid = 0.
LOOP AT i_t_select INTO l_s_select.
CASE l_s_select-fieldnm.
WHEN 'ZDELTA'.
MOVE-CORRESPONDING l_s_select TO r_zdelta.
APPEND r_zdelta.
CLEAR r_zdelta.
WHEN 'ID'.
MOVE-CORRESPONDING l_s_select TO r_id.
APPEND r_id.
CLEAR r_id.
WHEN 'PZGS'.
MOVE-CORRESPONDING l_s_select TO r_pzgs .
APPEND r_pzgs.
CLEAR r_pzgs .
ENDCASE.
ENDLOOP.
OPEN CURSOR WITH HOLD s_cursor FOR
SELECT *
FROM ztsd0011
WHERE ( ( timestamp IN r_zdelta ) OR ( timestamp_upd IN r_zdelta ) )
AND id IN r_id
AND pzgs IN r_pzgs.
ENDIF.
FETCH NEXT CURSOR s_cursor
APPENDING CORRESPONDING FIELDS
OF TABLE lt_ztsd0011
PACKAGE SIZE s_s_if-maxsize.
IF sy-subrc <> 0.
CLOSE CURSOR s_cursor.
RAISE no_more_data.
ENDIF.
LOOP AT lt_ztsd0011 INTO e_t_data.
APPEND e_t_data.
CLEAR e_t_data.
ENDLOOP.
s_counter_datapakid = s_counter_datapakid + 1.
ENDIF.
ENDFUNCTION.