Skip to Content
0
Former Member
Oct 21, 2009 at 07:59 AM

select statement too slow during run time

386 Views

Hi Experts,

I'm a newbie, I had a hard time in select statements. It takes 15 minutes to generate the output.

Could somebody help me to reconstruct my statement. Thank you.

Below is my statement:

  SELECT  bukrs
          belnr
          gjahr
          shkzg
          zuonr
          vbeln
          hkont
          prctr
          pswsl
          pswbt
  FROM bseg
  INTO TABLE it_pdc
  WHERE
  bukrs IN s_bukrs
  AND belnr IN s_belnr
  AND zuonr IN s_zuonr
  AND prctr IN s_prctr
  AND hkont = c_sales_pdc.

  SORT it_pdc BY belnr.

  IF sy-subrc = 0.
    SELECT belnr budat blart
    FROM bkpf
    INTO TABLE it_pdc1
    FOR ALL ENTRIES IN it_pdc
    WHERE belnr = it_pdc-belnr
    AND budat LE p_budat.
  ENDIF.


  LOOP AT it_pdc ASSIGNING <wa_pdc>.

    <wa_pdc>-gtotal = 0.

    IF <wa_pdc>-shkzg = 'H'.
      <wa_pdc>-pswbt  =  - <wa_pdc>-pswbt.
    ENDIF.

    MOVE <wa_pdc>-pswbt TO <wa_pdc>-pdc.
    ADD <wa_pdc>-pswbt TO <wa_pdc>-gtotal.

    MODIFY it_pdc FROM <wa_pdc>.

  ENDLOOP.

Edited by: Matt on Oct 21, 2009 10:37 AM - surrounded abap with to retain formatting