Time Out selecting Table

Hi friends, 
Now I'm with another problem.
I have a Specific table with 150.000.000 register approximately. I'm using the select bellow, with the command PACKAGE SIZE, but anyway a time out occurs. The Basis don't have permission to change the time of time out.  You can Help-me.
EXAMPLE BELLOW:
  SELECT rvers                                         
         drcrk
         docnr
         docln
         racct
         rcntr
         hsl
         sgtxt
         budat
         FROM zglt1sbra
             APPENDING TABLE gt_zglt1sbra
             PACKAGE SIZE 150000
             WHERE rrcty  = v_rrcty
            WHERE rrcty  EQ gw_rrcty
                    AND   rvers  IN r_rvers
                    AND   ryear  IN br_gjahr
                   AND   docnr  IN br_belnr
                  AND   rbukrs EQ br_bukrs-low
                  AND   activ  NE c_rkiv
                  AND   activ  NE c_rkiu
                 AND    budat  IN br_budat
                AND zzzxblnr IN br_xblnr.
   ENDSELECT.

Hi,
a bit old fashioned but it may work:
statics:    s_cursor type cursor.
DO.
If sy-index = 1. "first loop.
      open cursor with hold s_cursor for
         SELECT ..."continue your statement without package size
endif.
        fetch next cursor s_cursor
                   into corresponding fields
                   of table " your table
                   package size "your size.
        if sy-subrc <> 0.
          close cursor s_cursor.
          EXIT
        endif.
  COMMIT WORK. "resets runtime for max runtime
ENDDO.
Be sure not to append all entries but to process them block by block - else memory would be a problem...
Kind regards,
HP.

