本文主要是介绍ABAP CURSOR游标的应用1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【应用场景】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 FORSELECT *FROM ztsd0011WHERE ( ( timestamp IN r_zdelta ) OR ( timestamp_upd IN r_zdelta ) )AND id IN r_idAND pzgs IN r_pzgs.ENDIF.FETCH NEXT CURSOR s_cursorAPPENDING CORRESPONDING FIELDSOF TABLE lt_ztsd0011PACKAGE 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.
这篇关于ABAP CURSOR游标的应用1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!