Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Cursors..

Former Member
0 Likes
444

Hi,

Please help me why this code is taking too much time ...

Output of select quesry is only 10 lakhs data..

IF NOT s_matnr IS INITIAL.

OPEN CURSOR dbcur1 FOR

SELECT a~matnr

b~b_werk

b~b_lager

a~equnr

b~b_charge

b~lbbsa

FROM equi AS a INNER JOIN eqbs AS b

ON aequnr = bequnr

WHERE a~matnr IN s_matnr

AND b~b_werk IN s_werks

AND b~lbbsa IN ('01','07').

IF sy-subrc EQ 0.

count = count + 1.

MESSAGE s001 WITH 'Data fetched from EQBS,EQUI count' count.

ELSE.

MESSAGE e001 WITH 'Failed to fectch the Data from EQBS,EQUI'.

ENDIF.

DO.

FETCH NEXT CURSOR dbcur1

INTO TABLE it_esn1 PACKAGE SIZE 50000.

IF sy-subrc <> 0.

EXIT.

ENDIF.

SELECT matnr maktx

APPENDING TABLE it_makt

FROM makt

FOR ALL ENTRIES IN it_esn1

WHERE matnr = it_esn1-matnr.

IF sy-subrc EQ 0.

MESSAGE s001 WITH 'Data fetched from MAKT count' count.

ELSE.

MESSAGE e001 WITH 'Failed to fectch the Data from MAKT'.

ENDIF.

SELECT amblnr amjahr bequnr adatum

INTO TABLE it_sernr1

FROM ser03 AS a INNER JOIN objk AS b

ON aobknr = bobknr

FOR ALL ENTRIES IN it_esn1

WHERE a~werk = it_esn1-b_werk AND

a~lagerort = it_esn1-b_lager AND

a~charge = it_esn1-b_charge AND

b~sernr = it_esn1-equnr.

IF NOT it_sernr1[] IS INITIAL.

APPEND LINES OF it_sernr1 TO it_sernr.

CLEAR it_sernr1.

ENDIF.

APPEND LINES OF it_esn1 TO it_esn.

CLEAR it_esn1.

ENDDO.

CLOSE CURSOR dbcur1.

SORT it_makt BY matnr ASCENDING.

SORT it_sernr BY equnr ASCENDING.

LOOP AT it_esn INTO wa_esn WHERE lbbsa = '01' OR lbbsa = '07'.

READ TABLE it_makt INTO wa_makt WITH TABLE KEY matnr = wa_esn-matnr.

IF sy-subrc EQ 0.

wa_niu-maktx = wa_makt-maktx.

CLEAR: wa_makt.

ENDIF.

wa_niu-serial_no = wa_esn-equnr.

wa_niu-matnr = wa_esn-matnr.

wa_niu-bwtar = wa_esn-b_charge.

wa_niu-plant = wa_esn-b_werk.

wa_niu-storage_loc = wa_esn-b_lager.

wa_niu-stock_type = wa_esn-lbbsa.

wa_niu-pr_run_date = s_date.

wa_niu-s_date = sy-datum.

READ TABLE it_sernr INTO wa_sernr WITH KEY equnr = wa_esn-equnr.

IF sy-subrc EQ 0.

wa_niu-mblnr = wa_sernr-mblnr.

wa_niu-mjahr = wa_sernr-mjahr.

wa_niu-doc_date = wa_sernr-datum.

ENDIF.

APPEND wa_niu TO it_niu.

CLEAR: wa_niu,wa_esn,wa_sernr,wa_stock.

ENDLOOP.

MODIFY zniu_owner_stock FROM TABLE it_niu.

IF sy-subrc EQ 0.

MESSAGE s000 WITH 'Table UP-Dated count' count.

CLEAR: it_niu.

ELSE.

MESSAGE e000 WITH 'Table Not UP-Dated'.

CLEAR it_niu.

ENDIF.

REFRESH : it_esn.

  • ENDSELECT.

ENDIF.

Hi,

Please help me why this code is taking too much time ...

Output of select quesry is only 10 lakhs data..

