源代码如下:
FUNCTION zfm_bw_cdpos.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(I_ISOURCE) TYPE SBIWA_S_INTERFACE-ISOURCE OPTIONAL
*" VALUE(I_REQUNR) TYPE SBIWA_S_INTERFACE-REQUNR
*" VALUE(I_MAXSIZE) TYPE SBIWA_S_INTERFACE-MAXSIZE DEFAULT 1000
*" VALUE(I_INITFLAG) TYPE SBIWA_S_INTERFACE-INITFLAG OPTIONAL
*" VALUE(I_UPDMODE) TYPE SBIWA_S_INTERFACE-UPDMODE OPTIONAL
*" VALUE(I_DATAPAKID) TYPE SBIWA_S_INTERFACE-DATAPAKID DEFAULT
*" 50000
*" VALUE(I_READ_ONLY) TYPE SBIW_BOOL DEFAULT SBIW_C_FALSE
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG OPTIONAL
*" VALUE(I_RLOGSYS) TYPE RSAOT_LOGSYS OPTIONAL
*" TABLES
*" I_T_SELECT TYPE SBIWA_T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SBIWA_T_FIELDS OPTIONAL
*" E_T_DATA OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------
STATICS : updmode TYPE rsupdmode,
s_cursor TYPE cursor,
l_maxsize TYPE sbiwa_s_interface-maxsize.
DATA : startdate TYPE d,
enddate TYPE d.
* definite the selection structure
DATA : wa_select_ts TYPE sbiwa_s_select,
wa_select TYPE sbiwa_s_select,
r_udate LIKE RANGE OF cdhdr-udate,
wa_udate LIKE LINE OF r_udate.
DATA : lw_extractor TYPE zsbw_cdpos,
lt_extractor TYPE TABLE OF zsbw_cdpos,
lw_cdhdr LIKE cdhdr,
lt_cdhdr LIKE TABLE OF cdhdr,
lw_cdpos LIKE cdpos,
lt_cdpos LIKE TABLE OF cdpos,
lw_ekko TYPE ekko,
lt_ekko LIKE TABLE OF ekko,
g_index TYPE i.
CLEAR : e_t_data,lt_extractor.
IF i_initflag = 'X'.
* if it is the first time to extract
l_maxsize = i_maxsize.
READ TABLE i_t_select INTO wa_select_ts WITH KEY fieldnm = 'UDATE'.
IF wa_select_ts IS NOT INITIAL.
IF wa_select_ts-low IS INITIAL.
updmode = 'C'."initialization
startdate = '20100101'.
ELSE.
updmode = 'D'.
startdate = wa_select_ts-low.
ENDIF.
enddate = wa_select_ts-high.
wa_udate-low = startdate."wa_select_ts-low.
wa_udate-sign = wa_select_ts-sign.
wa_udate-option = wa_select_ts-option.
wa_udate-high = enddate."wa_select_ts-high.
APPEND wa_udate TO r_udate.
ELSE.
updmode = 'F'. " full mode
ENDIF.
* now wo prepare to open the cursor for target table
* according to the extraction mode
* initial and full we get data from the a645 konp konh
* delta ---> we get data from cdhdr and cdpos
OPEN CURSOR WITH HOLD s_cursor FOR
SELECT *
FROM cdhdr
WHERE objectclas EQ 'EINKBELEG'
AND udate IN r_udate
ORDER BY udate utime.
* CASE updmode.
* WHEN 'F' OR 'C'.
* OPEN CURSOR WITH HOLD s_cursor FOR
* SELECT *
* FROM cdpos
* FOR ALL ENTRIES IN lt_cdhdr
* WHERE objectclas EQ lt_cdhdr-objectclas
* AND objectid EQ lt_cdhdr-objectid
* AND changenr EQ lt_cdhdr-changenr
* AND tabname = 'EKKO'
* AND fname = 'FRGKE'
* AND ( value_new = 'Y' OR value_old = 'Y' ).
* WHEN 'D'."delta mode
* WHEN OTHERS.
* ENDCASE.
RETURN.
ELSE.
* fill the data to e_t_data
FETCH NEXT CURSOR s_cursor INTO TABLE
lt_cdhdr PACKAGE SIZE l_maxsize.
IF sy-subrc <> 0.
CLOSE CURSOR s_cursor.
RAISE no_more_data.
ENDIF.
IF lt_cdhdr[] IS NOT INITIAL .
SORT lt_cdhdr[].
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_cdpos
FROM cdpos
FOR ALL ENTRIES IN lt_cdhdr
WHERE objectclas EQ lt_cdhdr-objectclas
AND objectid EQ lt_cdhdr-objectid
AND changenr EQ lt_cdhdr-changenr
AND tabname IN ('EKKO',