Skip to Content
0
Former Member
Jul 12, 2007 at 08:21 AM

Extractor short dumps

125 Views

Our extractor program which fetches the data from R/3 to BW. But the extractor short dumps when we extract large amount of data. Can anyone say where we can optimize our code for better performance.

Extractor code is,

FUNCTION Z_01FBIW_EXTRACTOR .

*"----


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

*" 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 TYPE ZBWFI_FDATA1 OPTIONAL

*" EXCEPTIONS

*" NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

*"----


DATA: Begin of s_bkpf,

mandt like bkpf-mandt,

bukrs like bkpf-bukrs,

belnr like bkpf-belnr,

gjahr like bkpf-gjahr,

blart like bkpf-blart,

bldat like bkpf-bldat,

budat like bkpf-budat,

cpudt like bkpf-cpudt,

monat like bkpf-monat,

xblnr like bkpf-xblnr,

bktxt like bkpf-bktxt,

xref1_hd like bkpf-xref1_hd,

xref2_hd like bkpf-xref2_hd,

wwert like bkpf-wwert,

kursf like bkpf-kursf,

xmwst like bkpf-xmwst,

ldgrp like bkpf-ldgrp,

yke_awsys like bkpf-yke_awsys,

ktopl like t001-ktopl,

End of s_bkpf.

DATA: Begin of s_bseg,

mandt like bseg-mandt,

bukrs like bseg-bukrs,

belnr like bseg-belnr,

gjahr like bseg-gjahr,

buzei like bseg-buzei,

dmbtr like bseg-dmbtr,

wrbtr like bseg-wrbtr,

hkont like bseg-hkont,

lifnr like bseg-lifnr,

kunnr like bseg-kunnr,

zuonr like bseg-zuonr,

sgtxt like bseg-sgtxt,

aufnr like bseg-aufnr,

fkber_long like bseg-fkber_long,

paobjnr like bseg-paobjnr,

projk like bseg-projk,

bewar like bseg-bewar,

vbund like bseg-vbund,

mwskz like bseg-mwskz,

txjcd like bseg-txjcd,

menge like bseg-menge,

matnr like bseg-matnr,

werks like bseg-werks,

zterm like bseg-zterm,

zfbdt like bseg-zfbdt,

zlsch like bseg-zlsch,

zlspr like bseg-zlspr,

uzawe like bseg-uzawe,

qsskz like bseg-qsskz,

kidno like bseg-kidno,

End of s_bseg.

DATA: Begin of s_faglflexa,

rclnt like faglflexa-rclnt,

rbukrs like faglflexa-rbukrs,

docnr like faglflexa-docnr,

ryear like faglflexa-ryear,

rldnr like faglflexa-rldnr,

docln like faglflexa-docln,

buzei like faglflexa-buzei,

usnam like faglflexa-usnam,

rtcur like faglflexa-rtcur,

bschl like faglflexa-bschl,

drcrk like faglflexa-drcrk,

tsl like faglflexa-tsl,

hsl like faglflexa-hsl,

ksl like faglflexa-ksl,

rcntr like faglflexa-rcntr,

prctr like faglflexa-prctr,

RACCT like faglflexa-racct,

kokrs like faglflexa-kokrs,

segment like faglflexa-segment,

pprctr like faglflexa-pprctr,

runit like faglflexa-runit,

End of s_faglflexa.

DATA: Begin of s_bseg_add,

mandt like bseg_add-mandt,

belnr like bseg_add-belnr,

bukrs like bseg_add-bukrs,

gjahr like bseg_add-gjahr,

buzei like bseg_add-buzei,

dmbtr like bseg_add-dmbtr,

wrbtr like bseg_add-wrbtr,

dmbe2 like bseg_add-dmbe2,

zuonr like bseg_add-zuonr,

sgtxt like bseg_add-sgtxt,

aufnr like bseg_add-aufnr,

hkont like bseg_add-hkont,

paobjnr like bseg_add-paobjnr,

projk like bseg_add-projk,

bewar like bseg_add-bewar,

mwskz like bseg_add-mwskz,

txjcd like bseg_add-txjcd,

menge like bseg_add-menge,

matnr like bseg_add-matnr,

werks like bseg_add-werks,

End of s_bseg_add.

DATA: Begin of s_z01trtr_doc_hist,