Similar Messages

  • Time out error 1.6 million internal table fields are computed using FMs

    Hi , All ...
    The Report running fine in server with less 300 record but ...production server which has 1.6 million record it  gives error as time-out error and takes hell amount of time.
    Please suggest ugently ..
    I have tried few things
    Internal table having 1.6 lacs ... fields to compute .. i have token in a batch
    loop at i_cinfo into s_cinfo from 1 to  100000.
    and so on ...also applied all the performace related .. like indexs, work areas , deleting adjacent duplicates , for all entries ..wherever applicable.
    Please Suggest .
    Report is as below
    REPORT  ZUSOTCBD_CREDIT_REPORT .
    TABLES : KNA1,    " General Data Customer Master
             KNB1,    " Customer Master (Company Code)
             KNC1,    " Customer master (transaction figures)
             KNKK,    " Customer master credit management: Control area data
             T009,    " Fiscal Year Variants P
             T009Y,   " Shortened fiscal years in Asset Accounting P
             T001,    " Co. Codes
             T001CM,  " Permitted Credit Control Areas per Company Code
             RF42B,   " Structure to hold credit data.
             RF035,   " Structure to hold credit managment fields
             RF02L,   " Structure to hold credit data.
             TRAS,    " Interval for Days in Arrears P
             T000CM.  " Data for DSO calculation.
    Types
    TYPES:
      BEGIN OF type_final,
        string(50) TYPE c,                            " String Value for Title
      END OF type_final.
    data:wa_final     TYPE type_final.                " Work Area to hold Title Data
    DATA:    RASID    TYPE RF035-RASID value 'R03N'. " For Days in interval
    DATA:    MONAT(2) TYPE N.
    DATA:    GJAHR    TYPE  KNC1-GJAHR.
    DATA:    LD_PERIODS(32) TYPE N
                           VALUE '01020304050607080910111213141516'.
    DATA     sytabix type sy-tabix.
    DATA     LAND      TYPE KNA1-LAND1 VALUE 'US'.   " Country Key
    DATA:   LD_PERIOD    TYPE BSID-MONAT,            " Fiscal Year Variant
            LD_GJAHR   TYPE KNC1-GJAHR,
            LD_COUNTER TYPE SY-TABIX.
    Internal Tables
    Internal table to hold Title Data                                   *
    DATA:
      i_final    TYPE STANDARD TABLE OF type_final.
    **Internal Table Permitted Credit Control Areas per Company Code
    DATA:    BEGIN OF TCMTAB OCCURS 10.
            INCLUDE STRUCTURE T001CM.
    DATA:    END   OF TCMTAB.
    *Internal table to store Customer no.
    DATA :  BEGIN OF ICUST OCCURS 0,
               KUNNR             TYPE KNA1-KUNNR,    " Customer No.
            END   OF ICUST.
    DATA:    BEGIN OF BUKTAB OCCURS 20,
               KKBER             LIKE T001-KKBER,    " Credit Control Area
               BUKRS             LIKE T001-BUKRS,    " Co. Code
               WAERS             LIKE T001-WAERS,    " Currency
               PERIV             LIKE T001-PERIV,    " Fiscal Year Variant
               BUTXT             LIKE T001-BUTXT,
             END   OF BUKTAB.
    Internal Table to store Fiscal year Data .
    DATA:    BEGIN OF GJATAB OCCURS 5,
               PERIV             LIKE T001-PERIV,    " Fiscal Year Variant
               GJAHR             LIKE KNC1-GJAHR,    " Fiscal Year
               MONAT             LIKE T009-ANZBP,    "
               ANZBP             LIKE T009-ANZBP,    " Number of posting periods
             END   OF GJATAB.
    *Main Output internal table to be used to store credit history Information
    DATA : BEGIN OF I_CINFO occurs 0,
                 KUNNR TYPE   KNB1-KUNNR,     " Customer
                 KNKLI TYPE   KNKK-KNKLI,     " Customer's account number with credit limit reference
                 KKBER TYPE   KNKK-KKBER,     " Credit Control Area
                 CTLPC TYPE   KNKK-CTLPC,     " Risk Category
                 KLIMK TYPE   KNKK-KLIMK,     " Credit Limit
                 SBGRP TYPE   KNKK-SBGRP,     " Credit representative group for credit management
                 ERDAT TYPE   KNKK-ERDAT,     " Created On
                 DTREV TYPE   KNKK-DTREV,     " Last Internal Review
                 REVDB TYPE   KNKK-REVDB,     " Last External Review
                 SALDO TYPE   RF42B-SALDO,    " Balance
                 DSOIN TYPE   RF02L-DSOIN,    " DSO
                 H06SA TYPE   RF035-H06SA,    " Highest Balance at the end of 6 Months
                 H06JA TYPE   RF035-H06JA,    " Year highest Balance 6 Months
                 H06MO TYPE   RF035-H06MO,    " Month OF hihest Balance 6 Months
                 H12SA TYPE   RF035-H12SA,    " Highest Balance at the end of 12 Months
                 H12JA TYPE   RF035-H12JA,    " Year highest Balance 12 Months
                 H12MO TYPE   RF035-H12MO,    " Month OF hihest Balance 12 Months
                 UMP2U TYPE   RF42B-UMP2U,    " Sales from the current Year
                 UMP1U TYPE   RF42B-UMP1U,    " Sales from the Previous Year
                 SFAEL TYPE   RF035-SFAEL,    " Total Past Due Open Item
                 SFAE1 TYPE   RF035-SFAE1,    " Aging buckets 0-15
                 SFAE2 TYPE   RF035-SFAE2,    " Aging buckets 16-30
                 SFAE3 TYPE   RF035-SFAE3,    " Aging buckets 31-60
                 SFAE4 TYPE   RF035-SFAE4,    " Aging buckets 60-90
                 SFAE5 TYPE   RF035-SFAE5,    " Aging buckets Over 90
          END Of I_CINFO.
    DATA : BEGIN OF S_CINFO ,
                 KUNNR TYPE   KNB1-KUNNR,     " Customer
                 KNKLI TYPE   KNKK-KNKLI,     " Customer's account number with credit limit reference
                 KKBER TYPE   KNKK-KKBER,     " Credit Control Area
                 CTLPC TYPE   KNKK-CTLPC,     " Risk Category
                 KLIMK TYPE   KNKK-KLIMK,     " Credit Limit
                 SBGRP TYPE   KNKK-SBGRP,     " Credit representative group for credit management
                 ERDAT TYPE   KNKK-ERDAT,     " Created On
                 DTREV TYPE   KNKK-DTREV,     " Last Internal Review
                 REVDB TYPE   KNKK-REVDB,     " Last External Review
                 SALDO TYPE   RF42B-SALDO,    " Balance
                 DSOIN TYPE   RF02L-DSOIN,    " DSO
                 H06SA TYPE   RF035-H06SA,    " Highest Balance at the end of 6 Months
                 H06JA TYPE   RF035-H06JA,    " Year highest Balance 6 Months
                 H06MO TYPE   RF035-H06MO,    " Month OF hihest Balance 6 Months
                 H12SA TYPE   RF035-H12SA,    " Highest Balance at the end of 12 Months
                 H12JA TYPE   RF035-H12JA,    " Year highest Balance 12 Months
                 H12MO TYPE   RF035-H12MO,    " Month OF hihest Balance 12 Months
                 UMP2U TYPE   RF42B-UMP2U,    " Sales from the current Year
                 UMP1U TYPE   RF42B-UMP1U,    " Sales from the Previous Year
                 SFAEL TYPE   RF035-SFAEL,    " Total Past Due Open Item
                 SFAE1 TYPE   RF035-SFAE1,    " Aging buckets 0-15
                 SFAE2 TYPE   RF035-SFAE2,    " Aging buckets 16-30
                 SFAE3 TYPE   RF035-SFAE3,    " Aging buckets 31-60
                 SFAE4 TYPE   RF035-SFAE4,    " Aging buckets 60-90
                 SFAE5 TYPE   RF035-SFAE5,    " Aging buckets Over 90
          END Of s_cinfo.
    *Internal table to hold month-wise balance.
    DATA:    BEGIN OF SALTAB OCCURS 12,
               LNUMM(2)     TYPE N,             " Month
               SALDO        LIKE RF42B-SALDO,   " Balance
             END   OF SALTAB.
    *Internal table used for computing the Balance fields
    DATA:    BEGIN OF SALDO,
               UML01             LIKE KNC1-UM01S,
               UML02             LIKE KNC1-UM01S,
               UML03             LIKE KNC1-UM01S,
               UML04             LIKE KNC1-UM01S,
               UML05             LIKE KNC1-UM01S,
               UML06             LIKE KNC1-UM01S,
               UML07             LIKE KNC1-UM01S,
               UML08             LIKE KNC1-UM01S,
               UML09             LIKE KNC1-UM01S,
               UML10             LIKE KNC1-UM01S,
               UML11             LIKE KNC1-UM01S,
               UML12             LIKE KNC1-UM01S,
             END   OF SALDO.
    Structure to hold Bal fields ------ -------
    DATA:    BEGIN OF SKNKK,
               KUNNR             LIKE KNA1-KUNNR,  " Customer Number 1: Debitor
               KONTO             LIKE KNKK-KUNNR,
               SFAE1             LIKE RF035-SFAE1, " Aging buckets 0-15
               SFAE2             LIKE RF035-SFAE2, " Aging buckets 16-30
               SFAE3             LIKE RF035-SFAE3, " Aging buckets 30-60
               SFAE4             LIKE RF035-SFAE4, " Aging buckets 60-90
               SFAE5             LIKE RF035-SFAE5, " Aging buckets Over 90
               SFAEL             LIKE RF035-SFAEL, " Total Due of Items
               UML01             LIKE KNC1-UM01S,
               UML02             LIKE KNC1-UM01S,
               UML03             LIKE KNC1-UM01S,
               UML04             LIKE KNC1-UM01S,
               UML05             LIKE KNC1-UM01S,
               UML06             LIKE KNC1-UM01S,
               UML07             LIKE KNC1-UM01S,
               UML08             LIKE KNC1-UM01S,
               UML09             LIKE KNC1-UM01S,
               UML10             LIKE KNC1-UM01S,
               UML11             LIKE KNC1-UM01S,
               UML12             LIKE KNC1-UM01S,
               UMP1U             LIKE RF42B-UMP1U, " Sales from the Previous Year
               UMP2U             LIKE RF42B-UMP2U, " Sales from the current Year
               SALDO             LIKE RF42B-SALDO, " Balance
             END   OF SKNKK.
    DATA :  BEGIN OF ICUST1 OCCURS 0,
               KUNNR             TYPE KNA1-KUNNR,    "For Customer Filter.
            END   OF ICUST1.
    **Internal table to hold fiscal varriants
    DATA: BEGIN OF LT_PERIODS OCCURS 12,
             PERIOD LIKE BSID-MONAT,
             GJAHR  LIKE KNC1-GJAHR,
           END OF LT_PERIODS.
    **Constants
    constants :  BUKRS1 TYPE KNB1-BUKRS VALUE '1000',
                 BUKRS2 TYPE KNB1-BUKRS VALUE '1031',
                 Recs   Type i value '200',
                 B_count type i value '2'.
          INITIALIZATION
    INITIALIZATION.
      IF RASID IS INITIAL.
        SELECT * FROM TRAS.
          EXIT.
        ENDSELECT.
        IF SY-SUBRC = 0.
          RASID = TRAS-RASID.
        ENDIF.
      ENDIF.
    SELECTION-SCREEN
      parameters : p_path type rlgrap-filename default 'C:\Documents and Settings\C890971\Desktop\Credit_history.XLS'.
    Start of selection processing
    START-OF-SELECTION.
    **Get Customers for Co. Code 1000 & 1031.
      PERFORM GET_CUST.
    Get  / Compute Credit Information data for Company Codes 1000 & 1031.
      PERFORM GET_CREDIT_DATA.
    End of selection processing
    *END-OF-SELECTION.
    Listing Credit History Data
      PERFORM DOWNLOAD_CREDIT_DATA.
    S U B R O U T I N E S
    *&      Form  GET_CUST
          text
    -->  p1        text
    <--  p2        text
    FORM GET_CUST .
    Get US only Customers.
      Refresh icust.
      Select kunnr from kna1 appending table icust
                                   where Land1 = land.
    **Delete duplicate records
      Delete Adjacent duplicates from icust comparing kunnr.
      if icust[] is not initial.
       Limit the selection some more to Co. Code 1000 & 1031
      As join will cost overhead as compared.
      Select kunnr from knb1 into table icust1
                                  for all entries in icust
                                  where kunnr = icust-kunnr
                                  and   bukrs = bukrs1
                                  OR    bukrs = bukrs2.
    **Delete duplicate records
      Delete Adjacent duplicates from icust1 comparing kunnr.
       endif.
    **Free memory.
      Free icust.
    Credit Control Area
      select * from T001CM into table TCMTAB
                           where bukrs = bukrs1 OR
                                 bukrs = bukrs2.
    ENDFORM.                    " GET_CUST
    *&      Form  GET_CREDIT_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM GET_CREDIT_DATA .
      DATA : L_TEXT(60) TYPE C ,
             Ltext1(50) type C value 'Computing Credit-History Data For',
             Ltext2(10) type C value 'Customers',
             L_PCT type i value '10',
             L_recs type i,
             l_batch_recs type i,
             l_s_rec type i value 1,
             l_recs1(7) type N.
    ***Fetch data from KNKK table
      PERFORM GET_KNKK_DATA  .
    ***Computing Crredit Fields
    **Number of Customers For whom Deatils needed.
      Describe table I_CINFO lines l_recs.
      l_recs1 = l_recs.
      Concatenate Ltext1 l_recs1 Ltext2 into l_text separated by ' '.
      PERFORM GET_PGRESS_INDICATOR USING l_text l_pct.
    ***If records are more than 200000, should be processed  batch-wise
      If l_recs > recs.
        l_batch_recs = abs( l_recs / b_count ).
        Do b_count times.
          loop at i_cinfo INTO S_CINFO from l_S_REC to l_batch_recs.
    **Remember the row
            sytabix = sy-tabix.
    **Compute DSO
            PERFORM GET_DSO_FIELD .
    Compute rest credit history data.
            PERFORM COMPUTE_SFIELDS.
          endloop.
          l_S_REC = l_S_REC + l_batch_recs.
          l_batch_recs = l_batch_recs + l_batch_recs.
          IF l_batch_recs ge l_recs.
            l_batch_recs = l_recs.
          eNDIF.
    Commit up to here to release the DB locks.
          Commit work.
        enddo.
      else.
        loop at i_cinfo INTO S_CINFO.
    **Remember the row
          sytabix = sy-tabix.
    **Compute DSO
          PERFORM GET_DSO_FIELD .
    Compute rest credit history data.
          PERFORM COMPUTE_SFIELDS.
        endloop.
      Endif.
    ENDFORM.                    " GET_CREDIT_DATA
    *&      Form  GET_KNKK_DATA
          text
         -->P_ICUST_KUNNR  text
    FORM GET_KNKK_DATA .
      if icust1[] is not initial.
      SELECT   KUNNR KNKLI KKBER  CTLPC KLIMK
               SBGRP ERDAT DTREV REVDB
               from KNKK into corresponding fields of table I_Cinfo
               for all entries in icust1
               where kunnr = icust1-kunnr.
      Delete Adjacent duplicates from i_cinfo comparing kunnr.
      endif.
    **Free Memory for internal table icust1.
      Free icust1.
    ENDFORM.                    " GET_KNKK_DATA
    **&      Form  GET_DSO_FIELD
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DSO_FIELD .
    ***Determine DSO Parameter
      PERFORM DSO_PARAMETER.
    ***Compute DSO
      CALL FUNCTION 'CUSTOMER_DSO_CALCULATION'
        EXPORTING
          I_KKBER       = s_cinfo-kkber
          I_KUNNR       = s_cinfo-kunnr
          I_ANZBUPER    = T000CM-DSOPP
          I_XCHILDS     = T000CM-DSOCH
          I_ACTBALANCE  = T000CM-DSOAB
        IMPORTING
          E_DSOIN       = RF02L-DSOIN
        EXCEPTIONS
          ERROR_MESSAGE = 1.
    ENDFORM.                    " GET_DSO_FIELD
    *&      Form  DSO_PARAMETER
          text
    -->  p1        text
    <--  p2        text
    FORM DSO_PARAMETER.
      IF T000CM-DSOPP IS INITIAL.
        SELECT SINGLE * FROM T000CM.
        IF SY-SUBRC     EQ 0.
          IF T000CM-DSOPP IS INITIAL.
            T000CM-DSOPP = '003'.
          ENDIF.
        ELSE.
          T000CM-DSOPP = '003'.
          T000CM-DSOCH = ' '.
          T000CM-DSOAB = 'X'.
        ENDIF.
      ENDIF.
    ENDFORM.                    " DSO_PARAMETER
    -->  p1        text
    <--  p2        text
    FORM PERIODE_ERMITTELN_EXC USING
                P03_BUDAT    LIKE SYST-DATUM
                P03_GJAHR    LIKE KNC1-GJAHR
                P03_MONAT    LIKE MONAT.
      CALL FUNCTION 'FI_PERIOD_DETERMINE'
           EXPORTING
                I_BUDAT = P03_BUDAT
                I_PERIV = T001-PERIV
              I_BUKRS = T001-BUKRS
                I_GJAHR = P03_GJAHR
                I_MONAT = P03_MONAT
           IMPORTING
                E_GJAHR = P03_GJAHR
                E_MONAT = P03_MONAT
           EXCEPTIONS
                ERROR_MESSAGE = 1.
    ENDFORM.                    "PERIODE_ERMITTELN_EXC
    *&      Form  COMPUTE_SFIELDS
          text
    -->  p1        text
    <--  p2        text
    FORM COMPUTE_SFIELDS .
    **Compute Balance
      PERFORM GET_SFIELDS .
      S_CINFO-DSOIN = RF02L-DSOIN.
      S_CINFO-SALDO = RF035-SALDO.
      S_CINFO-H06SA = RF035-H06SA.
      S_CINFO-H06JA = RF035-H06JA.
      S_CINFO-H06MO = RF035-H06MO.
      S_CINFO-H12SA = RF035-H12SA.
      S_CINFO-H12JA = RF035-H12JA.
      S_CINFO-H12MO = RF035-H12MO.
      S_CINFO-UMP2U = RF42B-UMP2U.
      S_CINFO-UMP1U = RF42B-UMP1U.
      S_CINFO-SFAEL = RF035-SFAEL.
      S_CINFO-SFAE1 = RF035-SFAE1.
      S_CINFO-SFAE2 = RF035-SFAE2.
      S_CINFO-SFAE3 = RF035-SFAE3.
      S_CINFO-SFAE4 = RF035-SFAE4.
      S_CINFO-SFAE5 = RF035-SFAE5.
    modify..
      MODIFY I_CINFO FROM S_CINFO INDEX sytabix.
      CLEAR: S_CINFO,RF035,RF02L, RF42B.
    ENDFORM.                    " COMPUTE_SFIELDS
          text
         -->P_C_INFO_KUNNR  text
    FORM GET_CUST_BAL_INFO.
      LOOP AT TCMTAB.
        CALL FUNCTION 'FI_COMPANY_CODE_DATA'
          EXPORTING
            I_BUKRS       = TCMTAB-BUKRS
          IMPORTING
            E_T001        = T001
          EXCEPTIONS
            ERROR_MESSAGE = 1.
        IF SY-SUBRC = 0.
          MOVE-CORRESPONDING T001 TO BUKTAB.
          BUKTAB-KKBER = TCMTAB-KKBER.
          COLLECT BUKTAB.
        ENDIF.
      ENDLOOP.
      LOOP AT BUKTAB WHERE PERIV NE SPACE.
        GJATAB-PERIV = BUKTAB-PERIV.
        COLLECT GJATAB.
      ENDLOOP.
      CLEAR: MONAT.
      LOOP AT GJATAB.
        T001-PERIV = GJATAB-PERIV.
        CLEAR: GJAHR, MONAT.
        PERFORM PERIODE_ERMITTELN_EXC USING SY-DATLO GJAHR MONAT.
        CHECK SY-SUBRC = 0.
        GJATAB-GJAHR = GJAHR.
        GJATAB-MONAT = MONAT.
        SELECT SINGLE * FROM T009 WHERE PERIV = GJATAB-PERIV.
        IF SY-SUBRC = 0.
          GJATAB-ANZBP = T009-ANZBP.
        ENDIF.
        MODIFY GJATAB.
      ENDLOOP.
      LOOP AT BUKTAB.
        CHECK NOT ( BUKTAB-PERIV IS INITIAL ).
        READ TABLE GJATAB WITH KEY BUKTAB-PERIV.
        CHECK SY-SUBRC = 0
          AND NOT ( GJATAB-GJAHR IS INITIAL ).
        CALL FUNCTION 'CUSTOMER_BALANCE'
          EXPORTING
            KUNNR      = S_cinfo-kunnr
            BUKRS      = BUKTAB-BUKRS
            GJAHR      = GJATAB-GJAHR
            MONAT      = GJATAB-MONAT
            PERIV      = GJATAB-PERIV
            ANZBP      = GJATAB-ANZBP
            XH6MON     = 'X'
            XH12MON    = 'X'
          IMPORTING
            UMP2U      = RF42B-UMP2U
            VMP2U      = RF42B-UMP1U
            SALDO      = RF035-SALDO
            UML01      = SALDO-UML01
            UML02      = SALDO-UML02
            UML03      = SALDO-UML03
            UML04      = SALDO-UML04
            UML05      = SALDO-UML05
            UML06      = SALDO-UML06
            UML07      = SALDO-UML07
            UML08      = SALDO-UML08
            UML09      = SALDO-UML09
            UML10      = SALDO-UML10
            UML11      = SALDO-UML11
            UML12      = SALDO-UML12
          EXCEPTIONS
            NO_BALANCE = 4.
        IF SY-SUBRC = 0.
          SKNKK-UMP1U = SKNKK-UMP1U + RF42B-UMP1U.
          SKNKK-UMP2U = SKNKK-UMP2U + RF42B-UMP2U.
          SKNKK-SALDO = SKNKK-SALDO + RF035-SALDO.
          SKNKK-UML01 = SKNKK-UML01 + SALDO-UML01.
          SKNKK-UML02 = SKNKK-UML02 + SALDO-UML02.
          SKNKK-UML03 = SKNKK-UML03 + SALDO-UML03.
          SKNKK-UML04 = SKNKK-UML04 + SALDO-UML04.
          SKNKK-UML05 = SKNKK-UML05 + SALDO-UML05.
          SKNKK-UML06 = SKNKK-UML06 + SALDO-UML06.
          SKNKK-UML07 = SKNKK-UML07 + SALDO-UML07.
          SKNKK-UML08 = SKNKK-UML08 + SALDO-UML08.
          SKNKK-UML09 = SKNKK-UML09 + SALDO-UML09.
          SKNKK-UML10 = SKNKK-UML10 + SALDO-UML10.
          SKNKK-UML11 = SKNKK-UML11 + SALDO-UML11.
          SKNKK-UML12 = SKNKK-UML12 + SALDO-UML12.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "
    *&      Form  GET_SFIELDS
          text
    -->  p1        text
    <--  p2        text
    FORM GET_SFIELDS .
      sknkk-kunnr = S_CINFO-KUNNR.
    **Clear target to store computed values
      CLEAR: RF035.
    **Compute Balance fields
      PERFORM GET_CUST_BAL_INFO.
      REFRESH: SALTAB.
      SALTAB-LNUMM = '01'. SALTAB-SALDO = SKNKK-UML01. APPEND SALTAB.
      SALTAB-LNUMM = '02'. SALTAB-SALDO = SKNKK-UML02. APPEND SALTAB.
      SALTAB-LNUMM = '03'. SALTAB-SALDO = SKNKK-UML03. APPEND SALTAB.
      SALTAB-LNUMM = '04'. SALTAB-SALDO = SKNKK-UML04. APPEND SALTAB.
      SALTAB-LNUMM = '05'. SALTAB-SALDO = SKNKK-UML05. APPEND SALTAB.
      SALTAB-LNUMM = '06'. SALTAB-SALDO = SKNKK-UML06. APPEND SALTAB.
      SALTAB-LNUMM = '07'. SALTAB-SALDO = SKNKK-UML07. APPEND SALTAB.
      SALTAB-LNUMM = '08'. SALTAB-SALDO = SKNKK-UML08. APPEND SALTAB.
      SALTAB-LNUMM = '09'. SALTAB-SALDO = SKNKK-UML09. APPEND SALTAB.
      SALTAB-LNUMM = '10'. SALTAB-SALDO = SKNKK-UML10. APPEND SALTAB.
      SALTAB-LNUMM = '11'. SALTAB-SALDO = SKNKK-UML11. APPEND SALTAB.
      SALTAB-LNUMM = '12'. SALTAB-SALDO = SKNKK-UML12. APPEND SALTAB.
      READ TABLE SALTAB INDEX 1.
      RF035-H06SA = SALTAB-SALDO.
      RF035-H06MO = SALTAB-LNUMM.
      RF035-H12SA = SALTAB-SALDO.
      RF035-H12MO = SALTAB-LNUMM.
    ------ SALTAB ---------------------------------------------
      LOOP AT SALTAB.
        IF  SALTAB-SALDO > RF035-H06SA
        AND SY-TABIX     < 7.
          RF035-H06SA = SALTAB-SALDO.
          RF035-H06MO = SALTAB-LNUMM.
        ENDIF.
        IF  SALTAB-SALDO > RF035-H12SA
        AND SY-TABIX     < 13.
          RF035-H12SA = SALTAB-SALDO.
          RF035-H12MO = SALTAB-LNUMM.
        ENDIF.
      ENDLOOP.
    ------ Period--------------------
      REFRESH LT_PERIODS.
      CLEAR LD_COUNTER.
      READ TABLE BUKTAB INDEX 1.
      IF SY-SUBRC = 0.
        READ TABLE GJATAB WITH KEY BUKTAB-PERIV.
        DO GJATAB-MONAT TIMES
           VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
                                                     RANGE LD_PERIODS.
          LT_PERIODS-GJAHR  = GJATAB-GJAHR.
          LT_PERIODS-PERIOD = LD_PERIOD.
          LD_COUNTER = LD_COUNTER + 1.
          APPEND LT_PERIODS.
        ENDDO.
        IF LD_COUNTER LT 12.
          LD_GJAHR = GJATAB-GJAHR - 1.
          CLEAR T009Y.
          SELECT SINGLE * FROM T009Y WHERE PERIV = GJATAB-PERIV
                                       AND GJAHR = LD_GJAHR.
          DO GJATAB-ANZBP TIMES
             VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
                                                       RANGE LD_PERIODS.
            IF T009Y-ANZBP > 0.
              CHECK SY-INDEX <= T009Y-ANZBP.
            ENDIF.
            LD_COUNTER = LD_COUNTER + 1.
            LT_PERIODS-GJAHR  = LD_GJAHR.
            LT_PERIODS-PERIOD = LD_PERIOD.
            APPEND LT_PERIODS.
          ENDDO.
        ENDIF.
        IF LD_COUNTER LT 12.
          LD_GJAHR = LD_GJAHR - 1.
          DO GJATAB-ANZBP TIMES
             VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
                                                       RANGE LD_PERIODS.
            LD_COUNTER = LD_COUNTER + 1.
            LT_PERIODS-GJAHR  = LD_GJAHR.
            LT_PERIODS-PERIOD = LD_PERIOD.
            APPEND LT_PERIODS.
          ENDDO.
        ENDIF.
        SORT LT_PERIODS BY GJAHR ASCENDING PERIOD ASCENDING.
        LD_COUNTER = LD_COUNTER - 12.
        DO LD_COUNTER TIMES.
          DELETE LT_PERIODS INDEX 1.
        ENDDO.
        SORT LT_PERIODS BY GJAHR DESCENDING PERIOD DESCENDING.
        READ TABLE LT_PERIODS INDEX RF035-H06MO.
        RF035-H06MO = LT_PERIODS-PERIOD.
        RF035-H06JA = LT_PERIODS-GJAHR.
        READ TABLE LT_PERIODS INDEX RF035-H12MO.
        RF035-H12MO = LT_PERIODS-PERIOD.
        RF035-H12JA = LT_PERIODS-GJAHR.
      ENDIF.
    **Compute Due Dates fields
      PERFORM GET_AGING_BUCKETS .
      RF035-SFAE1 = SKNKK-SFAE1.
      RF035-SFAE2 = SKNKK-SFAE2.
      RF035-SFAE3 = SKNKK-SFAE3.
      RF035-SFAE4 = SKNKK-SFAE4 .
      RF035-SFAE5 = SKNKK-SFAE5.
    ENDLOOP.
    ENDFORM.                    " GET_BALANCE_SFIELDS
    *&      Form  GET_AGING_BUCKETS
          text
    -->  p1        text
    <--  p2        text
    FORM GET_AGING_BUCKETS .
      DATA: BEGIN OF LT_BUKRS OCCURS 0,
              BUKRS LIKE T001-BUKRS,
            END OF LT_BUKRS.
      DATA: BEGIN OF LT_BUKTAB OCCURS 0,
              BUKRS LIKE T001-BUKRS,
              WAERS LIKE T001-WAERS,
              KKBER LIKE T014-KKBER,
            END OF LT_BUKTAB.
      DATA: LD_LINES LIKE SY-TABIX.
    *...performance optimization: for more than one company codes check....*
    *...if balances exist and avoid selection of open items, if they don't.*
    *...exist..............................................................*
      REFRESH LT_BUKRS.
      REFRESH LT_BUKTAB.
      DESCRIBE TABLE BUKTAB LINES LD_LINES.
      IF LD_LINES GT 1.
        SELECT DISTINCT BUKRS APPENDING CORRESPONDING FIELDS
                                        OF TABLE LT_BUKRS
                              FROM KNC1 FOR ALL ENTRIES IN BUKTAB
                        WHERE BUKRS = BUKTAB-BUKRS AND
                              KUNNR = Sknkk-KUNNR.
        SELECT DISTINCT BUKRS APPENDING CORRESPONDING FIELDS
                                        OF TABLE LT_BUKRS
                              FROM KNC3 FOR ALL ENTRIES IN BUKTAB
                        WHERE BUKRS = BUKTAB-BUKRS AND
                              KUNNR = Sknkk-KUNNR.
        SORT LT_BUKRS.
        DELETE ADJACENT DUPLICATES FROM LT_BUKRS.
        LOOP AT LT_BUKRS.
          LOOP AT BUKTAB WHERE BUKRS = LT_BUKRS-BUKRS.
            MOVE-CORRESPONDING BUKTAB TO LT_BUKTAB.
            APPEND LT_BUKTAB.
          ENDLOOP.
        ENDLOOP.
      ELSE.
        READ TABLE BUKTAB INDEX 1.
        MOVE-CORRESPONDING BUKTAB TO LT_BUKTAB.
        APPEND LT_BUKTAB.
      ENDIF.
    *...process company codes for customer given by interface..........*
      LOOP AT LT_BUKTAB WHERE KKBER = s_cinfo-KKBER.
        CALL FUNCTION  'CUSTOMER_DUE_DATE_ANALYSIS'
             EXPORTING  BUKRS   = LT_BUKTAB-BUKRS
                       KKBER   = ' '
                        KKBER   = s_cinfo-KKBER
                        KUNNR   = Sknkk-KUNNR
                        RASID   = RASID
             IMPORTING  SFAE1   = RF035-SFAE1
                        SFAE2   = RF035-SFAE2
                        SFAE3   = RF035-SFAE3
                        SFAE4   = RF035-SFAE4
                        SFAE5   = RF035-SFAE5
                        SFAEL   = RF035-SFAEL
             EXCEPTIONS NO_OPEN_ITEMS = 4.
        IF SY-SUBRC = 0.
    *--  RF035 -
          SKNKK-SFAE1 = SKNKK-SFAE1 + RF035-SFAE1.
          SKNKK-SFAE2 = SKNKK-SFAE2 + RF035-SFAE2.
          SKNKK-SFAE3 = SKNKK-SFAE3 + RF035-SFAE3.
          SKNKK-SFAE4 = SKNKK-SFAE4 + RF035-SFAE4.
          SKNKK-SFAE5 = SKNKK-SFAE5 + RF035-SFAE5.
          SKNKK-SFAE5 = SKNKK-SFAE5 + RF035-SFAE5.
          SKNKK-SFAEL = SKNKK-SFAEL + RF035-SFAEL.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " GET_AGING_BUCKETS
    *&      Form  header
    This Subroutine gets data for displaying title                     *
    There are no interface parameters to be passed to this subroutine. *
    FORM header .
      wa_final-string = text-000.  APPEND wa_final TO i_final.
      wa_final-string = text-001.  APPEND wa_final TO i_final.
      wa_final-string = text-002.  APPEND wa_final TO i_final.
      wa_final-string = text-003.  APPEND wa_final TO i_final.
      wa_final-string = text-004.  APPEND wa_final TO i_final.
      wa_final-string = text-005.  APPEND wa_final TO i_final.
      wa_final-string = text-006.  APPEND wa_final TO i_final.
      wa_final-string = text-007.  APPEND wa_final TO i_final.
      wa_final-string = text-008.  APPEND wa_final TO i_final.
      wa_final-string = text-009.  APPEND wa_final TO i_final.
      wa_final-string = text-010.  APPEND wa_final TO i_final.
      wa_final-string = text-011.  APPEND wa_final TO i_final.
      wa_final-string = text-012.  APPEND wa_final TO i_final.
      wa_final-string = text-013.  APPEND wa_final TO i_final.
      wa_final-string = text-014.  APPEND wa_final TO i_final.
      wa_final-string = text-015.  APPEND wa_final TO i_final.
      wa_final-string = text-016.  APPEND wa_final TO i_final.
      wa_final-string = text-017.  APPEND wa_final TO i_final.
      wa_final-string = text-018.  APPEND wa_final TO i_final.
      wa_final-string = text-019.  APPEND wa_final TO i_final.
      wa_final-string = text-020.  APPEND wa_final TO i_final.
      wa_final-string = text-021.  APPEND wa_final TO i_final.
      wa_final-string = text-022.  APPEND wa_final TO i_final.
      wa_final-string = text-023.  APPEND wa_final TO i_final.
      wa_final-string = text-024.  APPEND wa_final TO i_final.
    ENDFORM.                               " header
    *&      Form  DOWNLOADCREDITDATA
          text
         -->P_P_PATH  text
    FORM DOWNLOADCREDITDATA  USING P_PATH.
      DATA:
          lw_file2 TYPE string .           " File Path
      lw_file2 = p_PATH.
      CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
      BIN_FILESIZE                    = BIN_FILESIZE
           filename                        = lw_file2
           filetype                        = 'DBF'
      APPEND                          = ' '
       write_field_separator           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = 'X'
      WRITE_LF                        = 'X'
       COL_SELECT                      = 'X'
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = 'X'
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = '0'
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
    IMPORTING
      FILELENGTH                      = FILELENGTH
         TABLES
           data_tab                        = I_CINFO
           fieldnames                      = i_final
         EXCEPTIONS
           file_write_error                = 1
           no_batch                        = 2
           gui_refuse_filetransfer         = 3
           invalid_type                    = 4
           no_authority                    = 5
           unknown_error                   = 6
           header_not_allowed              = 7
           separator_not_allowed           = 8
           filesize_not_allowed            = 9
           header_too_long                 = 10
           dp_error_create                 = 11
           dp_error_send                   = 12
           dp_error_write                  = 13
           unknown_dp_error                = 14
           access_denied                   = 15
           dp_out_of_memory                = 16
           disk_full                       = 17
           dp_timeout                      = 18
           file_not_found                  = 19
           dataprovider_exception          = 20
           control_flush_error             = 21
      IF sy-subrc <> 0.
    Messege
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                    " DOWNLOADCREDITDATA
    *&      Form  DOWNLOAD_CREDIT_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM DOWNLOAD_CREDIT_DATA .
      PERFORM HEADER.
      PERFORM DOWNLOADCREDITDATA USING P_PATH.
    ENDFORM.                    " DOWNLOAD_CREDIT_DATA
    *&      Form  GET_PGRESS_INDICATOR
          text
         -->P_L_TEXT  text
         -->P_L_PCT  text
    FORM GET_PGRESS_INDICATOR  USING    L_TEXT
                                        L_PCT.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          PERCENTAGE = l_pct
          TEXT       = l_TEXT.
    ENDFORM.                    " GET_PGRESS_INDICATOR

    If you are just Downloading to a Flat file then why dont you have logic in place for the program to dump the data read into  the file to that point depending on any criteria like accounts or customer then clear the internal table and run it in the back ground.
    try to use cursor to read the records from the table which will make it a bit more efficient than plain select stement.

  • TIME-OUT error in BSAK select query(Progress Indicator is also used)

    Hi,
        In my report program one select query is there on BSAK table, which is as follows --
           SELECT BUKRS                                                     
                         BELNR
                        GJAHR
                        SHKZG
                        BSCHL
                        UMSKZ
                        LIFNR
                        EBELN
                        EBELP
                        WRBTR
                        DMBTR
                        XZAHL
                        REBZG
                       AUGBL
                       BLART
                       AUFNR
                       AUGDT
                       BUZEI FROM BSAK
                                  INTO TABLE IT_BSAK
                                  FOR ALL ENTRIES IN IT_BKPF1
                                   WHERE BUKRS = IT_BKPF1-BUKRS
                                                AND AUGDT = IT_BKPF1-BUDAT
                                                AND AUGBL = IT_BKPF1-BELNR
                                                AND BSCHL IN ('31' , '29', '26', '39', '25').
    I used Progress Indicator befor running this query and after this query also. But still It's giving me TIME-OUT error in this select query only.
      I run the same query for 10 records in IT_BKPF1 table, it runs perfectly. But when I run it for 1000 records it giving dump.
    And in actual bussiness my records are always more than 100 only.
    I also check the indexing. It having secondary indexing on this BUKRS, AUGDT, AUGBL fields. Then also it's giving error.
    so, How can I solve this dump..?? What could be the reason..??
    Thanks in advance...!!
    Regards,
    Poonam.

    Hi Poonam Patil,
    Try to provide BELNR and GJAHR in where condition...
    BKPF-DBBLG ==> BSAK-BELNR
    Also check
    BKPF-BLDAT ==> BSAK-AUGDT
    Check out above relation...
    If data is there in these fields of the table and both are matching then you can pass it and as they are in primary key of BSAK it will improve the performance...
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • Time out problem for select query

    I am fetching data from BKPF for my report.
    I have written following query.But this query always time out.
    SELECT
        BUKRS
        BELNR
        GJAHR
        BLART
        BLDAT
        BUDAT
        MONAT
        XBLNR
        BKTXT
        WAERS
        KURSF
        HWAER
        FROM BKPF
        INTO TABLE I_BKPF
        WHERE BUKRS IN S_BUKRS
         AND BELNR IN S_BELNR
         AND GJAHR IN S_GJAHR
         AND BLART IN S_BLART
         AND BLDAT IN S_BLDAT
         AND BUDAT IN S_BUDAT
         AND MONAT IN S_MONAT
         AND CPUDT IN S_CPUDT
         AND BSTAT = SPACE.
    So please suggest me solution.

    Hi..
    1) Try to make Some of the Fields such as BUKRS , GJAHR  as PARAMETERS so that ROWS are restrited mostly.
    2) Make fields like BLDAT and BUDAT as OBLIGATORY if possible.
    3) And in the SELECT query add the PACKAGE SIZE addition.
    <b>Reward if Helpful.</b>

  • Select query giving Time out dump

    Hi All,
        I have written a select query on a table in BW system.The code for the same is attached below.The table contains some 6,00,000 records.This query is giving a time out error.Kindly look into the query and advice ways to make it work.Thanks.
        IF NOT lt_temp[] IS INITIAL.
          SELECT /bic/zprrmatnr objvers /bic/zprclwynr /bic/zprrmdlr
                 FROM  /bic/pzprrmatnr
                 INTO CORRESPONDING FIELDS OF TABLE lt_zprrmatnr
                 FOR ALL ENTRIES IN lt_temp
                 WHERE /bic/zprclwynr = lt_temp-temp
                 AND   objvers = 'A'.
        ENDIF.
    Thanks and Regards,
    Faisal

    Not only is it BW, it is also a customer table. Have a look here on how to research yourself:
    Please Read before Posting in the Performance and Tuning Forum
    Thomas

  • Time out error while fetching records from table BKPF

    Hi,
    I am fetching records from table BKPF using BUKRS & AWKEY in where clause. Query is as follows:
        SELECT BELNR  XBLNR  AWKEY
        FROM   BKPF
        INTO TABLE L_I_BKPF_TEMP
        PACKAGE SIZE 500
        WHERE BUKRS LIKE L_C_EG
        AND   AWKEY IN L_R_AWKEY .
          APPEND LINES OF L_I_BKPF_TEMP TO I_BKPF .
        ENDSELECT .
    Program is giving time out error. There are 25628 records in range L_R_AWKEY , i m fetching 500 records at a time using  PACKAGE SIZE. But the execution of prog stops on this query.
    Please suggest something to overcome this problem.

    Hi
    Rui is right,
    if you need to get the data by  operation parameters u have to use the fields AWTYP and AWKEY.
    In this selection u can omit the company code.
    SELECT BELNR XBLNR AWKEY FROM BKPF
           INTO TABLE L_I_BKPF_TEMP
                 PACKAGE SIZE 500
                      WHERE   AWTYP = <......> "<------------
                             AND AWKEY IN L_R_AWKEY .
           APPEND LINES OF L_I_BKPF_TEMP TO I_BKPF .
    ENDSELECT .
    Max

  • Select query - Time out error

    Hello Experts,
    Please help me this below query. If I ran the program, it will take so much time to execute the below query and its goes to time out.
    Please help me.
    SELECT  mvgr1                           "Line of Business
                werks                             "Plant
                lgort                               "Storage Location
                charg                              "Batch
                matnr                             "Material Number
                kwmeng                          "Ordered quantity
                posnr                              "Item
                vbeln                              "Sales Order Number
          FROM  vbap
          INTO  TABLE gt_salesdatatemp
           FOR  ALL ENTRIES IN gt_matmerge
         WHERE  matnr EQ gt_matmerge-matnr
           AND  werks EQ gt_matmerge-werks
           AND  mvgr1 EQ gt_matmerge-mvgr1
           AND  lgort EQ gt_matmerge-lgort
           AND  charg EQ gt_matmerge-charg
           AND  abgru EQ space.
    Thanks in advance.

    Hi,
    If the number of records to be fetched is very very high then you can use the cursor concept.
    Please see the below code.
    =====
    OPEN CURSOR dbcur FOR SELECT .... FROM ....... WHERE ...... .
        DO.
        FETCH NEXT CURSOR dbcur INTO TABLE itab PACKAGE SIZE 10000.
           IF sy-subrc NE 0.
                EXIT.
           ENDIF.
        ENDDO.
    CLOSE CURSOR dbcur.
    =====
    Using this concept you can fetch the data in packets.
    Additionally, you can take care of the following points to have better performance.
    a. Check that your query is using the index.
    b. Check that the internal table is not initial. If it is initial then the select will happen for all records in the DB.
    Regards,
    Saurabh

  • Time out parameter to avoid Table locking

    Hi,
    I am looking at any configurable parameter if any for setting the time out parameter to avoid Table locking.Now what's happening is : If i run select ...for update from one session,oracle is applying a lock till i do a commit.And if i run the same query from another session,it takes unspecified time without returning any error.Using the query with NOWAIT options does not serve my purpose.
    Any help in this regard is appreciated
    Thanks
    Sam

    Are you looking for a way to time out the original query, or are you looking for a way for the second query to wait for some time and then abort if it is unable to lock the row(s)?
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Time Out Dump while extracting data from table CKIS

    Dear Friends,
    I am getting TIme Out dump for the below code, while extracting data from table CKIS.
    Table CKIS doesn't have any Indexes. Please guide me to resolve this.
    Regards,
    Viji.
    form get_keko_ckis.
      SELECT kalnr kalka kadky tvers bwvar matnr werks kokrs
             FROM keko
             INTO TABLE i_keko1
             FOR ALL ENTRIES IN i_final_modify
                 WHERE matnr = i_final_modify-main_f
                   AND werks = p_werks
                   AND kokrs = p_kokrs
                   AND kadat = p_kadat
                   AND bidat = p_bidat
                   AND bwdat = p_bwdat.
      IF sy-subrc = 0.
        SORT i_keko1 BY kalnr kalka kadky tvers bwvar.
        SELECT kalnr kalka kadky tvers bwvar posnr typps kstar
               matnr menge gpreis
               FROM ckis
               INTO TABLE i_ckis_temp
               FOR ALL ENTRIES IN i_keko1
               WHERE kalnr = i_keko1-kalnr
                 AND kalka = i_keko1-kalka
                 AND kadky = i_keko1-kadky
                 AND tvers = i_keko1-tvers
                 AND bwvar = i_keko1-bwvar.
            IF sy-subrc = 0.
              SORT i_ckis_temp BY kalnr kalka kadky tvers bwvar.
              LOOP AT i_ckis_temp INTO wa_ckis_temp.
                wa_ckis-kalnr  = wa_ckis_temp-kalnr.
                wa_ckis-kadky  = wa_ckis_temp-kadky.
                wa_ckis-posnr  = wa_ckis_temp-posnr.
                wa_ckis-typps  = wa_ckis_temp-typps.
                wa_ckis-kstar  = wa_ckis_temp-kstar.
                wa_ckis-matnr1 = wa_ckis_temp-matnr1.
                wa_ckis-menge  = wa_ckis_temp-menge.
                wa_ckis-gpreis = wa_ckis_temp-gpreis.
              CLEAR wa_keko1.
              READ TABLE i_keko1 INTO wa_keko1
                                 WITH KEY kalnr = wa_ckis_temp-kalnr
                                          kalka = wa_ckis_temp-kalka
                                          kadky = wa_ckis_temp-kadky
                                          tvers = wa_ckis_temp-tvers
                                          bwvar = wa_ckis_temp-bwvar
                                          BINARY SEARCH.
                 IF sy-subrc = 0.
                    wa_ckis-matnr = wa_keko1-matnr.
                    wa_ckis-werks = wa_keko1-werks.
                 ENDIF.
                 APPEND wa_ckis TO i_ckis.
                 CLEAR: wa_ckis_temp, wa_ckis.
              ENDLOOP.
            ENDIF.
        REFRESH: i_keko1, i_ckis_temp.
      ENDIF.
    endform.                    " get_keko_ckis

    Hi Try minimising the conditions in where clause
         SELECT fields..... FROM CKIS
         WHERE KALNR = KEKO-KALNR AND
                      KADKY = KEKO-KADKY AND
                      TVERS = KEKO-TVERS AND
                      TYPPS = 'M'.
        after this, deleting unwanted records from internal table as per pending conditions...
    Regds,
    Anil

  • GLPCA table fetch - time out issue

    Hi,
    I have a situation in which one of my business user is facing a TIME OUT in RCOPCA02 report in the below piece of code.
    SELECT (tab_fields) FROM glpca
           CLIENT SPECIFIED
           PACKAGE SIZE packsize
           APPENDING CORRESPONDING FIELDS OF TABLE i_glpca
           WHERE rldnr     IN rldnr
             AND rrcty     IN rrcty
             AND rvers     IN rvers
             AND kokrs     IN kokrs
             AND rbukrs    IN bukrs
             AND ryear     IN ryear
             AND rassc     IN rassc
             AND hrkft     IN hrkft                            "note 550972
             AND sbukrs    IN sbukrs                           "note 550972
             AND shoart    IN shoart                           "note 550972
             AND sfarea    IN sfarea                           "note 550972
             AND racct     IN racct
             AND rprctr    IN prctr
             AND sprctr    IN pprctr
             AND poper     IN poper
             AND drcrk     IN drcrk
             AND activ     IN activ
             AND rhoart    IN rhoart
             AND rfarea    IN rfarea
             AND versa     IN versa
             AND eprctr    IN eprctr
             AND afabe     IN afabe
             AND rmvct     IN rmvct
             AND docct     IN docct
             AND docnr     IN docnr
             AND stagr     IN stagr
             AND rtcur     IN rtcur
             AND runit     IN runit
             AND refdocct  IN refdocct
             AND refdocnr  IN refdocnr
             AND werks     IN werks
             AND rep_matnr IN repmatnr     "RDIP40K020663
             AND rscope    IN rscope       "RDIP40K020663
          AND rclnt     IN rclnt.       "dirty trick to mislead DB-optimizer
        packsize is set to 1000
    But when I try to execute the same using the same variant as used by user I am able to get the output in less than 2 mins. The maximum runtime of a program is set as 900 seconds(which I understand is always same across all users). The issue of TIME_OUT is faced by that particular user only.
    My SAP system is SAP_APPL46C. Latest support package implemented is SAPK-91404INDMIS.
    What can be the issue? Please suggest.
    Regards,
    Chinmay

    You should run ST05 in parallel with both you and the user with the problem and see what the differences are in the plan.
    You cannot get a good answer with the data you have provided.
    Please see Please Read before Posting in the Performance and Tuning Forum before posting
    Rob
    Edited by: Rob Burbank on Sep 30, 2011 9:15 AM

  • Getting Time-Out at Select Query

    Dear All,
    I am getting Time-Out at particular Select Query.
    This error i am getting since last 3 days, before it was working fine. And there is no any change made to program in last 3 days.
    select  a~qmnum
             matnr
             kunum
             iwerk
             spart
    into    corresponding fields of iviqmel
    from    ( qmih as a
               inner join qmel as b on b~qmnum = a~qmnum )
    for all entries in i_tab
    where qmart in ('FS', 'ZP')
           and iwerk   = i_tab-iwerk
           and matnr   = i_tab-matnr
           and kunum   = i_tab-kunum
           and spart   = i_tab-spart.
       append iviqmel.
    endselect.
    In Program table QMEL also using the proper Index.
    Can you please give me any suggestion that how to come out from this issue.
    Regards,
    Dharmesh

    Hi Rob,
    I run the SQL Trace also, Query is using correct Index.
    and I had also chenge the select query.
    if not i_tab[] is initial.
        select a~matnr a~kunum a~spart
               b~qmnum b~iwerk
               into corresponding fields of table iviqmel
               from qmel as a inner join
                    qmih as b
                    on a~qmnum = b~qmnum
               for all entries in i_tab
               where a~qmart in ('FS', 'ZP')
                 and a~matnr   = i_tab-matnr
                 and a~kunum   = i_tab-kunum
                 and a~spart   = i_tab-spart
                 and b~iwerk   = i_tab-iwerk.
    endif.
    even its geving time out error.
    Regards,
    Dharmesh

  • Time Out by select on DD04L inner join DD04T

    Hello,
    I just installed ERP 2005. After the import of a language package (SMLT, IT, FR, ES) I get some problem.
    If I logon with EN or IT (and I think with any language other than DE) many transaction get a Time Out error in the function module DDIF_FIELDINFO_GET by the following selection:
    *             get texts of primary language (inner join here !)
                  SELECT DD04L~ROLLNAME DD04L~DOMNAME DD04L~HEADLEN
                         DD04L~SCRLEN1  DD04L~SCRLEN2 DD04L~SCRLEN3
                         DD04T~DDLANGUAGE DD04T~DDTEXT    DD04T~REPTEXT
                         DD04T~SCRTEXT_S  DD04T~SCRTEXT_M DD04T~SCRTEXT_L
                         INTO TABLE Rolltexts
                         FROM DD04L inner JOIN DD04T
                         ON DD04T~ROLLNAME = DD04L~ROLLNAME AND
                            DD04T~AS4LOCAL = 'A' AND
                            DD04T~DDLANGUAGE = langu_loc
                         FOR ALL ENTRIES IN missing
                         WHERE DD04L~ROLLNAME = missing-ROLLNAME
                           AND DD04L~AS4LOCAL = 'A'.
    That is, the ERP is using sequential read instead of direct read.
    Any idea is welcomed.
    Thanks & regards,
    Tommaso

    Hello,
    Thanks for your replies.
    I checked OSS and I found nothing.
    ST05 gives me this SQL command: (more than 500 sec!)
    SELECT T_00 . "ROLLNAME" , T_00 . "DOMNAME" , T_00 . "HEADLEN" , T_00 . "SCRLEN1" , T_00 . "SCRLEN2" , T_00 . "SCRLEN3" , T_01 . "DDLANGUAGE" , T_01 . "DDTEXT" , T_01 . "REPTEXT" , T_01 . "SCRTEXT_S" , T_01 . "SCRTEXT_M" , T_01 . "SCRTEXT_L" FROM "DD04L"
    T_00 INNER JOIN "DD04T" T_01 ON T_01 . "ROLLNAME" = T_00 . "ROLLNAME" AND T_01 . "AS4LOCAL" = 'A' AND T_01 . "DDLANGUAGE" = 'I' WHERE T_00 . "ROLLNAME" = 'VAL_TEXT' AND T_00 . "AS4LOCAL" = 'A'
    I executed it in SQL Studio and I got also a big execution time.
    But if I try
    SELECT  "ROLLNAME" ,  "DOMNAME" ,  "HEADLEN" , "SCRLEN1" , "SCRLEN2" , "SCRLEN3"  FROM "DD04L" WHERE T_00 . "ROLLNAME" = 'VAL_TEXT' AND T_00 . "AS4LOCAL" = 'A'
    I get the result in 1 ms.
    Is there something wrong in the inner join?
    What does it mean the operation "REOPEN"?
    How can I see from ST05 if an index has been used?
    Thanks & Regards,
    Tommaso

  • Select count(*) cause time out error

    I invoke the following statement:
    select count(*) as total from table1
    where table1 is large(30000 rows), total size of the database is more than 20GB.
    The above statement will cause time out error. How to solve the problem?

    Hallo chcw,
    a timeout in a table with 30.000 records is very unusual (for a simple SELECT COUNT). From my point of view Dan is on the right way and you will have a typical blocking scenario.
    1. if you have LOBs they won't be part of a SELECT COUNT (either its a heap of a clustered index)
    2. Microosft SQL Server will ALWAYS use the smallest index for such a simple SELECT
    3. if it is a heap you will run into a blocking scenario if someone is updating records and transaction has not committed.
    4. Check the isolation level of the transactions - but I expect the standard which is "read committed".
    Just a demonstration of "SELECT COUNT" will work whether it is a clustered index or a heap. The next script will create a heap with a LOB and additional attributes:
    CREATE TABLE dbo.foo
    Id INT NOT NULL IDENTITY(1,1),
    n1 INT NOT NULL,
    n2 SMALLINT NULL,
    c1 CHAR(250) NOT NULL,
    c2 CHAR(250) NULL,
    c3 VARCHAR(MAX) NOT NULL DEFAULT (REPLICATE('A', 15000))
    GO
    Now we enter 30,000 records into the table
    SET NOCOUNT ON;
    DECLARE @i INT = 1;
    WHILE @i <= 30000
    BEGIN
    INSERT INTO dbo.foo (n1, c1) VALUES (@i, 'Just a filler');
    SET @i += 1;
    END
    GO
    Keep in mind that we have a HEAP and NO indexes! To check the IO i use the following command befor any of the following examples:
    SET STATISTICS IO ON;
    GO
    Let's start with a first try and you will check as a result the produced IO depending on the affected table partitions:
    -- USE SELECT in a HEAP
    SELECT COUNT(*) FROM dbo.foo;
    GO
    Output:
    Table 'foo'. Scan count 1, logical reads 2508, ..., lob logical reads 0,
    As you can see from the result the LOB-data won't be attached only the "in-row-data" are affected (which are stored in 2508 pages. The reason is a quite simple one: Microsoft SQL Server uses different allocation units for in-row-data and LOB
    SELECT p.object_id, p.index_id, p.rows, au.total_pages
    FROM sys.partitions AS P INNER JOIN sys.allocation_units AS AU
    ON(p.partition_id = au.container_id)
    WHERE object_id = OBJECT_ID('dbo.foo');
    Now I create a simple index on the column n1 which is an INT-datatype
    SELECT p.object_id, p.index_id, p.rows, au.total_pages
    FROM sys.partitions AS P INNER JOIN sys.allocation_units AS AU
    ON(p.partition_id = au.container_id)
    WHERE object_id = OBJECT_ID('dbo.foo');
    and run the SELECT COUNT again with the following IO-output:
    Table 'foo'. Scan count 1, logical reads 69, ...
    WOW - only 69 pages have to be read. The explanation is a quite simple one - now we have an index which is quite small. Microsoft SQL Server WILL use the smallest index of a table to scan the number of records. Let's try it again with n2 which is a smallint
    (2 bytes)
    CREATE NONCLUSTERED INDEX ix_foo_n2 ON dbo.foo (n2);
    GO
    The IO will be 62 (or less) because MORE index records a fitting to one data page!
    Conclusion is that either you have small record size or long record size - The query optimizer will always use the smallest index for the execution (that's maybe why Visahk has asked for the execution plan).
    I don't believe it is because of the "huge amount of data" but - as Dan has pointed out - it HAS TO BE a blocking scenario which can have multiple reasons. For demonstration of a blocking scenario open SSMS and start in the query windows with the following
    command(s):
    BEGIN TRANSACTION
    UPDATE dbo.foo
    SET c1 = 'This is my name'
    WHERE Id = 10000;
    -- What locks do we have now in the database
    SELECT resource_description,
    resource_associated_entity_id,
    request_mode,
    request_type
    FROM sys.dm_tran_locks AS DTL
    WHERE resource_database_id = DB_ID() AND
    resource_type != 'DATABASE';
    Your result should look like that (with differences in the entity_id and resource descriptions :)
    The above pic demonstrates the "locking chain". As you can see the slot 7 on PAGE 82400 has an exclusive lock. This means that NO OTHER request can currently obtain another lock to it!
    Now open a second query window and run a SELECT COUNT... - it will not finish!
    The reason is that the second requests has to wait for the release of the locked resources by the first transaction! Leave the statement and change back to the first transaction and finish the transaction by cancellation of the query. In the moment the locks
    have been released the second query will finish immediate.
    So - from my point of view - Dan has given the correct answer. Against wide spreaded statements a heap won't block the whole table exclusivly but - as in a cluster, too - only the row itself (see the 7 which is the slot where the record exists).
    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

  • How to insert log In & Log Out Time in to Table

    hi,
    i have create a login form there are three textfield
    Username
    Passward
    request is for identify user is admin or User
    i have create two table for login details
    CREATE TABLE "USERS"
    (     "USER_ID" VARCHAR2(10) NOT NULL ENABLE,
         "PASSWORD" VARCHAR2(30),
         "EMAIL_ID" VARCHAR2(50),
         "ROLE" VARCHAR2(1),
         "PHONE_NO" VARCHAR2(15),
         "EMP_ID" NUMBER,
         CONSTRAINT "USERS_PK" PRIMARY KEY ("USER_ID") ENABLE
    CREATE TABLE "USER_RECORD"
    (     "SERIAL" NUMBER NOT NULL ENABLE,
         "USER_ID" VARCHAR2(10),
         "LOGIN_TIME" VARCHAR2(20) NOT NULL ENABLE,
         "DTE" DATE,
         "LOGOUT_TIME" VARCHAR2(20),
         "STATUS" VARCHAR2(1),
         CONSTRAINT "USER_RECORD_PK" PRIMARY KEY ("SERIAL") ENABLE
    DECLARE
    V_ROLE VARCHAR2(1);
    BEGIN
    SELECT ROLE INTO V_ROLE FROM USERS
    WHERE USER_ID =:P68_USERNAME;
    INSERT INTO USER_RECORD
    VALUES(:P68_S_NO,:P68_USERNAME,TO_CHAR(SYSDATE,'HH24:MI:SS'),TO_DATE(SYSDATE,'DD-MON-YYYY'),NULL,'N');
    END;
    i am using this code to insert login time in to table USER_RECORD.
    now i have create log out Navigation Bar on every page ,i want when i click on any on logout link in upper side of page then the logout time should go into USER_RECORD table in LOGOUT_TIME column.
    How can i do this.
    Thanks
    Manoj

    Hello
    Well, i have read and tried to understand what is your goal..
    The goal is to record a user when they log out, right?I have implemented something in a very similar way and I remember I read it once...from a blog...quite easy...
    Here is the way to implement it...
    On the log out URL.. divert it to a single page lets say page: 99..
    f?p=&APP_ID.:99:&APP_SESSION.Page 99 will be a special page which is called when a user logs out of your application right...
    Now..then create an application which you will load before the header....
    The job of this application process will be to insert the required information in your table, your code:
    INSERT INTO USER_RECORD
    VALUES(:P68_S_NO,:P68_USERNAME,TO_CHAR(SYSDATE,'HH24:MI:SS'),TO_DATE(SYSDATE,'DD-MON-YYYY'),NULL,'N');then call a APEX LOG OUT FUNCTIONS which will invalidate session and redirect user to your default log in page: 101<APEX default Authentication Scheme>
    like
    wwv_flow_custom_auth_std.logout( p_this_flow=>:APP_ID,p_next_flow_page_sess=>:APP_ID ||'.:101');
    This APEX Function will logout user, and then redirect the user to the next page with a new session id to your default page
    like i have added it below
    BEGIN
    SELECT ROLE INTO V_ROLE FROM USERS
    WHERE USER_ID =:P68_USERNAME;
    INSERT INTO USER_RECORD
    VALUES(:P68_S_NO,:P68_USERNAME,TO_CHAR(SYSDATE,'HH24:MI:SS'),TO_DATE(SYSDATE,'DD-MON-YYYY'),NULL,'N');
    wwv_flow_custom_auth_std.logout( p_this_flow=>:APP_ID,p_next_flow_page_sess=>:APP_ID ||'.:101');
    END;this processes should be done in default like when before a page is loaded...that is my magic trick
    Hope I was able to help.
    Regards,
    Noel Alex Makumuli,
    Tanzania

  • Bex query. Select single values in variable time out.

    I have created a variable on characteristic 0profit_ctr which works fine for all queries on all Infoproviders except for one.  With this particular Infoprovider, which is a DSO when the option to show u201CSingle Valuesu201D is selected in the variable screen the query just hangs and eventually time-outs. I have tried including the DSO in a mult-provider but still have the same issue. The variable works on other DSOu2019s with exactly the same settings. This DSO has less data than the other DSOu2019s which work fine.
    I know that 0profit_ctr is compounded with 0co_area which I have tried restricting with no change in the result.
    I would be grateful of any ideas.
    Thanks
    Jenny

    Hi Durgesh.
    I checked the settings and although they were the same as other infoproviders I changed the query filter value to use the values in the master data table and this has solved my problem.
    Thanks for your tip.
    Regards
    Jenny

Maybe you are looking for

  • Reset context

    Hi, I have an JSF Portal application one of the Portlets displays some fields and link . The link opens a poup window where I can do some searchers and move the results to the parent window that all works OK the problem that I'm having is if the user

  • Is there anyway to use the macbook pro as a moniter for a seperate device?

    Is it possible under a program of some sort to use the macbook pro's screen as a seperate moniter for a device because I am always on the go and I bring my macbook everywhere so it would be extremely conveniant if I could use it's amazing screen as a

  • Can you export plugins in Indesign CS6?

    I have supplied an InDesign CS6 file to a colleague, when he tries to open it it asks for 4 missing plugins? Does anybody know a solution to this? Do I need to 'export' the plugins, if so does anybody know how to do this?

  • GRRRRR!!!  AE CS3 crashes during render with quicktimempeg4.qtx as problem

    Rendering will advance a seemingly random amount of frames, only to crash repeatedly. The info on the error points to quicktimempeg4.qtx as problem module. I have tried an array of codec packs, as well as quicktime 7.0.3 through the latest 7.4.1 upda

  • Why won't my iPad show up under "devices"in iTunes?

    I have followed all the procedures, checking cables, ports, powering off laptop and iPad, uninstalling and reinstalling iTunes. My iPad only says "syncing will start when HP computer is available".  I was able to sync before the latest Windows8 versi