Function Module Extraction from KONV Table taking lot of time for extractio

Hi
I have a requirement wherein i need to get records from KONV Table (Conditions (Transaction Data) ). i need the data corresponding to Application (KAPPL) = 'F'.
For this i had written one function module but it is taking lot of time (@ 2.5 hrs) for fetching records as there are large number of records in KONV Table.
I am pasting the Function Module code for reference.
<b>kindly guide me as to how the extraction performance can be improved.</b>
<b>Function Module Code:</b>
FUNCTION ZBW_SHPMNT_COND.
""Local interface:
*"  IMPORTING
*"     VALUE(I_REQUNR) TYPE  SBIWA_S_INTERFACE-REQUNR
*"     VALUE(I_ISOURCE) TYPE  SBIWA_S_INTERFACE-ISOURCE OPTIONAL
*"     VALUE(I_MAXSIZE) TYPE  SBIWA_S_INTERFACE-MAXSIZE OPTIONAL
*"     VALUE(I_INITFLAG) TYPE  SBIWA_S_INTERFACE-INITFLAG OPTIONAL
*"     VALUE(I_UPDMODE) TYPE  SBIWA_S_INTERFACE-UPDMODE OPTIONAL
*"     VALUE(I_DATAPAKID) TYPE  SBIWA_S_INTERFACE-DATAPAKID OPTIONAL
*"     VALUE(I_PRIVATE_MODE) OPTIONAL
*"     VALUE(I_CALLMODE) LIKE  ROARCHD200-CALLMODE OPTIONAL
*"  TABLES
*"      I_T_SELECT TYPE  SBIWA_T_SELECT OPTIONAL
*"      I_T_FIELDS TYPE  SBIWA_T_FIELDS OPTIONAL
*"      E_T_DATA STRUCTURE  ZBW_SHPMNT_COND OPTIONAL
*"      E_T_SOURCE_STRUCTURE_NAME OPTIONAL
*"  EXCEPTIONS
*"      NO_MORE_DATA
*"      ERROR_PASSED_TO_MESS_HANDLER
The input parameter I_DATAPAKID is not supported yet !
  TABLES: KONV.
Auxiliary Selection criteria structure
  DATA: l_s_select TYPE sbiwa_s_select.
Maximum number of lines for DB table
  STATICS: l_maxsize TYPE sbiwa_s_interface-maxsize.
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.
Select ranges
  RANGES: L_R_KNUMV  FOR KONV-KNUMV,
          L_R_KSCHL  FOR KONV-KSCHL,
          L_R_KDATU  FOR KONV-KDATU.
Declaring internal tables
DATA : I_KONV LIKE KONV OCCURS 0 WITH HEADER LINE.
  DATA : Begin of I_KONV occurs 0,
         MANDT LIKE konv-mandt,
         KNUMV LIKE konv-knumv,
         KPOSN LIKE konv-kposn,
         STUNR LIKE konv-stunr,
         ZAEHK LIKE konv-zaehk,
         KAPPL LIKE konv-kappl,
         KSCHL LIKE konv-kschl,
         KDATU LIKE konv-kdatu,
         KBETR LIKE konv-kbetr,
         WAERS LIKE konv-waers,
         END OF I_KONV.
Initialization mode (first call by SAPI) or data transfer mode
(following calls) ?
  IF i_initflag = sbiwa_c_flag_on.
Initialization: check input parameters
                buffer input parameters
                prepare data selection
The input parameter I_DATAPAKID is not supported yet !
Invalid second initialization call -> error exit
    IF NOT g_flag_interface_initialized IS INITIAL.
      IF
        1 = 2.
        MESSAGE e008(r3).
      ENDIF.
      log_write 'E'                    "message type
                'R3'                   "message class
                '008'                  "message number
                ' '                    "message variable 1
                ' '.                   "message variable 2
      RAISE error_passed_to_mess_handler.
    ENDIF.
Check InfoSource validity
    CASE i_isource.
      WHEN 'X'.
     WHEN 'Y'.
     WHEN 'Z'.
      WHEN OTHERS.
       IF 1 = 2. MESSAGE e009(r3). ENDIF.
       log_write 'E'                  "message type
                 'R3'                 "message class
                 '009'                "message number
                 i_isource            "message variable 1
                 ' '.                 "message variable 2
       RAISE error_passed_to_mess_handler.
    ENDCASE.
Check for supported update mode
    CASE i_updmode.
For full upload
      WHEN 'F'.
      WHEN 'D'.
      WHEN OTHERS.
       IF 1 = 2. MESSAGE e011(r3). ENDIF.
       log_write 'E'                  "message type
                 'R3'                 "message class
                 '011'                "message number
                 i_updmode            "message variable 1
                 ' '.                 "message variable 2
       RAISE error_passed_to_mess_handler.
    ENDCASE.
    APPEND LINES OF i_t_select TO g_t_select.
Fill parameter buffer for data extraction calls
    g_s_interface-requnr    = i_requnr.
    g_s_interface-isource   = i_isource.
    g_s_interface-maxsize   = i_maxsize.
    g_s_interface-initflag  = i_initflag.
    g_s_interface-updmode   = i_updmode.
    g_s_interface-datapakid = i_datapakid.
    g_flag_interface_initialized = sbiwa_c_flag_on.
Fill field list table for an optimized select statement
(in case that there is no 1:1 relation between InfoSource fields
and database table fields this may be far from beeing trivial)
    APPEND LINES OF i_t_fields TO g_t_fields.