mandt like z01trtr_doc_hist-mandt,

belnr like z01trtr_doc_hist-belnr,

bukrs like z01trtr_doc_hist-bukrs,

gjahr like z01trtr_doc_hist-gjahr,

leg_sys like z01trtr_doc_hist-leg_sys,

cyc_num like z01trtr_doc_hist-cyc_num,

rep_ind like z01trtr_doc_hist-rep_ind,

rec_typ like z01trtr_doc_hist-rec_typ,

buzei_leg like z01trtr_doc_hist-buzei_leg,

hkont like z01trtr_doc_hist-hkont,

lifnr like z01trtr_doc_hist-lifnr,

kunnr like z01trtr_doc_hist-kunnr,

wrbtr like z01trtr_doc_hist-wrbtr,

dmbtr like z01trtr_doc_hist-dmbtr,

dmbe2 like z01trtr_doc_hist-dmbe2,

zuonr like z01trtr_doc_hist-zuonr,

sgtxt like z01trtr_doc_hist-sgtxt,

aufnr like z01trtr_doc_hist-aufnr,

fkber_long like z01trtr_doc_hist-fkber_long,

paobjnr like z01trtr_doc_hist-paobjnr,

projk like z01trtr_doc_hist-projk,

bewar like z01trtr_doc_hist-bewar,

vbund like z01trtr_doc_hist-vbund,

mwskz like z01trtr_doc_hist-mwskz,

txjcd like z01trtr_doc_hist-txjcd,

menge like z01trtr_doc_hist-menge,

matnr like z01trtr_doc_hist-matnr,

werks like z01trtr_doc_hist-werks,

zterm like z01trtr_doc_hist-zterm,

zfbdt like z01trtr_doc_hist-zfbdt,

zlsch like z01trtr_doc_hist-zlsch,

zlspr like z01trtr_doc_hist-zlspr,

uzawe like z01trtr_doc_hist-uzawe,

qsskz like z01trtr_doc_hist-qsskz,

kidno like z01trtr_doc_hist-kidno,

indust like z01trtr_doc_hist-indust,

poo_tag like z01trtr_doc_hist-poo_tag,

brand like z01trtr_doc_hist-brand,

leg_doc like z01trtr_doc_hist-leg_doc,

ser_off like z01trtr_doc_hist-ser_off,

bus_lin like z01trtr_doc_hist-bus_lin,

pro_str like z01trtr_doc_hist-pro_str,

product like z01trtr_doc_hist-product,

End of s_z01trtr_doc_hist.

DATA: t_bkpf LIKE HASHED TABLE OF s_bkpf WITH UNIQUE KEY BUKRS BELNR GJAHR WITH HEADER LINE,

t_bseg like table of s_bseg with header line,

t_faglflexa like table of s_faglflexa with header line,

T_Z01TRTR_DOC_HIST like TABLE OF s_z01trtr_doc_hist with header line,

t_bseg_add like table of s_bseg_add with header line.

Data : begin of s_t001,

mandt like t001-mandt,

bukrs like t001-bukrs,

ktopl like t001-ktopl,

end of s_t001.

Data : t_t001 like table of s_t001 with header line.

TYPES: BEGIN of i_data.

  • Include structure zcapbisfibwextr.

Include structure z01SBIW.

TYPES: END OF i_data.

DATA: h_tabix LIKE sy-tabix.

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

RANGES: R_BUKRS FOR BKPF-BUKRS,

R_BELNR FOR BKPF-BELNR,

R_GJAHR FOR BKPF-GJAHR,

R_CPUDT FOR BKPF-CPUDT,

R_LDGRP FOR BKPF-LDGRP,

R_YKE_AWSYS FOR BKPF-YKE_AWSYS. " included cpudt in the ranges

