Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Unable to get delta observation,

i am trying get delta records from ztable based on time stamp with 900sec lower timestamp,,,,,,,,,,

please correct my code,

  • Example: DataSource for table SFLIGHT

TABLES: zsales_order1.

  • Auxiliary Selection criteria structure

DATA: l_s_select TYPE srsc_s_select.

  • Maximum number of lines for DB table

STATICS: s_s_if TYPE srsc_s_if_simple,

  • counter

s_counter_datapakid LIKE sy-tabix,

  • cursor

s_cursor TYPE cursor.

  • Select ranges

RANGES: l_r_zvbeln FOR zsales_order1-zvbeln,

l_r_zerdat FOR zsales_order1-zerdat,

l_r_zerzet FOR zsales_order1-zerzet,

l_r_ztimestamp FOR zsales_order1-ztimestamp.

DATA : startdate TYPE sy-datum,

starttime TYPE sy-uzeit,

enddate TYPE sy-datum,

endtime TYPE sy-uzeit,

timestamp TYPE tzonref-tstamps.

  • Initialization mode (first call by SAPI) or data transfer mode

  • (following calls) ?

IF i_initflag = sbiwa_c_flag_on.

************************************************************************

  • Initialization: check input parameters

  • buffer input parameters

  • prepare data selection

************************************************************************

  • Check DataSource validity

CASE i_dsource.

WHEN 'ZSALES_ORDER_FUN1'.

WHEN OTHERS.

IF 1 = 2.

MESSAGE e009(r3).

ENDIF.

  • this is a typical log call. Please write every error message like this

log_write 'E' "message type

'R3' "message class

'009' "message number

i_dsource "message variable 1

' '. "message variable 2

RAISE error_passed_to_mess_handler.

ENDCASE.

APPEND LINES OF i_t_select TO s_s_if-t_select.

  • Fill parameter buffer for data extraction calls

s_s_if-requnr = i_requnr.

s_s_if-dsource = i_dsource.

s_s_if-maxsize = i_maxsize.

  • Fill field list table for an optimized select statement

  • (in case that there is no 1:1 relation between InfoSource fields

  • and database table fields this may be far from beeing trivial)

APPEND LINES OF i_t_fields TO s_s_if-t_fields.

ELSE. "Initialization mode or data extraction ?

************************************************************************

  • Data transfer: First Call OPEN CURSOR + FETCH

  • Following Calls FETCH only

************************************************************************

  • First data package -> OPEN CURSOR

IF s_counter_datapakid = 0.

  • Fill range tables BW will only pass down simple selection criteria

  • of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'ZVBELN'.

MOVE-CORRESPONDING l_s_select TO l_r_zvbeln.

APPEND l_r_zvbeln.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'ZERDAT'.

MOVE-CORRESPONDING l_s_select TO l_r_zerdat.

APPEND l_r_zerdat.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'ZERZET'.

MOVE-CORRESPONDING l_s_select TO l_r_zerzet.

APPEND l_r_zerzet.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'ZTIMESTAMP'.

timestamp = l_s_select-low.

CONVERT TIME STAMP timestamp

TIME ZONE sy-zonlo INTO DATE startdate TIME starttime.

timestamp = l_s_select-high.

CONVERT TIME STAMP timestamp

TIME ZONE sy-zonlo INTO DATE enddate TIME endtime.

l_r_zerdat-low = startdate.

l_r_zerdat-sign = l_s_select-sign.

l_r_zerdat-option = l_s_select-option.

l_r_zerdat-high = enddate.

APPEND l_r_zerdat.

l_r_zerzet-low = starttime.

l_r_zerzet-sign = l_s_select-sign.

l_r_zerzet-option = l_s_select-option.

l_r_zerzet-high = endtime.

APPEND l_r_zerzet.

ENDLOOP.

ENDLOOP.

ENDLOOP.

ENDLOOP.

  • Determine number of database records to be read per FETCH statement

  • from input parameter I_MAXSIZE. If there is a one to one relation

  • between DataSource table lines and database entries, this is trivial.

  • In other cases, it may be impossible and some estimated value has to

  • be determined.

OPEN CURSOR WITH HOLD s_cursor FOR

SELECT zvbeln

zerdat

zerzet

zland1

zkunnr

zlgort

zposnv

zmatnr

znetpr

waerk

zkpein

zkmein

zarktx

zstadat

zaedat

zaezet

ztimestamp FROM zsales_order1 WHERE zvbeln IN l_r_zvbeln

AND zerdat IN l_r_zerdat

AND zerzet IN l_r_zerzet

AND (

( zerdat >= startdate AND ( zerzet >= starttime OR

( zerdat <= enddate AND zerzet <= endtime ) ) ) OR

( zaedat >= startdate AND ( zaezet >= starttime OR

( zaedat <= enddate AND zaezet <= endtime ) ) )

).

ENDIF. "First data package ?

  • Fetch records into interface table.

  • named E_T_'Name of extract structure'.

FETCH NEXT CURSOR s_cursor

APPENDING CORRESPONDING FIELDS

OF TABLE e_t_data

PACKAGE SIZE s_s_if-maxsize.

IF sy-subrc <> 0.

CLOSE CURSOR s_cursor.

RAISE no_more_data.

ENDIF.

s_counter_datapakid = s_counter_datapakid + 1.

ENDIF. "Initialization mode or data extraction ?

ENDFUNCTION.

thanks in advance

Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question