Interpretation of date selection for generic extraktion
   CALL FUNCTION 'RSA3_DATE_RANGE_CONVERT'
     TABLES
       i_t_select = g_t_select.
  ELSE.                 "Initialization mode or data extraction ?
   CASE g_s_interface-updmode.
     WHEN 'F' OR 'C' OR 'I'.
First data package -> OPEN CURSOR
    IF g_counter_datapakid = 0.
   L_MAXSIZE = G_S_INTERFACE-MAXSIZE.
      LOOP AT g_t_select INTO l_s_select WHERE fieldnm = 'KNUMV'.
        MOVE-CORRESPONDING l_s_select TO l_r_knumv.
        APPEND l_r_knumv.
      ENDLOOP.
      LOOP AT g_t_select INTO l_s_select WHERE fieldnm = 'KSCHL'.
        MOVE-CORRESPONDING l_s_select TO l_r_kschl.
        APPEND l_r_kschl.
      ENDLOOP.
      Loop AT g_t_select INTO l_s_select WHERE fieldnm = 'KDATU'.
        MOVE-CORRESPONDING l_s_select TO l_r_kdatu.
        APPEND l_r_kdatu.
      ENDLOOP.
*In case of full upload
Fill field list table for an optimized select statement
(in case that there is no 1:1 relation between InfoSource fields
and database table fields this may be far from beeing trivial)
   APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.
      OPEN CURSOR G_CURSOR FOR
        SELECT MANDT
               KNUMV
               KPOSN
               STUNR
               ZAEHK
               KAPPL
               KSCHL
               KDATU
               KBETR
               WAERS
        FROM   KONV
        WHERE KNUMV IN l_r_knumv
        AND   KSCHL IN l_r_kschl
        AND   KDATU IN l_r_kdatu
        AND   KAPPL EQ 'F'.
    ENDIF.
    Refresh I_KONV.
    FETCH NEXT CURSOR G_CURSOR
               APPENDING CORRESPONDING FIELDS OF TABLE I_KONV
               PACKAGE SIZE S_S_IF-MAXSIZE.
    IF SY-SUBRC <> 0.
      CLOSE CURSOR G_CURSOR.
      RAISE NO_MORE_DATA.
    ENDIF.
    LOOP AT I_KONV.
     IF I_KONV-KAPPL EQ 'F'.
      CLEAR :E_T_DATA.
      E_T_DATA-MANDT = I_KONV-MANDT.
      E_T_DATA-KNUMV = I_KONV-KNUMV.
      E_T_DATA-KPOSN = I_KONV-KPOSN.
      E_T_DATA-STUNR = I_KONV-STUNR.
      E_T_DATA-ZAEHK = I_KONV-ZAEHK.
      E_T_DATA-KAPPL = I_KONV-KAPPL.
      E_T_DATA-KSCHL = I_KONV-KSCHL.
      E_T_DATA-KDATU = I_KONV-KDATU.
      E_T_DATA-KBETR = I_KONV-KBETR.
      E_T_DATA-WAERS = I_KONV-WAERS.
      APPEND E_T_DATA.
   ENDIF.
    ENDLOOP.
    g_counter_datapakid = g_counter_datapakid + 1.
  ENDIF.
ENDFUNCTION.
Thanks in Advance
Regards
Swapnil.

Hi,
one option to investigate is to select the data with a condition on KNUMV (primary IDX).
Since shipment costs are store in VFKP I would investigate if all your F condition records are used in this table (field VFKP-KNUMV).
If this is the case then something like
SELECT *
FROM KONV
WHERE KNUMV IN (SELECT DISTINCT KNUMV FROM VFKP)
or
SELECT DISTINCT KNUMV
INTO CORRESPONDING FIELD OF <itab>
FROM VFKP
and then
SELECT *
FROM KONV
FOR ALL ENTRIES IN <itab>
WHERE...
will definitively speed it up.
hope this helps....
Olivier