IF NOT s_matnr IS INITIAL.

OPEN CURSOR dbcur1 FOR

SELECT a~matnr

b~b_werk

b~b_lager

a~equnr

b~b_charge

b~lbbsa

FROM equi AS a INNER JOIN eqbs AS b

ON aequnr = bequnr

WHERE a~matnr IN s_matnr

AND b~b_werk IN s_werks

AND b~lbbsa IN ('01','07').

IF sy-subrc EQ 0.

count = count + 1.

MESSAGE s001 WITH 'Data fetched from EQBS,EQUI count' count.

ELSE.

MESSAGE e001 WITH 'Failed to fectch the Data from EQBS,EQUI'.

ENDIF.

DO.

FETCH NEXT CURSOR dbcur1

INTO TABLE it_esn1 PACKAGE SIZE 50000.

IF sy-subrc <> 0.

EXIT.

ENDIF.

SELECT matnr maktx

APPENDING TABLE it_makt

FROM makt

FOR ALL ENTRIES IN it_esn1

WHERE matnr = it_esn1-matnr.

IF sy-subrc EQ 0.

MESSAGE s001 WITH 'Data fetched from MAKT count' count.

ELSE.

MESSAGE e001 WITH 'Failed to fectch the Data from MAKT'.

ENDIF.

SELECT amblnr amjahr bequnr adatum

INTO TABLE it_sernr1

FROM ser03 AS a INNER JOIN objk AS b

ON aobknr = bobknr

FOR ALL ENTRIES IN it_esn1

WHERE a~werk = it_esn1-b_werk AND

a~lagerort = it_esn1-b_lager AND

a~charge = it_esn1-b_charge AND

b~sernr = it_esn1-equnr.

IF NOT it_sernr1[] IS INITIAL.

APPEND LINES OF it_sernr1 TO it_sernr.

CLEAR it_sernr1.

ENDIF.

APPEND LINES OF it_esn1 TO it_esn.

CLEAR it_esn1.

ENDDO.

CLOSE CURSOR dbcur1.

SORT it_makt BY matnr ASCENDING.

SORT it_sernr BY equnr ASCENDING.

LOOP AT it_esn INTO wa_esn WHERE lbbsa = '01' OR lbbsa = '07'.

READ TABLE it_makt INTO wa_makt WITH TABLE KEY matnr = wa_esn-matnr.

IF sy-subrc EQ 0.

wa_niu-maktx = wa_makt-maktx.

CLEAR: wa_makt.

ENDIF.

wa_niu-serial_no = wa_esn-equnr.

wa_niu-matnr = wa_esn-matnr.

wa_niu-bwtar = wa_esn-b_charge.

wa_niu-plant = wa_esn-b_werk.

wa_niu-storage_loc = wa_esn-b_lager.

wa_niu-stock_type = wa_esn-lbbsa.

wa_niu-pr_run_date = s_date.

wa_niu-s_date = sy-datum.

READ TABLE it_sernr INTO wa_sernr WITH KEY equnr = wa_esn-equnr.

IF sy-subrc EQ 0.

wa_niu-mblnr = wa_sernr-mblnr.

wa_niu-mjahr = wa_sernr-mjahr.

wa_niu-doc_date = wa_sernr-datum.

ENDIF.

APPEND wa_niu TO it_niu.

CLEAR: wa_niu,wa_esn,wa_sernr,wa_stock.

ENDLOOP.

MODIFY zniu_owner_stock FROM TABLE it_niu.

IF sy-subrc EQ 0.

MESSAGE s000 WITH 'Table UP-Dated count' count.

CLEAR: it_niu.

ELSE.

MESSAGE e000 WITH 'Table Not UP-Dated'.

CLEAR it_niu.

ENDIF.

REFRESH : it_esn.

  • ENDSELECT.

ENDIF.

1 REPLY 1
Read only

Former Member
0 Likes
408

Nothing to do with cursors:

SELECT...
  LOOP
    READ (no binary search option)
  ENDLOOP.
ENDSELECT

Rob