2 Replies Latest reply: May 21, 2007 3:20 PM by Pawan Sharma RSS

Delta Extraction Using Function Module

GK S
Currently Being Moderated

Dear All,

 

I have created a generic datasource using Custom Function Module, I have selected Posting Date as Generic Delta extraction field with timestamp.

 

I have intialized in bw it has retreived 4 records, next time when I give delta update it is retreiving 4 records again instead of retreving 0 records. Is there any code needs to write in the FM to retreive only new records. Pls give your suggestion to retrieve only latest records.

 

Best Regards,

SGK.

  • Re: Delta Extraction Using Function Module
    hareesh adapala
    Currently Being Moderated

    Hi,

    Check with the following:

     

    Creation of custom datasource. (Using function module)

     

    1. Create a function group .

     

    2. Create a structure with required fields like as below:

     

    Structure ZTEST123

     

    ZMATNR MATNR CHAR 18 0 Material Number

    ZMTART MTART CHAR 4 0 Material type

    ZMBRSH MBRSH CHAR 1 0 Industry sector

    ZMATKL MATKL CHAR 9 0 Material group

    ZBISMT BISMT CHAR 18 0 Old material number

    ZMAKTX MAKTX CHAR 40 0 Material description

     

    3. Create function module (i.e. ZTEST….) .

    FM - YMARA_DATA_TRNS

     

    FUNCTION YMARA_DATA_TRNS.

    *"----


    ""Local Interface:

    *" 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

    *" 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 ZTEST123 OPTIONAL

    *" EXCEPTIONS

    *" NO_MORE_DATA

    *" ERROR_PASSED_TO_MESS_HANDLER

    *"----


     

    data : ZTEST123 type ZTEST123 occurs 0 with header line.

     

    • Maximum number of lines for DB table

    STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,

    S_COUNTER_DATAPAKID LIKE SY-TABIX.

     

     

    DATA: begin of t_mara occurs 0,

    ZMATNR type MATNR,

    ZMTART type MTART,

    ZMBRSH type MBRSH,

    ZMATKL type MATKL,

    ZBISMT type BISMT,

    end of t_mara.

     

     

    DATA: begin of t_makt occurs 0,

    ZMATNR type MATNR,

    ZMAKTX type MAKTX,

    end of t_makt.

     

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

    • (following calls) ?

    IF I_INITFLAG = SBIWA_C_FLAG_ON.

     

     

    • Check DataSource validity

    CASE I_DSOURCE.

    WHEN 'ZZMARA_DATA'.

     

    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.

     

    • 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.

     

     

    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.

     

    • 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.

     

    select MATNR

    MTART

    MBRSH

    MATKL

    BISMT

    from mara up to 10 rows

    into table t_mara.

     

    if not t_mara[] is initial.

    select MATNR

    maktx

    from makt

    into table t_makt

    for all entries in t_mara

    where matnr = t_mara-zmatnr.

     

    endif.

     

    loop at t_mara.

    read table t_makt with key zmatnr = t_mara-zmatnr.

    ZTEST123-zmatnr = t_mara-zmatnr.

    ZTEST123-ZMTART = t_mara-ZMTART.

    ZTEST123-ZBISMT = t_mara-ZBISMT.

    ZTEST123-ZMBRSH = t_mara-ZMBRSH.

    ZTEST123-ZMATKL = t_mara-ZMATKL.

    ZTEST123-zmaktx = t_makt-zmaktx.

     

    append ZTEST123.

    clear ZTEST123.

    endloop.

     

    clear E_T_DATA.

    refresh E_T_DATA.

    E_T_DATA[] = ZTEST123[].

     

    ENDIF.

     

    S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.

     

    ENDIF. "Initialization mode or data extractio

     

    ENDFUNCTION.

     

    3. Create the data source using transaction (RSO2) as option using function module .

    4. To make Generic Delta add a date field and in generic delta check the data field to enbale it as a delta extractor.

    5. If structure exists for the table parameter of your function module then ok else create a structure for the table parameter ‘E_T_DATA’.

    6. Test the datasource in R/3 using transaction RSA3.

    7. Transfer the data source to BW –System and replicate it in the BW-System

     

     

    Hareesh

  • Re: Delta Extraction Using Function Module
    Pawan Sharma
    Currently Being Moderated

    Hi SGK,

     

    you can use the FM "RSVD_BW_GET_DELTA_DATA" which is an example for delta FM .

    Also there are many threads on Delta extraction FM please check them....

     

    Regards,

    Pawan.

Actions