Similar Messages

  • Program is taking lot of time for execution

    Hi all,
    TYPES: BEGIN OF TY_MARA,
           MATNR       TYPE  MATNR,         " Material Number
           ZZBASE_CODE TYPE  ZBASE_CODE,    " Base Code
           END OF TY_MARA,
           BEGIN OF TY_MAKT,
           MATNR       TYPE  MATNR,         " Material
           MAKTX       TYPE  MAKTX,         " Material Description
           END OF TY_MAKT,
           BEGIN OF TY_MARC,
           MATNR       TYPE  MATNR ,        " Material Number
           WERKS       TYPE  WERKS_D,      " Plant
           END OF TY_MARC,
           BEGIN OF TY_QMAT,
           MATNR        TYPE  MATNR,         " Material Number
           ART           TYPE  QPART,         " Inspection Type
           END OF TY_QMAT,
           BEGIN OF TY_MAPL,
           MATNR        TYPE  MATNR,        " Material
           PLNTY        TYPE  PLNTY,        " Task List Type
           END OF TY_MAPL,
           BEGIN OF TY_PLKO,
           PLNTY          TYPE     PLNTY,         " Task List Type
           VERWE             TYPE     PLN_VERWE,     "     Task list usage
           END OF TY_PLKO,
           BEGIN OF TY_KLAH,
           CLASS          TYPE    KLASSE_D,       "     Class Number
           END OF TY_KLAH,
           BEGIN OF TY_FINAL,
           MATNR          TYPE    MATNR,          " Material Number
           MAKTX          TYPE    MAKTX,          " Material Description
           ZZBASE_CODE    TYPE    ZBASE_CODE,     " Base Code
           WERKS          TYPE    WERKS_D,        " Plant
           CLASS          TYPE    KLASSE_D,       "     Class Number
           ART             TYPE    QPART,           " Inspection Type
           VERWE             TYPE    PLN_VERWE,       " Task list usage
           MESSAGE        TYPE    STRING,          " Message
           END OF TY_FINAL.
    DATA: I_MARA  TYPE  STANDARD TABLE OF TY_MARA  ,
          I_MAKT  TYPE  STANDARD TABLE OF TY_MAKT  ,
          I_MARC  TYPE  STANDARD TABLE OF TY_MARC  ,
          I_QMAT  TYPE  STANDARD TABLE OF TY_QMAT  ,
          I_MAPL  TYPE  STANDARD TABLE OF TY_MAPL  ,
          I_PLKO  TYPE  STANDARD TABLE OF TY_PLKO  ,
          I_KLAH  TYPE  STANDARD TABLE OF TY_KLAH  ,
          I_FINAL TYPE  STANDARD TABLE OF TY_FINAL ,
          WA_MARA  TYPE  TY_MARA,
          WA_MAKT  TYPE  TY_MAKT,
          WA_MARC  TYPE  TY_MARC,
          WA_QMAT  TYPE  TY_QMAT,
          WA_MAPL  TYPE  TY_MAPL,
          WA_PLKO  TYPE  TY_PLKO,
          WA_KLAH  TYPE  TY_KLAH,
          WA_FINAL TYPE  TY_FINAL.
    DATA: V_MTART         TYPE    MARA-MTART,
          V_MATNR         TYPE    MARA-MATNR,
          V_ZZBASE_CODE   TYPE    MARA-ZZBASE_CODE,
          V_WERKS         TYPE    T001W-WERKS,
          V_BESKZ         TYPE    MARC-BESKZ.
    *selection-screen
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_MTART    FOR V_MTART DEFAULT 'halb' TO 'zraw',
                    S_MATNR    FOR V_MATNR,
                    S_ZZBASE   FOR V_ZZBASE_CODE,
                    S_WERKS    FOR V_WERKS OBLIGATORY,
                    S_BESKZ    FOR V_BESKZ.
    SELECTION-SCREEN END OF BLOCK B1.
    START-OF-SELECTION.
      SELECT MATNR
             ZZBASE_CODE
             FROM  MARA INTO TABLE I_MARA
             WHERE MTART IN S_MTART       "Material Type
             AND   MATNR IN S_MATNR        "Material
             AND   ZZBASE_CODE IN S_ZZBASE."Base Code
    IF NOT I_MARA IS INITIAL.
      SELECT MATNR
             MAKTX
             FROM MAKT INTO TABLE I_MAKT FOR ALL ENTRIES IN I_MARA
             WHERE MATNR = I_MARA-MATNR.
    ENDIF.
    IF NOT I_MARA IS INITIAL.
      SELECT MATNR
             WERKS
             FROM MARC INTO TABLE I_MARC FOR ALL ENTRIES IN I_MARA
             WHERE MATNR = I_MARA-MATNR
             AND WERKS IN S_WERKS "plant
             AND BESKZ IN S_BESKZ."Procurement Type
    ENDIF.
    IF NOT I_MARA IS INITIAL.
      SELECT MATNR
             ART
             FROM QMAT INTO TABLE I_QMAT FOR ALL ENTRIES IN I_MARA
             WHERE MATNR = I_MARA-MATNR
             AND WERKS IN S_WERKS.
    ENDIF.
    IF NOT I_MARA IS INITIAL.
      SELECT MATNR
             PLNTY FROM MAPL INTO TABLE I_MAPL FOR ALL ENTRIES IN I_MARA
             WHERE MATNR = I_MARA-MATNR.
    ENDIF.
    IF NOT I_MAPL IS INITIAL.
      SELECT PLNTY
             VERWE
             FROM PLKO INTO TABLE I_PLKO FOR ALL ENTRIES IN I_MAPL
             WHERE PLNTY = I_MAPL-PLNTY.
      ENDIF.
      LOOP AT I_MARA INTO WA_MARA.
        CALL FUNCTION 'CLFC_BATCH_ALLOCATION_TO_CLASS'
          EXPORTING
            MATERIAL                  = WA_MARA-MATNR
           PLANT                     =  WA_MARC-WERKS
           CLASSTYPE                 =  '023'
      I_IGNORE_MATMASTER        = ' '
      I_BATCHES_ONLY            =
      I_IGNORE_BUFFER           = ' '
         IMPORTING
      CLASSTYPE                 =
           CLASS                     = WA_KLAH-CLASS
         EXCEPTIONS
           WRONG_FUNCTION_CALL       = 1
           NO_CLASS_FOUND            = 2
           NO_CLASSTYPE_FOUND        = 3
           OTHERS                    = 4 .
    *IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    APPEND WA_KLAH TO I_KLAH.
      ENDLOOP.
      LOOP AT I_MARA INTO WA_MARA.
        WA_FINAL-MATNR       = WA_MARA-MATNR.
        WA_FINAL-ZZBASE_CODE = WA_MARA-ZZBASE_CODE.
        APPEND WA_FINAL TO I_FINAL.
        SORT I_MAKT BY MATNR.
       READ TABLE I_MAKT INTO WA_MAKT WITH KEY MATNR = WA_MARA-MATNR BINARY
       SEARCH.
       IF SY-SUBRC EQ 0.
        WA_FINAL-MAKTX = WA_MAKT-MAKTX.
      ENDIF.
        APPEND WA_FINAL TO I_FINAL.
        SORT I_MARC BY MATNR.
       READ TABLE I_MARC INTO WA_MARC WITH KEY MATNR = WA_MARA-MATNR BINARY
       SEARCH.
       IF SY-SUBRC EQ 0.
        WA_FINAL-WERKS = WA_MARC-WERKS.
      ENDIF.
        APPEND WA_FINAL TO I_FINAL.
        SORT I_QMAT BY MATNR.
       READ TABLE I_QMAT INTO WA_MARC WITH KEY MATNR = WA_MARA-MATNR BINARY
       SEARCH.
       IF SY-SUBRC EQ 0.
        WA_FINAL-ART = WA_QMAT-ART.
    ENDIF.
        APPEND WA_FINAL TO I_FINAL.
    SORT I_MAPL BY MATNR.
    READ TABLE I_MAPL INTO WA_MAPL WITH KEY MATNR = WA_MARA-MATNR BINARY
    SEARCH.
    IF SY-SUBRC EQ 0.
    SORT I_PLKO BY PLNTY.
    READ TABLE I_PLKO INTO WA_PLKO WITH KEY PLNTY = WA_MAPL-PLNTY BINARY
    SEARCH.
    ENDIF.
    WA_FINAL-VERWE = WA_PLKO-VERWE.
    APPEND WA_FINAL TO I_FINAL.
    ENDLOOP.
    LOOP AT I_KLAH INTO WA_KLAH.
    WA_FINAL-CLASS = WA_KLAH-CLASS.
    APPEND WA_FINAL TO I_FINAL.
    ENDLOOP.
    LOOP AT I_FINAL INTO WA_FINAL.
    WRITE:/ WA_FINAL-MATNR,
            WA_FINAL-MAKTX,
            WA_FINAL-ZZBASE_CODE,
            WA_FINAL-WERKS,
            WA_FINAL-CLASS,
            WA_FINAL-ART,
            WA_FINAL-VERWE.
    ENDLOOP.
    This is my program. it is giving out put.but it is taking lot of time for execution. what might be the porblem.pls let me know.
    Thanks,

    Hi Mythily,
    Try the following code.
    TYPES: BEGIN OF ty_mara,
             matnr TYPE matnr, " Material Number
             zzbase_code TYPE zbase_code, " Base Code
           END OF ty_mara,
           BEGIN OF ty_makt,
             matnr TYPE matnr, " Material
             maktx TYPE maktx, " Material Description
           END OF ty_makt,
           BEGIN OF ty_marc,
             matnr TYPE matnr , " Material Number
             werks TYPE werks_d, " Plant
           END OF ty_marc,
           BEGIN OF ty_qmat,
             art   TYPE qpart  , " Inspection Type
             matnr TYPE matnr  , " Material Number
             werks TYPE werks_d, "Plant
           END OF ty_qmat,
           BEGIN OF ty_mapl,
             matnr TYPE matnr    , " Material
             werks TYPE werks_d  , "Plant
             plnty TYPE plnty    , " Task List Type
             plnnr TYPE plnnr    , " Key for Task List Group
             plnal TYPE plnal    , " Group Counter
             zkriz TYPE dzkriz   , " Counter for additional criteria
             zaehl TYPE cim_count, " Internal counter
           END OF ty_mapl,
           BEGIN OF ty_plko,
             plnty TYPE plnty    , " Task List Type
             plnnr TYPE plnnr    , " Key for Task List Group
             plnal TYPE plnal    , " Group Counter
             zaehl TYPE cim_count, " Internal counter
             verwe TYPE pln_verwe, " Task list usage
           END OF ty_plko,
           BEGIN OF ty_klah,
             class TYPE klasse_d, " Class Number
           END OF ty_klah,
           BEGIN OF ty_final,
             matnr TYPE matnr, " Material Number
             maktx TYPE maktx, " Material Description
             zzbase_code TYPE zbase_code, " Base Code
             werks TYPE werks_d, " Plant
             class TYPE klasse_d, " Class Number
             art TYPE qpart, " Inspection Type
             verwe TYPE pln_verwe, " Task list usage
             message TYPE string, " Message
           END OF ty_final.
    DATA: i_mara     TYPE STANDARD TABLE OF ty_mara ,
          i_makt     TYPE HASHED   TABLE OF ty_makt
            WITH UNIQUE KEY matnr,
          i_marc     TYPE SORTED   TABLE OF ty_marc
            WITH NON-UNIQUE KEY matnr,
          i_qmat     TYPE SORTED   TABLE OF ty_qmat
            WITH NON-UNIQUE KEY matnr werks,
          i_mapl     TYPE SORTED   TABLE OF ty_mapl
            WITH NON-UNIQUE KEY matnr werks,
          i_mapl_tmp TYPE STANDARD TABLE OF ty_mapl ,
          i_plko     TYPE SORTED   TABLE OF ty_plko
            WITH NON-UNIQUE KEY plnty
                                plnnr
                                plnal,
          i_final    TYPE STANDARD TABLE OF ty_final,
          wa_mara TYPE ty_mara,
          wa_makt TYPE ty_makt,
          wa_marc TYPE ty_marc,
          wa_qmat TYPE ty_qmat,
          wa_mapl TYPE ty_mapl,
          wa_plko TYPE ty_plko,
          wa_klah TYPE ty_klah,
          wa_final TYPE ty_final.
    DATA: v_mtart TYPE mara-mtart,
          v_matnr TYPE mara-matnr,
          v_zzbase_code TYPE mara-zzbase_code,
          v_werks TYPE t001w-werks,
          v_beskz TYPE marc-beskz.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_mtart FOR v_mtart DEFAULT 'halb' TO 'zraw',
                    s_matnr FOR v_matnr,
                    s_zzbase FOR v_zzbase_code,
                    s_werks FOR v_werks OBLIGATORY,
                    s_beskz FOR v_beskz.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      SELECT matnr
             zzbase_code
        FROM mara
        INTO TABLE i_mara
        WHERE mtart       IN s_mtart "Material Type
        AND   matnr       IN s_matnr. "Material
        AND   zzbase_code IN s_zzbase."Base Code
      IF NOT i_mara[] IS INITIAL.
        SELECT matnr
               maktx
          FROM makt
          INTO TABLE i_makt
          FOR ALL ENTRIES IN i_mara
          WHERE matnr EQ i_mara-matnr
          AND   spras EQ sy-langu.
        SELECT matnr
               werks
          FROM marc
          INTO TABLE i_marc
          FOR ALL ENTRIES IN i_mara
          WHERE matnr EQ i_mara-matnr
          AND   werks IN s_werks "plant
          AND   beskz IN s_beskz."Procurement Type
        IF sy-subrc EQ 0.
          SELECT art
                 matnr
                 werks
            FROM qmat
            INTO TABLE i_qmat
            FOR ALL ENTRIES IN i_marc
            WHERE matnr EQ i_marc-matnr
            AND   werks EQ i_marc-werks.
          SELECT matnr
                 werks
                 plnty
                 plnnr
                 plnal
                 zkriz
                 zaehl
            FROM mapl
            INTO TABLE i_mapl
            FOR ALL ENTRIES IN i_marc
            WHERE matnr EQ i_marc-matnr
            AND   werks EQ i_marc-werks.
          IF NOT i_mapl[] IS INITIAL.
            i_mapl_tmp[] = i_mapl[].
            SORT i_mapl_tmp BY plnty
                               plnnr
                               plnal.
            DELETE ADJACENT DUPLICATES FROM i_mapl_tmp
              COMPARING
                plnty
                plnnr
                plnal.
            SELECT plnty
                   plnnr
                   plnal
                   zaehl
                   verwe
              FROM plko
              INTO TABLE i_plko
              FOR ALL ENTRIES IN i_mapl_tmp
              WHERE plnty EQ i_mapl_tmp-plnty
              AND   plnnr EQ i_mapl_tmp-plnnr
              AND   plnal EQ i_mapl_tmp-plnal.
          ENDIF.
        ENDIF.
      ENDIF.
      LOOP AT i_mara INTO wa_mara.
        wa_final-matnr       = wa_mara-matnr.
        wa_final-zzbase_code = wa_mara-zzbase_code.
        READ TABLE i_makt INTO wa_makt
          WITH KEY matnr = wa_mara-matnr
          TRANSPORTING
            maktx.
        IF sy-subrc EQ 0.
          wa_final-maktx = wa_makt-maktx.
        ENDIF.
        REFRESH i_final.
        LOOP AT i_marc INTO wa_marc
          WHERE matnr EQ wa_mara-matnr.
          CLEAR wa_klah-class.
          CALL FUNCTION 'CLFC_BATCH_ALLOCATION_TO_CLASS'
            EXPORTING
              material            = wa_mara-matnr
              plant               = wa_marc-werks
              classtype           = '023'
            IMPORTING
              class               = wa_klah-class
            EXCEPTIONS
              wrong_function_call = 1
              no_class_found      = 2
              no_classtype_found  = 3
              OTHERS              = 4.
          IF sy-subrc EQ 0.
            wa_final-class = wa_klah-class.
          ENDIF.
          READ TABLE i_qmat
            WITH KEY matnr = wa_mara-matnr
                     werks = wa_marc-werks
                     TRANSPORTING NO FIELDS.
          IF sy-subrc EQ 0.
            LOOP AT i_qmat INTO wa_qmat
              WHERE matnr EQ wa_mara-matnr
              AND   werks EQ wa_marc-werks.
              wa_final-art = wa_qmat-art.
              READ TABLE i_mapl
                WITH KEY matnr = wa_marc-matnr
                         werks = wa_marc-werks
                         TRANSPORTING NO FIELDS.
              IF sy-subrc EQ 0.
                LOOP AT i_mapl INTO wa_mapl
                  WHERE matnr EQ wa_marc-matnr
                  AND   werks EQ wa_marc-werks.
                  LOOP AT i_plko INTO wa_plko
                    WHERE plnty EQ wa_mapl-plnty
                    AND   plnnr EQ wa_mapl-plnnr
                    AND   plnal EQ wa_mapl-plnal.
                    wa_final-verwe = wa_plko-verwe.
                    APPEND wa_final TO i_final.
                  ENDLOOP.
                ENDLOOP.
              ELSE.
                APPEND wa_final TO i_final.
              ENDIF.
            ENDLOOP.
          ELSE.
            LOOP AT i_mapl INTO wa_mapl
              WHERE matnr EQ wa_marc-matnr
              AND   werks EQ wa_marc-werks.
              LOOP AT i_plko INTO wa_plko
                WHERE plnty EQ wa_mapl-plnty
                AND   plnnr EQ wa_mapl-plnnr
                AND   plnal EQ wa_mapl-plnal.
                wa_final-verwe = wa_plko-verwe.
                APPEND wa_final TO i_final.
              ENDLOOP.
            ENDLOOP.
          ENDIF.
        ENDLOOP.
        CLEAR wa_final.
      ENDLOOP.
      LOOP AT i_final INTO wa_final.
        WRITE:/ wa_final-matnr      ,
                wa_final-maktx      ,
                wa_final-zzbase_code,
                wa_final-werks      ,
                wa_final-class      ,
                wa_final-art        ,
                wa_final-verwe      .
      ENDLOOP.

  • Taking lot of time for loading

    Hi,
      We are loading data from HR to BI. Connection between HR and BI has been done recently. When I am trying to load data from HR  to BI it taking lot of time--for example to load 5recs its taking 8hrs. Its same for every datasource. Should we change anything in settings to makes IDOCS work proper? Thanks

    You have to isolate the part that is taking the time.
    - Is R/3 extraction quick? (You can check with RSA3 and see how long does it take.)
    - If R/3 extraction is slow, then is the selection using an index? How many records are there in the table / view?
    - Is there a user exit? Is user exit slow?
    You can find out using monitor screen:
    - After R/3 extraction completed, how long did it take to insert into PSA?
    - How long did it take in the update rules?
    - How long did it take to activate?
    Once you isolate the problem area, post your findings here and someone will help you.

  • Background job is taking lot of time for processing the job.

    One background job - which is processing Idocs is processing a job for more than 2000+ seconds.. and completed tho.
    But this is happening for the past few days.. is there any way to trouble shoot, or find from any logs of this completed job, to find out why it was taking lot of time for processing.
    Can you please tell me the steps of analyzing / trouble shooting why it was taking lot of time daily.
    Regards,
    Satish.

    Hi Satish,
    Run DB stat from db13 it will improve the performance.
    Check number of idocs. You can send part by part, instead of sending huge data.
    Check SM58 logs
    Suman

  • Interface is taking lots of time for first time execution

    Hello all,
    I have one inbound interface in which i am updating T-code CO01 ,CO15 , MIGO and MB1A respectively
    depending upon the condition in the incoming file.
    When ever i run this interface for the first time it takes lots of time for execution, but when i run the same interface again with the same file it is taking half time of the first time execution.
    I am not able to understand why it is taking lots of time for first execution and after that execution time is redued very much with the same file
    Kindly help
    Thanks
    Sachin Yadav

    thank you santhosh for your reply..
    as this program is in Production system it it taking 3 to 4 hour to execute.
    Previously it was OK but from last 2 to 3 moths it is taking more time.
    when i debug the code it is working fine. I din't find any point at which it is taking more time.
    I am not aware about buffers and SAP memory. can you plz help
    Do you have any idea why this is happening.
    Or how can i rectify the problem?
    Thanks
    Sachin

  • Query from source table takes lots of time

    I have to load data from an Oracle table which has millions of records. The loading knowledge module I am using is 'lkm sql to oracle'.
    I see that the query from the source database takes lot of time and doing a full table scan where as it supposed to be using an index.
    I dont have any lkm with 'lkm oracle to oracle'. Some how I need to add a hint to this source query. How I can do this?

    This LKM is not indicated to large volume of data, try to use LKM Oracle to Oracle (DBLINK), see ODI KMs documentation for more information.
    Related to HINTS you can add this with KM options, see that some Oracle ODI11g new KMs already have some options to do it, so you can put the hint on interface options of KM or define the temp index on the interface

  • Delete operation on indexed table taking lot of time

    We are working on 10g R2. We have a script for archiving a table which upon copying into table (say Y a non indexed table); the pre-decided records from a table (say X indexed table).
    After inserting the records into Y the records are deleted from X. There are close to 50 million records to be archived this way.
    While testing the script in development instance for a million records, we find that on avoiding the delete operation the time taken for the script to execute is ~ 45 minutes which otherwise (including the delete operation) takes 2 hours.
    How can we reduce this overhead time.
    Dropping the index and recreating them is not an option!

    My method is logical if you are planing to migrate at least 90% of all data from X to Y. If so
    For the new X table you only need at most 10% of the size of the current X table ( At my previous post by saying "the same as" i did not mean data, i mean only DDL except storage). Moreover, after renaming X to X_ and copying "data not to be copied to Y" from X_ to X, you may drop unnecessary indexes from X_ to free up some space.

  • Select statement is taking lot of time for the first time Execution.?

    Hi Experts,
    I am facing the following issue. I am using one select statement to retrieve all the contracts from the table CACS_CTRTBU according to FOR ALL ENTRIES restriction.
    if p_lt_zcacs[] is not initial.
    SELECT
               appl ctrtbu_id version gpart
               busi_begin busi_end tech_begin tech_end
               flg_cancel_obj flg_cancel_vers int_title
             FROM cacs_ctrtbu INTO TABLE lt_cacs FOR ALL ENTRIES IN p_lt_zcacs
                                                    WHERE
                                                    appl EQ gv_appl
                                                    AND ctrtbu_id EQ p_lt_zcacs-ctrtbu_id
                                                    AND  ( flg_cancel_vers EQ '' OR version EQ '000000' )
                                                    AND flg_cancel_obj EQ ''
                                                    AND busi_begin LE p_busbegin
                                                    AND busi_end GT p_busbegin.
    endif.
    The WHERE condition is in order with the available Index. The index has  APPL,CTRTBU_ID,FLG_CANCEL_VERS and FLG_CANCEL_OBJ.
    The technical settings of table CACS_CTRTBU says that the "Buffering is not allowed"
    Now the problem is , for the first time execution of this select statement, with 1.5 lakh entries in P_LT_ZCACS table, the select statement takes 3 minutes.
    If I execute this select statement again, in another run with Exactly the same parameter values and number of entries in P_LT_ZCACS ( i.e 1.5 lakh entries), it gets executed in 3-4 seconds.
    What can be the issue in this case? Why first execution takes longer time?.. Or is there any way to modify the Select statemnt to get better performance.
    Thanks in advance
    Sreejith A P

    Hi,
    >
    sree jith wrote:
    > What can be the issue in this case? Why first execution takes longer time?..
    > Sreejith A P
    Sounds like caching or buffering in some layer down the i/o stack. Your first execution
    seems to do the "physical I/O" where your following executions can use the caches / buffers
    that are filled by your first exectution.
    >
    sree jith wrote:
    > Or is there any way to modify the Select statemnt to get better performance.
    > Sreejith A P
    If modifying your SELECTS statement or your indexes could help depends on your access details:
    does your internal table P_LT_ZCACS  contain duplicates?
    how do your indexes look like?
    how does your execution plan look like?
    what are your execution figures in ST05 - Statement Summary?
    (nr. of executions, records in total, total time, time per execuiton,  records per execution, time per record,...)
    Kind regards,
    Hermann

  • Analyze table taking lot of time

    HI,
    I am analyzing fact table. its taking almost 1 hour to. is there any solution for the same?
    i am using compute statistics.
    regards,
    sandeep

    Hi,
    Why not DBMS_STATS which collects stats in parallel so much faster then analyze command.I strongly recommand use DBMS_STATS in case of partition tables.Much faster, collects local and global stats both.
    Analyze cmd for partitioned table:--
    analyze table <schema>.<table> partition (<partition_name>) estimate statistics sample 5 percent;
    Use GATHER_SCHEMA_STATS for whole schema analysis .

  • Clarification on some reading: Datasource and Function Module extraction

    Hi,
    I found a link on Help.sap which explains how to create a function module and I have some questions after my review:
    It basically uses function module to read some filght data from the table SPFLI
    1.
    I got into this research since one of the methods for data extraction from R3/ECC to BW is through Function Modules.
    Why couldn't that extraction be based on a view of the table SPFLI.
    i.e. why is this complication of writing an ABAP code to achieve something which could be done with a DB view or table?
    2.
    Any example or scenario where you think a datasource could NOT be created based on a table, Database View or Sap Query and that it must be done with a Function Module?
    3.
    So, once the function module is successfully created; how to do create a Datasource based on this function modeule to take care of the delta's on the source data?
    4.
    There was a discussion about "remote function call" which I did not get completely. Will extracting data from R3/ECC to BI be regarded as "remote call"
    Thanks

    1. Why couldn't that extraction be based on a view of the table SPFLI. i.e. why is this complication of writing an ABAP code to achieve something which could be done with a DB view or table?
    A DataSource could have been created directly from table SPFLI. It was used as an example in the case of the document is my guess. There are some table types, however, that you cannot create a DataSource directly off of.
    2. Any example or scenario where you think a datasource could NOT be created based on a table, Database View or Sap Query and that it must be done with a Function Module?
    Pool/Cluster tables cannot be directly read and therefore must use a Function Module for extraction. Another reason for using a Function Module, even against a single table, is in the case that you have more than one field that you want to create a generic delta against. SAP delivers the capability in the application to set a generic delta on only one field within the DataSource. If there is more than one, say created on and changed on dates, a Function Module is require in order to enable that.
    3. So, once the function module is successfully created; how to do create a Datasource based on this function modeule to take care of the delta's on the source data?
    Go to tocde RSO2, enter the DataSource name, click on the Create button. In the next screen, there are three buttons toward the top to tell what is the source of the DataSource: 1) Extraction from View (default); 2) Extraction from Query; and 3) Extraction from Function Module. When you click on the Extraction from Function Module button, the View/Table field will gray out and the Function Module and Extraction Structure fields will un-gray.
    4. There was a discussion about "remote function call" which I did not get completely. Will extracting data from R3/ECC to BI be regarded as "remote call"
    I think that this is referring to a process whereby you create a remote-enabled Function Module on the source R3/ECC system and then create an ABAP program in BW that calls that remote-enabled Function Module. Basically, the ABAP program on BW would send some parameters through to the remote-enabled Function Module on R3/ECC. The Function Module would extract data into an internal table and then pass that internal table back through to the ABAP program in BW for further processing.
    Edited by: Dennis Scoville on Aug 20, 2009 8:18 AM

  • Function Module: how to setting table import parameter

    hi, i'm developing a function module. i create a TABLES where it will allow multiple variables  IMPORT from user input to this function module. the tables i set as OPTIONAL and decribed as below.
    PSPID     PS_PSPID     CHAR     24
    POSID     PS_POSID     CHAR     24
    AUFNR     AUFNR     CHAR     12
    PSY     J_STATUS     CHAR     5
    PUS     J_STATUS     CHAR     5
    in my source code, i done a select statement to process the IMPORT input . the problems i face,for the PSY and PUS  input,  if the one or both input is BLANK, NO RESULT will display. What i'm try to do , if input one or both  is BLANK, it wil neglect the input and return as ALL RESULT (return result oir all status for input pspis / posid / aufnr)  . attached the select statement. thank you
    itparm[] = objparm[].
    select
        a~pspnr a~stspr a~objnr a~pspid
        b~psphi b~objnr as wobjnr b~posid
        c~aufnr c~objnr as nobjnr c~pspel
        d~objnr as jeobjnr d~inact d~stat
        e~objnr as jcobjnr e~udate e~usnam e~utime e~stat as jcstat e~inact as jcinact
        f~istat as syistat
        f~txt04 as sytxt04
        f~spras
        g~estat as usestat
        g~txt04 as ustxt04
        into corresponding fields of table itobj
        from proj as a
        inner join prps as b on a~pspnr = b~psphi
        inner join aufk as c on b~pspnr = c~pspel
        inner join jest as d on c~objnr = d~objnr
        inner join jcds as e on d~objnr = e~objnr
                             and d~stat = e~stat
        inner join tj02t as f on e~stat = f~istat
        inner join tj30t as g on a~stspr = g~stsma
        for all entries in itparm
        where ( a~pspid = itparm-pspid
        or b~posid = itparm-posid
        or c~aufnr = itparm-aufnr )
       and ( f~istat = itparm-PSY and g~estat = itparm-PUS ).

    Thanks for your quick reply. actually the data will be somehing like this. since i developed a function module, i keep the import parameter in a table.
    PSPID     PS_PSPID     CHAR     24
    POSID     PS_POSID     CHAR     24
    AUFNR     AUFNR         CHAR     12
    PSY       J_STATUS     CHAR     5
    PUS      J_STATUS     CHAR     5
    the example data will be in OTPARM internal table
    PSPID              POSID          AUFNR     PSY     PUS
    aa-aa-aa         a1                                  I001
    bb-bb-bb                              b1                        E009
    cc-cc-cc
    i'll store  this into an internal table. from the data. it can be seen there a BLANK input. so the blank input should not be included into WHERE connditions. that why in the previous solution, i use SELECT inside LOOP because every line of the IMPORT tables will be generated with different WHERE conditions. i tried to do something like this:
    PSPID         POSID     AUFNR     PSY     PUS        cond_syx
    aa-aa-aa     a1                           I001                  if proj~pspid = itparm-pspid and prps~posid = itparm~posid and ....
    bb-bb-bb                   b1                         E009     if proj~pspid = itparm-pspid and aufk~aufnr = itparm~paufnr and ....
    cc-cc-cc                                                             if proj~pspid = itparm-pspid
    and implement with FOR ALL ENTERIES, but at the WHERE conditions i failed to put the CONF_SYX. please comment and give opinions. Thanks you very much.

  • How to save function module in a custom table..

    hi experts,
    i need your help, how can i save a customize function module into a custom table?is this possible?
    i need your reply ASAP..
    thanks,
    mau

    Hi,
    pls chk this links:
    Generic extraction via function module blog siggi
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    Generic extraction via function module
    BW genenric delta not TABLE but VIEW
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/801ee8454211d189710000e8322d00/frameset.htm
    Re: how to use a function module
    http://help.sap.com/saphelp_nw70/helpdata/en/2a/f9ff95493111d182b70000e829fbfe/frameset.htm
    **pls assign points,if link is useful*
    Regards
    CSM Reddy

  • Can generic function module extractions possible with CRM data sources.

    Hi Friends,
    can generic function module extractions possible with CRM data sources.
    90% extractions are generic function module extractions.
    How is it possible without BW adapters..
    It's very urgent ...Please.
    Thanks,
    Basava Raju

    Hi Madhu,
       Just curious ... if you already have a generic FM extractor then just go into it and find out where it is reading the data from. If its reading data from the CRM system then thre is no need for any BW adapter ... just in case you need any ABAP help ... post here ... I may be of use to you.
    Best regards,
    Kazmi

  • Is it possible to call custom designed RFC function module, apart from BAPI

    Hi Friends,
    1.     Is it possible to call custom designed RFC function module, apart from BAPI.
    2.     Why we call it Adaptive RFC layer, Since every time the JCO layer updated with SAP, Why can’t be dynamic.
    Thanx for Ur time.
    Cheers,
    Sam

    Also check <a href="http://help.sap.com/saphelp_nw04/helpdata/en/41/38bc8f813719488ddc9d9b21251ec3/frameset.htm">here</a> for more information on aRFC. Here you can find why it is called adaptive.
    Regards,
    Christophe

  • RFC remote function module call from XI

    hi
    I am trying to call a remote function module directly from XI which is not a bespoke module.
    And i am getting the following error:
    com.sap.aii.af.ra.ms.api.DeliveryException: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: failed to parse BAPI response due to: com.sap.aii.af.rfc.util.bapi.BapiException: Parameter with name RETURN not found.
    Please help me in this.
    Thanks in advance.

    Hi Naina,
    Normally RFC are synchronous, they do have return parameter as export parameter.
    If return parameter is missing then , you can create Wrapper RFC.
    Wrapper RFC:
    It is nothing but you just  create BAPI in SE37 transaction with Return parameter as export parameter and make it remote enabled by clicking on Radio button.
    Under source code, CALL BAPI which XI has to call.
    Thats it!
    I hope this helps.
    Let me know if any help required.

Maybe you are looking for

  • I'am experiencing inimaginable problems with my thunderbird under Windows 8.1 platform, can you fix it???

    I was wondering about all the crashing problems of my thunderbird performnance and when I finally when straight to Task Manager I found out it is a 32 bit version. The thing is... when downloading it right from the site, it wouldn't give you the chan

  • Analysing waveform for digital values stored in a file

    i have certain digitals values obtained in a file in .txt format. i have to obtain a waveform by giving the input as these digital values in that file. I have programmed for array input manually. But the waveform analysis should be made such that it

  • MobileMe Gallery display Album in Mosaic by default

    How can i setup my MobileMe gallery i will send to be viewed in Mosaic by default ???? Thanks Gian

  • Quicktime and fcp dont recognize a .mpg file?

    im running fcp 5.0.4 with quicktime 7.0.3, i have a file that i made with a pinnacle system on a pc. i got it from another one of my hard drives, and it is rendered from the pc as a MPEG type of file. the extension is .mpg when i play it was quicktim

  • Small screen displays

    Why is everything on the screen so SMALL? This Mac is my first one and I don't like it very much. Microsoft gives one an Accessibility screen where you can size the text on the screen. I have searched for this in the book, but nothing comes up. Anyon