IF I_INITFLAG = SBIWA_C_FLAG_ON.

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

  • Initialization: check input parameters

  • buffer input parameters

  • prepare data selection

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

  • Check DataSource validity

  • CASE I_DSOURCE.

  • WHEN 'ZCAPBIDSFIBW_EXTR'.

  • WHEN OTHERS.

  • IF 1 = 2. MESSAGE E009(R3).

  • ENDIF.

  • 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

    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 = 'BUKRS'.

    MOVE-CORRESPONDING L_S_SELECT TO R_BUKRS.

    APPEND R_BUKRS.

    ENDLOOP.

    LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'BELNR'.

    MOVE-CORRESPONDING L_S_SELECT TO R_BELNR.

    APPEND R_BELNR.

    ENDLOOP.

    LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'GJAHR'.

    MOVE-CORRESPONDING L_S_SELECT TO R_GJAHR.

    APPEND R_GJAHR.

    ENDLOOP.

    LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CPUDT'. " Fill range table added for feild CPUDT

    MOVE-CORRESPONDING L_S_SELECT TO R_CPUDT.

    APPEND R_CPUDT.

    ENDLOOP.

    LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'LDGRP'.

    MOVE-CORRESPONDING L_S_SELECT TO R_LDGRP.

    APPEND R_LDGRP.

    ENDLOOP.

    LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'YKE_AWSYS'.

    MOVE-CORRESPONDING L_S_SELECT TO R_YKE_AWSYS.

    APPEND R_YKE_AWSYS.

    ENDLOOP.

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

    • from input parameter I_MAXSIZE.

    OPEN CURSOR WITH HOLD S_CURSOR FOR

    SELECT mandt bukrs belnr gjahr blart bldat budat cpudt monat xblnr bktxt xref1_hd xref2_hd wwert kursf xmwst ldgrp yke_awsys

    FROM BKPF WHERE BUKRS IN R_BUKRS AND BELNR IN R_BELNR AND GJAHR IN R_GJAHR AND CPUDT IN R_CPUDT AND LDGRP IN R_LDGRP

    AND YKE_AWSYS IN R_YKE_AWSYS.

    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 T_BKPF

    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

    Sort t_bkpf by mandt bukrs belnr gjahr. " Sorted based on the primary keys of table BKPF

    CHECK NOT t_bkpf[] IS INITIAL.

    Select mandt bukrs ktopl from t001 into table t_t001.

    FREE t_faglflexa.

    SELECT rclnt rbukrs docnr ryear rldnr docln buzei

    usnam rtcur bschl drcrk tsl hsl

    ksl rcntr prctr racct kokrs segment pprctr runit

    FROM faglflexa INTO TABLE t_faglflexa FOR ALL ENTRIES IN t_bkpf

    WHERE ryear = t_bkpf-gjahr

    AND docnr = t_bkpf-belnr

    AND rbukrs = t_bkpf-bukrs.

    IF sy-subrc IS INITIAL.

    SORT t_faglflexa BY ryear docnr rbukrs rldnr.

    ENDIF.

    FREE t_bseg.

    SELECT mandt bukrs belnr gjahr buzei dmbtr

    wrbtr hkont lifnr kunnr zuonr sgtxt

    aufnr fkber_long paobjnr projk bewar vbund

    mwskz txjcd menge matnr werks zterm

    zfbdt zlsch zlspr uzawe qsskz kidno

    FROM bseg INTO TABLE t_bseg FOR ALL ENTRIES IN t_bkpf

    WHERE bukrs = t_bkpf-bukrs

    AND belnr = t_bkpf-belnr

    and gjahr = t_bkpf-gjahr.

    IF sy-subrc IS INITIAL.

    SORT t_bseg BY bukrs belnr gjahr buzei.

    ENDIF.

    FREE t_bseg_add.

    SELECT mandt belnr bukrs gjahr buzei dmbtr

    wrbtr dmbe2 zuonr sgtxt aufnr hkont

    paobjnr projk bewar mwskz txjcd menge

    matnr werks

    FROM bseg_add INTO TABLE t_bseg_add FOR ALL ENTRIES IN t_bkpf

    WHERE bukrs = t_bkpf-bukrs

    AND belnr = t_bkpf-belnr

    AND gjahr = t_bkpf-gjahr.

    IF sy-subrc IS INITIAL.

    SORT t_bseg_add BY mandt bukrs belnr gjahr buzei.

    ENDIF.

    FREE t_z01trtr_doc_hist.

    SELECT mandt belnr bukrs gjahr leg_sys cyc_num rep_ind rec_typ buzei_leg hkont

    lifnr kunnr wrbtr dmbtr dmbe2 zuonr sgtxt aufnr fkber_long paobjnr

    projk bewar vbund mwskz txjcd menge matnr werks zterm zfbdt

    zlsch zlspr uzawe qsskz kidno indust poo_tag brand leg_doc ser_off

    bus_lin pro_str product

    FROM z01trtr_doc_hist INTO TABLE t_z01trtr_doc_hist FOR ALL ENTRIES IN t_bkpf

    WHERE bukrs = t_bkpf-bukrs

    AND belnr = t_bkpf-belnr

    AND gjahr = t_bkpf-gjahr.

    IF sy-subrc IS INITIAL.

    SORT t_z01trtr_doc_hist BY bukrs belnr gjahr.

    ENDIF.

    DATA: l_index TYPE sytabix.

    LOOP AT t_bkpf.

    READ TABLE t_t001 WITH KEY MANDT = t_bkpf-mandt

    BUKRS = t_bkpf-bukrs.

    IF sy-subrc = 0.

    t_bkpf-ktopl = t_t001-ktopl.

    ENDIF.

    IF ( t_bkpf-ldgrp = '0L' AND t_bkpf-yke_awsys <> ' ' OR " Change of condition

    t_bkpf-ldgrp = ' ' AND t_bkpf-yke_awsys <> ' ' ).

    READ TABLE t_faglflexa BINARY SEARCH WITH KEY ryear = t_bkpf-gjahr

    docnr = t_bkpf-belnr

    rbukrs = t_bkpf-bukrs.

    IF sy-subrc IS INITIAL.

    l_index = sy-tabix.

    LOOP AT t_faglflexa FROM l_index.

    IF t_faglflexa-ryear <> t_bkpf-gjahr

    OR t_faglflexa-docnr <> t_bkpf-belnr

    OR t_faglflexa-rbukrs <> t_bkpf-bukrs.

    EXIT.

    ENDIF.

    CLEAR e_t_data.

    MOVE-CORRESPONDING t_faglflexa TO e_t_data.

    MOVE-CORRESPONDING t_bkpf TO e_t_data.

    APPEND e_t_data.

    ENDLOOP.

    ENDIF.

    READ TABLE t_z01trtr_doc_hist BINARY SEARCH WITH KEY bukrs = t_bkpf-bukrs

    belnr = t_bkpf-belnr

    gjahr = t_bkpf-gjahr.

    IF sy-subrc IS INITIAL.

    l_index = sy-tabix.

    LOOP AT t_z01trtr_doc_hist FROM l_index.

    IF t_z01trtr_doc_hist-bukrs <> t_bkpf-bukrs

    OR t_z01trtr_doc_hist-belnr <> t_bkpf-belnr

    OR t_z01trtr_doc_hist-gjahr <> t_bkpf-gjahr.

    EXIT.

    ENDIF.

    CLEAR e_t_data.

    MOVE-CORRESPONDING t_z01trtr_doc_hist TO e_t_data.

    MOVE-CORRESPONDING t_bkpf TO e_t_data.

    APPEND e_t_data.

    ENDLOOP.

    ENDIF.

    ELSEIF ( t_bkpf-ldgrp = '0L' AND t_bkpf-yke_awsys = ' ' ) OR

    ( t_bkpf-ldgrp = ' ' AND t_bkpf-yke_awsys = ' ' ).

    READ TABLE t_bseg BINARY SEARCH WITH KEY bukrs = t_bkpf-bukrs

    belnr = t_bkpf-belnr

    gjahr = t_bkpf-gjahr.

    IF sy-subrc IS INITIAL.

    l_index = sy-tabix.

    LOOP AT t_bseg FROM l_index.

    IF t_bseg-bukrs <> t_bkpf-bukrs

    OR t_bseg-belnr <> t_bkpf-belnr

    OR t_bseg-gjahr <> t_bkpf-gjahr.

    EXIT.

    ENDIF.

    CLEAR e_t_data.

    MOVE-CORRESPONDING t_bseg TO e_t_data.

    MOVE-CORRESPONDING t_bkpf TO e_t_data.

    APPEND e_t_data.

    ENDLOOP.

    ENDIF.

    READ TABLE t_faglflexa BINARY SEARCH WITH KEY ryear = t_bkpf-gjahr

    docnr = t_bkpf-belnr

    rbukrs = t_bkpf-bukrs.

    IF sy-subrc IS INITIAL.

    l_index = sy-tabix.

    LOOP AT t_faglflexa FROM l_index.

    IF t_faglflexa-ryear <> t_bkpf-gjahr

    OR t_faglflexa-docnr <> t_bkpf-belnr

    OR t_faglflexa-rbukrs <> t_bkpf-bukrs.

    EXIT.

    ENDIF.

    CLEAR e_t_data.

    MOVE-CORRESPONDING t_faglflexa TO e_t_data.

    MOVE-CORRESPONDING t_bkpf TO e_t_data.

    APPEND e_t_data.

    ENDLOOP.

    ENDIF.

    ELSEIF t_bkpf-yke_awsys = ' '.

    READ TABLE t_bseg_add BINARY SEARCH WITH KEY bukrs = t_bkpf-bukrs

    belnr = t_bkpf-belnr

    gjahr = t_bkpf-gjahr.

    IF sy-subrc IS INITIAL.

    l_index = sy-tabix.

    LOOP AT t_bseg_add FROM l_index.

    IF t_bseg_add-bukrs <> t_bkpf-bukrs

    OR t_bseg_add-belnr <> t_bkpf-belnr

    OR t_bseg_add-gjahr <> t_bkpf-gjahr.

    EXIT.

    ENDIF.

    CLEAR e_t_data.

    MOVE-CORRESPONDING t_bseg_add TO e_t_data.

    MOVE-CORRESPONDING t_bkpf TO e_t_data.

    APPEND e_t_data.

    ENDLOOP.

    ENDIF.

    READ TABLE t_faglflexa BINARY SEARCH WITH KEY ryear = t_bkpf-gjahr

    docnr = t_bkpf-belnr

    rbukrs = t_bkpf-bukrs.

    IF sy-subrc IS INITIAL.

    l_index = sy-tabix.

    LOOP AT t_faglflexa FROM l_index.

    IF t_faglflexa-ryear <> t_bkpf-gjahr

    OR t_faglflexa-docnr <> t_bkpf-belnr

    OR t_faglflexa-rbukrs <> t_bkpf-bukrs.

    EXIT.

    ENDIF.

    CLEAR e_t_data.

    MOVE-CORRESPONDING t_faglflexa TO e_t_data.

    MOVE-CORRESPONDING t_bkpf TO e_t_data.

    APPEND e_t_data.

    ENDLOOP.

    ENDIF.

    ELSE.

    READ TABLE t_faglflexa BINARY SEARCH WITH KEY ryear = t_bkpf-gjahr

    docnr = t_bkpf-belnr

    rbukrs = t_bkpf-bukrs.

    IF sy-subrc IS INITIAL.

    l_index = sy-tabix.

    LOOP AT t_faglflexa FROM l_index.

    IF t_faglflexa-ryear <> t_bkpf-gjahr

    OR t_faglflexa-docnr <> t_bkpf-belnr

    OR t_faglflexa-rbukrs <> t_bkpf-bukrs.

    EXIT.

    ENDIF.

    CLEAR e_t_data.

    MOVE-CORRESPONDING t_faglflexa TO e_t_data.

    MOVE-CORRESPONDING t_bkpf TO e_t_data.

    APPEND e_t_data.

    ENDLOOP.

    ENDIF.

    READ TABLE t_z01trtr_doc_hist BINARY SEARCH WITH KEY bukrs = t_bkpf-bukrs

    belnr = t_bkpf-belnr

    gjahr = t_bkpf-gjahr.

    IF sy-subrc IS INITIAL.

    l_index = sy-tabix.

    LOOP AT t_z01trtr_doc_hist FROM l_index.

    IF t_z01trtr_doc_hist-bukrs <> t_bkpf-bukrs

    OR t_z01trtr_doc_hist-belnr <> t_bkpf-belnr

    OR t_z01trtr_doc_hist-gjahr <> t_bkpf-gjahr.

    EXIT.

    ENDIF.

    CLEAR e_t_data.

    MOVE-CORRESPONDING t_z01trtr_doc_hist TO e_t_data.

    MOVE-CORRESPONDING t_bkpf TO e_t_data.

    APPEND e_t_data.

    ENDLOOP.

    ENDIF.

    ENDIF.

    ENDLOOP.

    Free T_bkpf.

    Free T_bseg.

    Free T_Bseg_add.

    Free T_faglflexa.

    Free t_z01trtr_doc_hist.

    ENDFUNCTION.