Hi how to improve performence of this program

Hi all,
How to improve the performence of this program.....................
REPORT z03_gil010 NO STANDARD PAGE HEADING LINE-SIZE 130.
                             INCLUDE                                 *
INCLUDE: z00_bci010.                   " Gestion des anomalies.
                      Déclaration des données                        *
                   Tables de la bases de données                     *
TABLES:
        ekpo,        " Poste document d'achat.
        lfa1,        " Base fournisseurs (généralités).
        marc,        " Données division de l'article.
        z03_bw_cmp1,
        eord,        "Répertoire des sources appro. Achats
        eina,        "Fiche infos-achats - données générales
        t024,        "Groupes d'acheteurs
        tvarv.                                              "FAE17345+
                   Déclaration des données internes                  *
Déclaration de la table interne qui permet de recuperer les mois.
DATA: BEGIN OF itb_months OCCURS 12.
        INCLUDE STRUCTURE t247.
DATA: END OF itb_months.
Table pour récupération d'infos sur les divisions
DATA: BEGIN OF itb_t001w OCCURS 0,
        werks LIKE t001w-werks,
        fabkl LIKE t001w-fabkl," Clé du calendrier d'entreprise
      END OF itb_t001w.
Déclaration de la table interne contenant les infos sur l'adresse du
fournisseur.
DATA: BEGIN OF itb_adresse OCCURS 0,
        lifnr LIKE lfa1-lifnr,           " Numéro de compte fournisseur.
        name1 LIKE lfa1-name1,                              " Nom 1.
        name2 LIKE lfa1-name2,                              " Nom 2.
        name3 LIKE lfa1-name3,                              " Nom 3.
        name4 LIKE lfa1-name4,                              " Nom 4.
        stras LIKE lfa1-stras,           " N° de rue et nom de la rue.
        pstlz LIKE lfa1-pstlz,           " Code postal.
        ort01 LIKE lfa1-ort01,           " Localité.
        pfach LIKE lfa1-pfach,           " Boîte postale.
        pstl2 LIKE lfa1-pstl2,           " Code de la boîte postale.
        land1 LIKE lfa1-land1,           " Clé de pays.
        landx LIKE t005t-landx,          " Pays.
        spras LIKE lfa1-spras,           " Code langue
END OF itb_adresse.
Déclaration d'une table interne pour les informations sur les
prévisions de commande.
DATA: BEGIN OF itb_prev_cde OCCURS 0,
        werks LIKE marc-werks,            " Division
        idnlf LIKE eina-idnlf,            " ADDsde ref article frn
        lifnr LIKE eord-lifnr,            " N° fournisseur.
        ekgrp LIKE marc-ekgrp,            " Groupe d'acheteurs
        dispo LIKE marc-dispo,            " Code gestionnaire MRP
        matnr LIKE eord-matnr,            " Article.
        maktx LIKE makt-maktx,            " Désignation article.
        bstmi LIKE marc-bstmi,            " Quantité de commande.
        men00 LIKE plaf-gsmng,            " Quantité du mois en cours M.
        men01 LIKE plaf-gsmng,            " Quantité pour le mois M+1.
        men02 LIKE plaf-gsmng,            " Quantité pour le mois M+2.
        men03 LIKE plaf-gsmng,            " Quantité pour le mois M+3.
        men04 LIKE plaf-gsmng,            " Quantité pour le mois M+4.
        men05 LIKE plaf-gsmng,            " Quantité pour le mois M+5.
        men06 LIKE plaf-gsmng.            " Quantité pour le mois M+6.
DATA: END OF itb_prev_cde.
Structure de travail pour les commandes convernant les PFC
DATA str_pca_pfc  LIKE itb_prev_cde.
*add sde
DATA str_eord_pfc  LIKE itb_prev_cde.
Structure de travail pour les prévisons PFC
DATA str_prev_pfc LIKE itb_prev_cde.
Déclaration d'une table interne pour les informations sur le
portefeuille des commandes d'achat.
DATA: BEGIN OF itb_pca OCCURS 0,
        werks LIKE ekpo-werks,    " Division
        idnlf LIKE eina-idnlf,     " ADDsde ref article frn
        lifnr LIKE eord-lifnr,    " N° fournisseur.
        ekgrp LIKE marc-ekgrp,    " Groupe d'acheteurs
        dispo LIKE marc-dispo,    " Code gestionnaire MRP
        matnr LIKE eord-matnr,    " Article.
        maktx LIKE makt-maktx,    " Désignation article.
        ebeln LIKE ekes-ebeln,    " Numéro du document d'achat.
        ebelp LIKE ekes-ebelp,    " Numéro de poste du document d'achat.
        slfdt LIKE eket-slfdt,    " Date de livraison statistique
        eindt LIKE ekes-eindt,    " Date de livraison indiquée dans la
                                  " confirmation de la cde.
        menge LIKE ekes-menge,    " Quantité indiquée dans la confirma-
                                  " tion de la commande.
        attdu LIKE eket-wemng,    " Portefeuille fournisseur.
        netpr LIKE ekpo-brtwr,    " Prix net du document d'achat dans
                                  " la devise du document.
        rtard TYPE i,             " Retard en jours ouvres.
        wemng LIKE eket-wemng,    " Quantité de l'entrée de marchandise.
        bldat LIKE mkpf-bldat,    " Date inscrite sur la pièce/sur le
                                  " document.
        qtran LIKE ekes-menge,    " Quantité en transit.
        dtran LIKE ekes-eindt.    " Date du dernier avis de transit.
DATA: END OF itb_pca.
DATA: w_i TYPE i,                "Compteur
      w_i_char(1) TYPE c,        "Texte pour récupérer compteur
      w_nm_zone(20) TYPE c,      "Nom zone pour assign au field-symbols
      w_nb_j TYPE i,             "Nb de jours ouvrés jusqu'à fin mois
      w_nb_j_tot TYPE i.         "Nb de jours ouvrés du mois
FIELD-SYMBOLS:       TYPE ANY.
Déclaration d'une table contenant les fiches info achat.
DATA: BEGIN OF itb_eina OCCURS 0,
        matnr LIKE eina-matnr,
        lifnr LIKE eina-lifnr,
        idfnl LIKE eina-idnlf.
DATA: END OF itb_eina.
Déclaration d'une table contenant les infos groupe acheteur.
*DATA: BEGIN OF itb_t024 OCCURS 0,
       ekgrp LIKE t024-ekgrp,
       eknam LIKE t024-eknam,
       ektel LIKE t024-ektel,
       telfx LIKE t024-telfx.
*DATA: END OF itb_t024.
Déclaration d'une table pour le transfert du fichier.
DATA: BEGIN OF itb_transfert OCCURS 0,
        col00(8),                 "division
        col00bis(20),             "Reference article
        col01(18),                "No article
        col02(45),                "libelle article
        col021(17),               "Groupe acheteur
        col022(13),               "gestionnaire
        col03(17),                "qte commandée ou No de commande
        col04(13),                "Mois 1 ou No poste cde
        col05(20),                "Mois 2 ou délai initial
        col06(33),                "Mois 3 ou délai négocié
        col07(13),                "Mois 4 ou qté cdée
        col08(13),                "Mois 5 ou qté attendue
        col09(13),                "Mois 6 ou Montant attendu
        col10(13),                "Mois 7 ou retard
        col11(13),                "qte partielle livree
        col12(13),                "date livraison partielle
        col13(13),                "qté en transit
        col14(13).                "date
DATA: END OF itb_transfert.
Déclaration d'une table contenant la liste des fournisseurs.
DATA: BEGIN OF itb_lifnr OCCURS 0,
        werks LIKE marc-werks,
        idfnl LIKE eina-idnlf,
        lifnr LIKE eord-lifnr,
        ekgrp LIKE marc-ekgrp,
        spras LIKE lfa1-spras,
        eknam LIKE t024-eknam,
        ektel LIKE t024-ektel,
        telfx LIKE t024-telfx.
DATA: END OF itb_lifnr.
Déclaration d'une structure pour la selection dans la table MSEG.
DATA : BEGIN OF itb_mseg OCCURS 0,
         mblnr LIKE mseg-mblnr,
         mjahr LIKE mseg-mjahr,
         ebeln LIKE mseg-ebeln,
         ebelp LIKE mseg-ebelp,
       END OF itb_mseg.
déclaration d'une structure pour la selection dans EKPO.
DATA : BEGIN OF itb_ekpo OCCURS 0,
         lifnr LIKE ekko-lifnr,
         ebeln LIKE ekpo-ebeln,
         ebelp LIKE ekpo-ebelp,
         menge LIKE ekpo-menge,
         bpumz LIKE ekpo-bpumz,
         bpumn LIKE ekpo-bpumn,
         matnr LIKE ekpo-matnr,
         werks LIKE ekpo-werks,
         netpr LIKE ekpo-netpr,
         peinh LIKE ekpo-peinh,  "Base de prix FAE17345+
         ekgrp LIKE ekko-ekgrp,   "AFT++
         dispo LIKE marc-dispo,   "AFT++
       END OF itb_ekpo.
déclaration d'une structure pour la selection dans EKPO.
DATA : BEGIN OF itb_ekko OCCURS 0,
         ebeln LIKE ekko-ebeln,
         lifnr LIKE ekko-lifnr,
         spras LIKE ekko-spras,
       END OF itb_ekko.
déclaration d'une structure pour la selection dans EKES.
DATA : BEGIN OF itb_ekes OCCURS 0,
         ebeln LIKE eket-ebeln,
         ebelp LIKE eket-ebelp,
         ebtyp LIKE ekes-ebtyp,
         eindt LIKE ekes-eindt,
         menge LIKE ekes-menge,
         dabmg LIKE ekes-dabmg,
         etens LIKE ekes-etens,
       END OF itb_ekes.
déclaration d'une structure pour la selection dans EKET
DATA : BEGIN OF itb_eket OCCURS 0,
         ebeln LIKE eket-ebeln,
         ebelp LIKE eket-ebelp,
         menge LIKE eket-menge,
         wemng LIKE eket-wemng,
         eindt LIKE eket-eindt,
         slfdt LIKE eket-slfdt,
       END OF itb_eket.
déclaration d'une structure pour la selection dans MKPF.
DATA : BEGIN OF itb_mkpf OCCURS 0,
         mblnr LIKE mkpf-mblnr,
         mjahr LIKE mkpf-mjahr,
         bldat LIKE mkpf-bldat,
       END OF itb_mkpf.
Déclaration d'une structure pour la sélection dans EORD.
DATA : BEGIN OF itb_eord OCCURS 0,
         matnr LIKE eord-matnr,
         werks LIKE eord-werks,
         lifnr LIKE eord-lifnr,
         ekgrp LIKE marc-ekgrp,
         dispo LIKE marc-dispo,                             "DE3K924352
         disls LIKE marc-disls,
         bstfe LIKE marc-bstfe,
         bstrf LIKE marc-bstrf,
         bstmi LIKE marc-bstmi,
         bstma LIKE marc-bstma,
       END OF itb_eord.
DATA : BEGIN OF itb_eordw OCCURS 0.
        INCLUDE STRUCTURE itb_eord.
DATA : END OF itb_eordw.
Déclaration d'une structure pour la sélection dans MAKT.
DATA : BEGIN OF itb_makt OCCURS 0,
         matnr LIKE makt-matnr,
         spras LIKE makt-spras,
         maktx LIKE makt-maktx,
       END OF itb_makt.
Déclaration d'une structure pour la sélection dans EBAN.
DATA : BEGIN OF itb_eban OCCURS 0,
         matnr LIKE eban-matnr,
         werks LIKE eban-werks,
         flief LIKE eban-flief,
         lfdat LIKE eban-lfdat,
         menge LIKE eban-menge,
         bsmng LIKE eban-bsmng,
         webaz LIKE eban-webaz,
         ekgrp LIKE eban-ekgrp,
         ebeln LIKE eban-ebeln,
         banfn LIKE eban-banfn,
         bnfpo LIKE eban-bnfpo, "DB3K900702+
       END OF itb_eban.
Déclaration d'une structure pour la sélection dans PLAF.
DATA : BEGIN OF itb_plaf OCCURS 0,
         plnum LIKE plaf-plnum, "DB3K900702+
         matnr LIKE plaf-matnr,
         plwrk LIKE plaf-plwrk,
         flief LIKE plaf-flief,
         pedtr LIKE plaf-pedtr,
         gsmng LIKE plaf-gsmng,
         webaz LIKE plaf-webaz,
       END OF itb_plaf.
Déclaration d'une structure pour la sélection dans MARC.
DATA : BEGIN OF itb_marc OCCURS 0,
         matnr LIKE marc-matnr,
         werks LIKE marc-werks,
         disls LIKE marc-disls,
         bstrf LIKE marc-bstrf,
         bstmi LIKE marc-bstmi,
         bstma LIKE marc-bstma,
         bstfe LIKE marc-bstfe,
         ekgrp LIKE marc-ekgrp,
         dispo LIKE marc-dispo,
       END OF itb_marc.
DATA : BEGIN OF itb_marc_eord OCCURS 0,
          matnr LIKE marc-matnr,
          werks LIKE marc-werks,
          strgr LIKE marc-strgr,   "groupe de stratégie planif
       END OF itb_marc_eord.
DATA : BEGIN OF itb_z03_bw_cmp1 OCCURS 0,
         matnr LIKE z03_bw_cmp1-matnr,
         werks LIKE z03_bw_cmp1-werks,
         pdatu LIKE z03_bw_cmp1-pdatu,
         plnmg LIKE z03_bw_cmp1-plnmg,
       END OF itb_z03_bw_cmp1.
Begin change BNI <DE3K937051>
DATA : BEGIN OF itb_z03_bw_cmp2 OCCURS 0,
         matnr LIKE z03_bw_cmp2-matnr,
         werks LIKE z03_bw_cmp2-werks,
         pdatu LIKE z03_bw_cmp2-pdatu,
         plnmg LIKE z03_bw_cmp2-plnmg,
       END OF itb_z03_bw_cmp2.
*End change BNI
DATA : BEGIN OF str_index1,
         matnr LIKE eord-matnr,
         werks LIKE eord-werks,
      END OF str_index1.
DATA : BEGIN OF str_index2,
         matnr LIKE eord-matnr,
         werks LIKE eord-werks,
      END OF str_index2.
DATA : BEGIN OF str_index3_eord,
         matnr LIKE eord-matnr,
         werks LIKE eord-werks,
      END OF str_index3_eord.
DATA : BEGIN OF str_index4,
         matnr LIKE eord-matnr,
         werks LIKE eord-werks,
      END OF str_index4.
DATA : BEGIN OF str_index5,
         matnr LIKE eord-matnr,
         werks LIKE eord-werks,
END OF str_index5.
DATA : BEGIN OF str_index6,
         matnr LIKE eord-matnr,
         werks LIKE eord-werks,
END OF str_index6.
DATA : BEGIN OF str_index7,
         matnr LIKE eord-matnr,
         werks LIKE eord-werks,
END OF str_index7.
Déclaration des variables de debut et de fin de mois.
DATA: w_debut_mois    LIKE sy-datum,
      w_debut_periode LIKE sy-datum,
      w_fin_mois      LIKE sy-datum,
      w_fin_periode   LIKE sy-datum.
Déclaration des variables pour les dates.
DATA: w_date0 LIKE sy-datum,
      w_date1 LIKE sy-datum,
      w_date2 LIKE sy-datum,
      w_date3 LIKE sy-datum,
      w_date4 LIKE sy-datum,
      w_date5 LIKE sy-datum,
      w_date6 LIKE sy-datum,
      w_datejour LIKE sy-datum,                             "FAE15269
      w_dat_da LIKE eban-lfdat,
      w_dat_op LIKE plaf-pedtr,
      w_mois0 LIKE t247-ltx,
      w_mois1 LIKE t247-ltx,
      w_mois2 LIKE t247-ltx,
      w_mois3 LIKE t247-ltx,
      w_mois4 LIKE t247-ltx,
      w_mois5 LIKE t247-ltx,
      w_mois6 LIKE t247-ltx,
      w_lendemain LIKE sy-datum.                            "FAE17345+
Temoin d'un AR dans la commande d'achat.
DATA: w_temoin_ar.
Numéro de la confirmation de la commande
DATA : w_etens LIKE ekes-etens.
Déclaration des variables pour le nom des fichiers.
DATA: w_nom_fichier LIKE rlgrap-filename,
      w_fichier LIKE rlgrap-filename,
      w_racine LIKE rlgrap-filename,
      w_file LIKE rlgrap-filename.
Déclaration d'une table interne pour le transfert.
DATA: BEGIN OF itb_trans OCCURS 0,
        w_ligne(320).
DATA: END OF itb_trans.
Déclaration d'une variable pour rechercher les enregistrements vides.
DATA: w_compteur     TYPE i,
      w_compteur1    TYPE i,
      w_compteur2    TYPE i,
      w_retard       TYPE i,          " Retard en jours ouvres.
      w_trouve_pfc   TYPE c, "addsde
      w_trouve_pfs   TYPE c, "+DE3K937051
      w_trouve       TYPE c.
*Index pour les LOOP
DATA : w_index_ekpo LIKE sy-tabix,
       w_index_ekes LIKE sy-tabix,
       w_index_eket LIKE sy-tabix,
       w_index_mseg LIKE sy-tabix,
       w_index_eban LIKE sy-tabix,
       w_index_plaf LIKE sy-tabix,
       w_index_pca  LIKE sy-tabix,
       w_index_z03_bw_cmp1 LIKE sy-tabix,
       w_index_z03_bw_cmp2 LIKE sy-tabix."+DE3K937051
RANGES : r_type_pfs   FOR marc-strgr.
*fichier sur serveur +EDR231003
DATA : w_chemin LIKE filename-fileintern,  "nom du fichier
       w_date_fichier(12) TYPE c,          "Date format DD_MM_AA
       w_csv(307) TYPE c.                  "ligne du fichier format CSV
CONSTANTS: k_imputation_m LIKE eban-knttp VALUE 'M'.        "FAE19001+
                 Description de l écran de sélection                 *
                     Paramètres "UTILISATION"                        *
Ouverture d'un block de sélection pour le(s) fournisseur(s).
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-bl1.
Sélection division(s)
SELECT-OPTIONS: s_werks FOR ekpo-werks.
Sélection fournisseur(s).
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr OBLIGATORY.
Sélection du Groupe d'acheteur
*SELECT-OPTIONS: s_ekgrp FOR marc-ekgrp.   "-FAE26446
*SELECT-OPTIONS: s_dispo FOR marc-dispo.   "-FAE26446
SELECTION-SCREEN END OF BLOCK block1.
FAE 26446 : ajout
SELECTION-SCREEN BEGIN OF BLOCK block3 WITH FRAME TITLE text-bl3.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_ekgrp RADIOBUTTON GROUP g3.
SELECTION-SCREEN COMMENT 5(24) text-001 FOR FIELD p_ekgrp.
SELECT-OPTIONS: s_ekgrp FOR marc-ekgrp.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_dispo RADIOBUTTON GROUP g3.
SELECTION-SCREEN COMMENT 5(24) text-002 FOR FIELD p_dispo.
SELECT-OPTIONS: s_dispo FOR marc-dispo.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK block3.
FAE 26446 : fin ajout
                       Paramètres "SYSTEME"                          *
Saut de 2 lignes.
SELECTION-SCREEN: SKIP 2.
Ouverture d'un block de sélection pour l'adresse physique du fichier.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-bl2.
PARAMETERS: p_pc       RADIOBUTTON GROUP rad1 DEFAULT 'X',  "+EDR231003
            p_fic_pc LIKE rlgrap-filename.                  "+EDR231003
SELECTION-SCREEN SKIP.                                      "+EDR231003
PARAMETERS     : p_serve   RADIOBUTTON GROUP rad1,          "+EDR231003
                 p_fic_se LIKE filename-fileintern          "+EDR231003
                          DEFAULT 'Z03_PREV_COMMANDES'.     "+EDR231003
SELECTION-SCREEN END OF BLOCK block2.
                       Logique de traitement                         *
                          INITIALIZATION                             *
INITIALIZATION.
Date du jour
  MOVE sy-datum TO w_datejour.                              "FAE15269
Gestion des anomalies.
  MOVE text-lb1 TO w_lb_traitement.
  PERFORM f930_init USING sy-cprog '30'.
Fin de la gestions des anomalies.
Récuperation des mois dans la table interne 'ITB_MONTHS'.
  CALL FUNCTION 'MONTH_NAMES_GET'
       EXPORTING
            language              = sy-langu
       TABLES
            month_names           = itb_months
       EXCEPTIONS
            month_names_not_found = 1
            OTHERS                = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
Récupération des differentes periodes.
  PERFORM f100_recuperation_date TABLES itb_months.
Récupération du debut du mois.
  CONCATENATE sy-datlo(6) '01' INTO w_debut_mois.
  MOVE: w_debut_mois TO w_debut_periode.
Récupération du dernier jour du mois.
  CALL FUNCTION 'LAST_DAY_OF_MONTHS'
       EXPORTING
            day_in            = sy-datlo
       IMPORTING
            last_day_of_month = w_fin_mois
       EXCEPTIONS
            day_in_no_date    = 1
            OTHERS            = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
                          TOP-OF-PAGE                                *
TOP-OF-PAGE.
  CALL FUNCTION 'Z_00_BC_TOP_OF_PAGE'
       EXPORTING
            p_linsz   = k_ligne
            p_pagno   = sy-pagno
            p_prog    = sy-cprog
            p_projet  = k_projet
            p_societe = k_societe
            p_sujet   = sy-title.
                          END-OF-PAGE                                *
END-OF-PAGE.
                        AT SELECTION-SCREEN                          *
FAE 26446 : ajout
AT SELECTION-SCREEN ON BLOCK block3.
  IF NOT ( s_ekgrp IS INITIAL )
  AND  NOT ( s_dispo IS INITIAL ).
    MESSAGE e394(z03_mm).
  ENDIF.
  IF p_ekgrp = 'X'.
    IF s_ekgrp IS INITIAL.
      MESSAGE e395(z03_mm).
    ENDIF.
  ELSE.
    IF s_dispo IS INITIAL.
      MESSAGE e396(z03_mm).
    ENDIF.
  ENDIF.
fae26446 fin ajout
AT SELECTION-SCREEN ON BLOCK block2.
  IF p_pc = 'X'.
    IF p_fic_pc IS INITIAL.
*Attention, il n'y a aucune adresse de sauvegarde pour le(s) fichier(s)
      MESSAGE e021(z03_mm).
    ENDIF.
  ELSE.
    IF p_fic_se IS INITIAL.
*Attention, il n'y a aucune adresse de sauvegarde pour le(s) fichier(s)
      MESSAGE e021(z03_mm).
    ENDIF.
  ENDIF.
Création du matchcode pour la selection du fichier local.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fic_pc.
  CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
            def_filename     = p_fic_pc
            def_path         = 'C:'
            mask             = text-ma1
            mode             = 'S'
            title            = text-sel
       IMPORTING
            filename         = p_fic_pc
       EXCEPTIONS
            inv_winsys       = 1
            no_batch         = 2
            selection_cancel = 3
            selection_error  = 4
            OTHERS           = 5.
  IF sy-subrc NE 0 AND sy-subrc NE 3.
    MESSAGE e032(z03_mm).
  ENDIF.
                        START-OF-SELECTION                           *
START-OF-SELECTION.
  PERFORM select_donnees.
=================================================
Liste des ARTICLES impactés pour les prévisions *
=================================================
===================================
PORTEFEUILLE DE COMMANDES D'ACHAT *
===================================
Construction itb_pca à partir de EKKO/EKPO.
  w_index_ekpo  = 1.
  w_index_ekes  = 1.
  w_index_eket  = 1.
  w_index_mseg  = 1.
SORT itb_ekko BY ebeln.           "-FAE26446
  SORT itb_ekpo BY ebeln ebelp.
  SORT itb_makt BY matnr spras.
  SORT itb_eket BY ebeln ebelp.
  SORT itb_ekes BY ebeln ebelp.
  SORT itb_mseg BY ebeln ebelp.
  SORT itb_mkpf BY mblnr mjahr.
  SORT itb_marc BY matnr werks.                             "+FAE26446
FAE 26446 remplacement
LOOP AT itb_ekko.
   LOOP AT itb_ekpo.
           FROM w_index_ekpo.
     IF itb_ekko-ebeln = itb_ekpo-ebeln.
  LOOP AT itb_ekpo.
    READ TABLE itb_marc WITH KEY
       matnr = itb_ekpo-matnr
       werks = itb_ekpo-werks BINARY SEARCH.
    CHECK sy-subrc = 0.
FAE 26446 fin remplacement
    itb_pca-ebeln = itb_ekpo-ebeln.
    itb_pca-ebelp = itb_ekpo-ebelp.
  itb_pca-lifnr = itb_ekko-lifnr.   "-FAE26446
    itb_pca-lifnr = itb_ekpo-lifnr.                         "+FAE26446
    itb_pca-ekgrp = itb_ekpo-ekgrp.                         "+FAE26446
    itb_pca-dispo = itb_ekpo-dispo.                         "+FAE26446
    itb_pca-matnr = itb_ekpo-matnr.
    itb_pca-werks = itb_ekpo-werks.
  Recherche du libellé article
    READ TABLE itb_makt
               WITH KEY matnr = itb_ekpo-matnr
                        spras = text-fra
               BINARY SEARCH.
    IF sy-subrc = 0.
      itb_pca-maktx = itb_makt-maktx.
    ELSE.
      READ TABLE itb_makt
                WITH KEY matnr = itb_ekpo-matnr
                         spras = text-ang
                BINARY SEARCH.
      IF sy-subrc = 0.
        itb_pca-maktx = itb_makt-maktx.
      ENDIF.
    ENDIF.
    IF NOT itb_ekpo-bpumn IS INITIAL.
      itb_pca-menge = itb_ekpo-menge * itb_ekpo-bpumz /
                                       itb_ekpo-bpumn.
    ENDIF.
  Sélect° ds la table EKES des dates de livraisons et des qtés
  en transit
    CLEAR w_temoin_ar.
    CLEAR w_etens.
    LOOP AT itb_ekes
            FROM w_index_ekes.
      IF  itb_ekes-ebeln = itb_ekpo-ebeln
      AND itb_ekes-ebelp = itb_ekpo-ebelp.
        IF itb_ekes-ebtyp = text-arn.
          itb_pca-eindt = itb_ekes-eindt.
          w_temoin_ar = 'X'.
        ELSE.
        Si c'est une qté en transit alors on recupere
        la quantité et la date.
          IF itb_ekes-dabmg < itb_ekes-menge.
            itb_pca-qtran = itb_pca-qtran + itb_ekes-menge -
                            itb_ekes-dabmg.
          ENDIF.
          IF itb_ekes-etens > w_etens.
            w_etens = itb_ekes-etens.
            itb_pca-dtran = itb_ekes-eindt.
          ENDIF.
        ENDIF.
      ELSEIF itb_ekes-ebeln > itb_ekpo-ebeln
      OR ( itb_ekes-ebeln = itb_ekpo-ebeln
      AND itb_ekes-ebelp > itb_ekpo-ebelp ).
        w_index_ekes = sy-tabix.
        EXIT.
      ENDIF.
    ENDLOOP.
  S'il n'y a pas d'AR alors récupérat° de la date livraison dans EKET.
    LOOP AT itb_eket
            FROM w_index_eket.
      IF  itb_eket-ebeln = itb_ekpo-ebeln
      AND itb_eket-ebelp = itb_ekpo-ebelp.
        IF w_temoin_ar IS INITIAL.
          itb_pca-eindt = itb_eket-eindt.
        ENDIF.
        itb_pca-slfdt = itb_eket-slfdt.
      Calcul du portefeuille fournisseur à partir de la
      qté commandée et la qté reçue
        itb_pca-attdu = itb_pca-attdu + itb_eket-menge -
                        itb_eket-wemng.
      Calcul du montant du poste
        itb_pca-netpr = itb_ekpo-netpr * itb_pca-attdu.
        IF itb_ekpo-peinh NE 0.
          itb_pca-netpr = itb_pca-netpr / itb_ekpo-peinh.
        ENDIF.
      Calcul quantité réceptionnée.
        itb_pca-wemng = itb_pca-wemng + itb_eket-wemng.
      Calcul du retard en nombre de jours calendaires
      Le calcul du retard  ne doit pas prendre en compte
      le jour de livraison
        ADD 1 TO itb_eket-eindt.
        IF NOT itb_pca-attdu  IS INITIAL
        AND    itb_eket-eindt LT sy-datum.
        Calcul du retard en nombre de jours ouvrés
          CLEAR w_retard.
          CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_PERIOD'
               EXPORTING
                    date_deb = itb_eket-eindt
                    date_fin = sy-datum
               IMPORTING
                    jours    = w_retard.
          itb_pca-rtard = itb_pca-rtard + w_retard .
        ENDIF.
      ELSEIF itb_eket-ebeln > itb_ekpo-ebeln
      OR (   itb_eket-ebeln = itb_ekpo-ebeln
      AND    itb_eket-ebelp > itb_ekpo-ebelp ).
        w_index_eket = sy-tabix.
        EXIT.
      ENDIF.
    ENDLOOP.
  Recherche de la derniere date de livraison.
    LOOP AT itb_mseg
            FROM w_index_mseg.
      IF  itb_mseg-ebeln = itb_ekpo-ebeln
      AND itb_mseg-ebelp = itb_ekpo-ebelp.
        READ TABLE itb_mkpf
                   WITH KEY mblnr = itb_mseg-mblnr
                            mjahr = itb_mseg-mjahr
                   BINARY SEARCH.
        IF sy-subrc = 0.
          IF itb_mkpf-bldat > itb_pca-bldat.
            itb_pca-bldat = itb_mkpf-bldat.
          ENDIF.
        ENDIF.
      ELSEIF itb_mseg-ebeln > itb_ekpo-ebeln
      OR (   itb_mseg-ebeln = itb_ekpo-ebeln
      AND    itb_mseg-ebelp > itb_ekpo-ebelp ).
        w_index_mseg = sy-tabix.
        EXIT.
      ENDIF.
    ENDLOOP.
    APPEND itb_pca.
    CLEAR itb_pca.
FAE26446 suppression parag. suivant
     ELSEIF itb_ekpo-ebeln > itb_ekko-ebeln.
       w_index_ekpo = sy-tabix.
       EXIT.
     ENDIF.
   ENDLOOP.
Fin FAE26446
  ENDLOOP.
=========================
PREVISIONS DE COMMANDES *
=========================
  SORT itb_eord        BY matnr werks lifnr ekgrp.
  SORT itb_eban        BY matnr werks flief ekgrp.
  SORT itb_plaf        BY matnr plwrk flief.
  SORT itb_z03_bw_cmp1 BY matnr werks.
  SORT itb_z03_bw_cmp2 BY matnr werks."+DE3K937051
  SORT itb_pca         BY matnr werks lifnr.
  w_index_eban = 1.
  w_index_plaf = 1.
  w_index_z03_bw_cmp1 = 1.
  w_index_pca = 1.
  w_index_z03_bw_cmp2 = 1."+DE3K937051
Remplissage de la table des prévisions de commande.
  LOOP AT itb_eord.
    CLEAR: str_prev_pfc,
           w_trouve.
    MOVE-CORRESPONDING itb_eord TO str_index1.
    MOVE-CORRESPONDING itb_eord TO str_index3_eord.
    MOVE-CORRESPONDING itb_eord TO itb_prev_cde.
  Recherche dans table division/article (MARC) afin de déterminer si
  article PFS (prod fabriqué à stock) ou PFC (Prod fabriqué sur cde)
    AT NEW werks.
      READ TABLE itb_marc_eord
                 WITH KEY matnr = itb_eord-matnr
                          werks = itb_eord-werks
                 BINARY SEARCH.
      IF sy-subrc NE 0.
        CLEAR itb_marc_eord.
      ENDIF.
    ENDAT.
a - Prévisions pour les PFS : DA + OP *
*Calcul des quantités de commande.
    IF itb_eord-disls = text-tl1.
      itb_prev_cde-bstmi =  itb_eord-bstfe.
    ELSEIF itb_eord-disls = text-tl2
    OR     itb_eord-disls = text-tl3.
      IF  itb_eord-bstrf NE 0
      AND itb_eord-bstmi = 0
      AND itb_eord-bstma = 0.
        itb_prev_cde-bstmi = itb_eord-bstrf.
      ELSEIF itb_eord-bstrf NE 0
      AND    itb_eord-bstmi NE 0.
        itb_prev_cde-bstmi = itb_eord-bstmi.
      ELSEIF itb_eord-bstrf = itb_eord-bstma
      AND    itb_eord-bstrf NE 0
      AND    itb_eord-bstmi = 0.
        itb_prev_cde-bstmi = itb_eord-bstma.
      ENDIF.
    ENDIF.
  si article PFS (Prod fabriqué à stock) recherche des
  demandes d'achat ou ordres planfiés
    IF itb_marc_eord-strgr IN r_type_pfs.
  Récupérat° calendrier de la division pour calcul correct lors de
  l'ajout de eban-webaz ou plaf-webaz jours ouvrés
      CLEAR w_trouve_pfs ."+DE3K937051
      READ TABLE itb_t001w
                 WITH KEY werks = itb_eord-werks
                 BINARY SEARCH.
      IF sy-subrc = 0.
        LOOP AT itb_eban
                FROM w_index_eban.
          MOVE-CORRESPONDING itb_eban TO str_index2.
          IF str_index1 = str_index2.
            w_trouve_pfs = 'X'."+DE3K937051
          si qte commandées pour la DA  < quantité de la DA
            IF itb_eban-bsmng < itb_eban-menge.
            ajout de quantité de la DA - qte  commandée pour la DA
              PERFORM affect_da.
            ENDIF.
          ELSEIF str_index2 > str_index1.
            w_index_eban = sy-tabix.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ajout des quantité des OP (ordres planifiés)
      LOOP AT itb_plaf
              FROM w_index_plaf.
        MOVE-CORRESPONDING itb_plaf TO str_index4.
        str_index4-werks = itb_plaf-plwrk.
      str_index4-lifnr = itb_plaf-flief.
        IF str_index4 = str_index3_eord.
        Ajout de webaz jours ouvrés à pedtr
          CALL FUNCTION 'Z_03_MM_ADD_TO_FACTORYDATE'
               EXPORTING
                    i_date        = itb_plaf-pedtr
                    i_calendar_id = itb_t001w-fabkl
                    i_nb_days     = itb_plaf-webaz
               IMPORTING
                    o_date        = w_dat_op
               EXCEPTIONS
                    conv_error    = 1
                    OTHERS        = 2.
          IF sy-subrc
   If forecasts found in Z03_BW_CMP2 for the article
   IF w_trouve_pfs = 'X'."-DE3K937602
Recalculation prev month M in fct of Nb of wrought days of the month
    IF NOT itb_prev_cde-men00 IS INITIAL.
   one does not hold any more account of the day in progress
      w_lendemain = w_date0 + 1.
      CLEAR:w_nb_j,w_nb_j_tot.         "DE3K938206+
      CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_PERIOD'
           EXPORTING
                date_deb = w_lendemain
                date_fin = w_fin_mois
           IMPORTING
                jours    = w_nb_j.
      CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_MONTH'
           EXPORTING
                date  = w_lendemain
           IMPORTING
                jours = w_nb_j_tot.
      itb_prev_cde-men00  = itb_prev_cde-men00 * w_nb_j / w_nb_j_tot
*CLA DE3K925301 FAE27197
*to round has the higher entirety
    itb_prev_cde-men00  = ceil( itb_prev_cde-men00 ). "DE3K938206-
    ENDIF.
   ENDIF."-DE3K937602
*End change BNI
b - Prévisions pour les PFC (Z03_BW_CMP1 puis rééquilibrage) *
  Recherche des previsions dans Z03_BW_CMP1
  si article PFC (Prod fabriqué sur cde) recherche des prévisions
    IF  NOT itb_marc_eord-strgr IN r_type_pfs.
      CLEAR str_prev_pfc.
      MOVE-CORRESPONDING itb_eord TO str_prev_pfc.
      CLEAR w_trouve_pfc .
      LOOP AT itb_z03_bw_cmp1
              FROM w_index_z03_bw_cmp1.
        MOVE-CORRESPONDING itb_z03_bw_cmp1 TO str_index7.
        MOVE-CORRESPONDING itb_eord TO str_index6.
        IF str_index6 = str_index7.
      si on trouve des prévisions dans z03_bw_cmp1 pour la source
      d'appro eord alors c'est un article  PFC
          w_trouve_pfc = 'X'.
          CASE itb_z03_bw_cmp1-pdatu+0(6).
            WHEN w_date0+0(6).
              str_prev_pfc-men00 = itb_z03_bw_cmp1-plnmg.
            WHEN w_date1+0(6).
              str_prev_pfc-men01 = itb_z03_bw_cmp1-plnmg.
            WHEN w_date2+0(6).
              str_prev_pfc-men02 = itb_z03_bw_cmp1-plnmg.
            WHEN w_date3+0(6).
              str_prev_pfc-men03 = itb_z03_bw_cmp1-plnmg.
            WHEN w_date4+0(6).
              str_prev_pfc-men04 = itb_z03_bw_cmp1-plnmg.
            WHEN w_date5+0(6).
              str_prev_pfc-men05 = itb_z03_bw_cmp1-plnmg.
            WHEN w_date6+0(6).
              str_prev_pfc-men06 = itb_z03_bw_cmp1-plnmg.
            WHEN OTHERS.
          ENDCASE.
        ELSEIF str_index7 > str_index6.
          w_index_z03_bw_cmp1 = sy-tabix.
          EXIT.
        ENDIF.
      ENDLOOP.
*Begin change BNI
    Si des prévisions trouvées dans Z03_BW_CMP1 pour l'article
      IF w_trouve_pfc = 'X'.
      Recalcul prev mois M en fct du nb de jours ouvrés du mois
        IF NOT str_prev_pfc-men00 IS INITIAL.
        on ne tient plus compte du jour en cours
          w_lendemain = w_date0 + 1.
          CLEAR:w_nb_j,w_nb_j_tot.               "DE3K938206+
          CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_PERIOD'
               EXPORTING
                    date_deb = w_lendemain
                    date_fin = w_fin_mois
               IMPORTING
                    jours    = w_nb_j.
          CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_MONTH'
               EXPORTING
                    date  = w_lendemain
               IMPORTING
                    jours = w_nb_j_tot.
          str_prev_pfc-men00 = str_prev_pfc-men00 * w_nb_j / w_nb_j_tot.
*CLA DE3K925301 FAE27197
*arrondir a l'entier supèrieur
          str_prev_pfc-men00 = ceil( str_prev_pfc-men00 ).
        ENDIF.
      Equilibrage PFC : commande/prévision du mois
      Recherche COMMANDES cumulées pour M à M+6
        CLEAR str_pca_pfc.
        LOOP AT itb_pca
                FROM w_index_pca.
          MOVE-CORRESPONDING itb_pca TO str_index5.
          IF str_index5 = str_index3_eord.
            IF NOT itb_pca-menge IS INITIAL.
              CASE itb_pca-eindt+0(6).
                WHEN w_date0+0(6).
                  IF itb_pca-eindt >= w_date0.
                  str_pca_pfc-men00 = str_pca_pfc-men00 + itb_pca-menge.
                  ENDIF.
                WHEN w_date1+0(6).
                  str_pca_pfc-men01 = str_pca_pfc-men01 + itb_pca-menge.
                WHEN w_date2+0(6).
                  str_pca_pfc-men02 = str_pca_pfc-men02 + itb_pca-menge.
                WHEN w_date3+0(6).
                  str_pca_pfc-men03 = str_pca_pfc-men03 + itb_pca-menge.
                WHEN w_date4+0(6).
                  str_pca_pfc-men04 = str_pca_pfc-men04 + itb_pca-menge.
                WHEN w_date5+0(6).
                  str_pca_pfc-men05 = str_pca_pfc-men05 + itb_pca-menge.
                WHEN w_date6+0(6).
                  str_pca_pfc-men06 = str_pca_pfc-men06 + itb_pca-menge.
              ENDCASE.
            ENDIF."NOT itb_pca-menge IS INITIAL
          ELSEIF str_index5 > str_index3_eord.
            w_index_pca = sy-tabix.
            EXIT.
          ENDIF.
        ENDLOOP."itb_pca
*. Equilibrer commande / prévision des mois : diminuer la quantité de
prévision de chaque mois par le portefeuille de commande client du
mois*. Si ce solde est négatif alors lui donner la valeur 0.
        w_i = 0.
      Ajustement commandes/prévisions pour les mois M à M+6
        WHILE w_i .
        Pour un mois, SI Prévisions > Commandes en cours
          IF .
          Prévisions = Prévisions - Commandes en cours
             = 0.
          ENDIF.
        On passe au mois suivant
          w_i = w_i + 1.
        ENDWHILE.
        MOVE str_prev_pfc-men00 TO itb_prev_cde-men00.
        MOVE str_prev_pfc-men01 TO itb_prev_cde-men01.
        MOVE str_prev_pfc-men02 TO itb_prev_cde-men02.
        MOVE str_prev_pfc-men03 TO itb_prev_cde-men03.
        MOVE str_prev_pfc-men04 TO itb_prev_cde-men04.
        MOVE str_prev_pfc-men05 TO itb_prev_cde-men05.
        MOVE str_prev_pfc-men06 TO itb_prev_cde-men06.
      ENDIF.  "w_trouve_pfc = 'X'.
    ENDIF.
*recherche du libellé article

Hi,
see this link, useful tips, links and transactions for best performance, by Anji.
https://forums.sdn.sap.com/click.jspa?searchID=5967263&messageID=4260111
Regards

Similar Messages

  • How to improve performace for this program

    Hi,
    I want to improve performance for this program.Pls help me.Here is the code.
    Thanks
    kumar
    --# SCCS: @(#)nscdprpt_rpt_fam_fweq_detail_aggr_dml.sql     2.1 08/17/05 12:16:11
    --# Location: /appl/dpdm/src/sql/SCCS/s.nscdprpt_rpt_fam_fweq_detail_aggr_dml.sql
    -- =============================================================================
    -- Purpose:
    -- DML Script to calculate aggregate rows from table NSCDPRPT.RPT_FAM_FWEQ_DETAIL
    -- inserts one (1) monthly total row for each comparison type (6 of them)
    -- Modification History
    -- Date Version Who What
    -- 28-Jun-05 V1.00 J. Myers Initial Version
    -- 17-Aug-05 gzuerc Replaced UNION ALL code with INSERT's to avoid
    -- Oracle error out of undo tablespace.
    -- ============================================================================
    -- NOTES:
    -- This process pulls data from RPT_FAM_FWEQ_DETAIL table.
    -- The target table RPT_FAM_FWEQ_DETAIL_AGGR is truncated by plan_ctry and loaded daily;
    -- it is the data used in the Forecast Accuracy Measurements Report.
    -- The input data is 'wide' (6 quantities), and this script outputs a single
    -- row for each quantity as a 'thin' table (single column F1_QTY and F2_QTY shared by all quantities), and
    -- with a ROW_TYPE = 'TOTAL'
    -- Two (2) other scripts add additional rows to this table as follows:
    -- 1) nscdprpt_rpt_fam_FWEQ_detail_aggr_sesn_avg_dml.sql => calculates the
    -- total quantities F1_QTY, F2_QTY and AE for each LEVEL_VALUE
    -- 2) nscdprpt_rpt_fam_FWEQ_detail_aggr_pct_swg_dml.sql => calculates the
    -- percent swing in quantities between DISP_EVENTS for each grouping
    -- of PLAN_CTRY, DIVISION, SEASON and TRG_EVENT_NUM for only LEVEL_TYPE = 'SUB_CAT'
    -- =============================================================================
    -- The result set from joining RPT_FAM_FWEQ_DETAIL rows with comparison types
    -- is inserted into the table RPT_FAM_FWEQ_DETAIL_AGGR
    INSERT INTO rpt_fam_FWEQ_detail_aggr
    SELECT plan_ctry,
    division,
    season,
    monthly_seq,
         bucket_month_date,
    tier_num,
    level_num,
    tier_volume,
    trg_event_num,
    disp_event_num,
    max_event_num,
    compare_name,
    first_display_event_num,
    level_type,
    level_value,
    'TOTAL' AS row_type,
    material,
    key_material,
    sap_cat_cd,
    sap_cat_desc,
    sap_sub_cat_cd,
    sap_sub_cat_desc,
    sty_colr_sdesc,
    sty_grp_nbr,
    sty_grp_desc,
    matl_typ,
    sap_prod_typ_grp, -- 'Type Group' in Brio
    typ_grp_desc, -- 'Type Group' in Brio
    curr_prod_i2_life_cyc_cd,
    NULL AS promo_ind, -- for future use
    -- Each RPT_FAM_FWEQ_DETAIL row's eight (8) quantity columns are broken down
    -- into F1_QTY from DISP_aaaa_QTY, F2_QTY from TRG_aaaa_QTY and
         -- AE from aaaa_AE where 'aaaa' is equal to one of the COMPARE_TYPEs below:
    -- F1_QTY
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    disp_dlvry_plan_qty
    WHEN compare_type = 'NET' THEN
    disp_net_qty
    WHEN compare_type = 'NET_AO' THEN
    disp_ao_qty
    WHEN compare_type = 'NET_FTRS' THEN
    disp_futr_qty
    WHEN compare_type = 'NET_REPLENS' THEN
    disp_replen_qty
    WHEN compare_type = 'AUTH_FTRS' THEN
    disp_auth_futr_qty
    END as f1_qty,
    -- F2_QTY
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    trg_dlvry_plan_qty
    WHEN compare_type = 'NET' THEN
    trg_net_qty
    WHEN compare_type = 'NET_AO' THEN
    trg_ao_qty
    WHEN compare_type = 'NET_FTRS' THEN
    trg_futr_qty
    WHEN compare_type = 'NET_REPLENS' THEN
    trg_replen_qty
    WHEN compare_type = 'AUTH_FTRS' THEN
    trg_auth_futures_qty
    END as f2_qty,
    -- AE
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    abs(disp_dlvry_plan_qty - trg_dlvry_plan_qty)
    WHEN compare_type = 'NET' THEN
    abs(disp_net_qty - trg_net_qty)
    WHEN compare_type = 'NET_AO' THEN
    abs(disp_ao_qty - trg_ao_qty)
    WHEN compare_type = 'NET_FTRS' THEN
    abs(disp_futr_qty - trg_futr_qty)
    WHEN compare_type = 'NET_REPLENS' THEN
    abs(disp_replen_qty - trg_replen_qty)
    WHEN compare_type = 'AUTH_FTRS' THEN
    abs(disp_auth_futr_qty - trg_auth_futures_qty)
    END as ae,
    SYSDATE AS zz_insert_tmst
    FROM
    -- The following in-line view provides three (3) result sets from the RPT_FAM_FWEQ_DETAIL table
         -- This in-line view returns only LEVEL_NUM = 1 or LEVEL_TYPE = 'SUB_CAT' data
         SELECT plan_ctry,
         division,
         season,
         monthly_seq,
              bucket_month_date,
         tier_num,
         level_num,
         tier_volume,
         trg_event_num,
         trg_event_type,
         disp_event_num,
         max_event_num,
         first_display_event_num,
         level_type,
         level_value,
         -- The following NULL'd columns' values cannot be saved due to aggregation
         NULL AS material,
         NULL AS key_material,
         sap_cat_cd,
         sap_cat_desc,
         sap_sub_cat_cd,
         sap_sub_cat_desc,
         NULL AS sty_colr_sdesc,
         NULL AS sty_grp_nbr,
         NULL AS sty_grp_desc,
         NULL AS matl_typ,
         sap_prod_typ_grp, -- 'Type Group' in Brio
         typ_grp_desc, -- 'Type Group' in Brio
         NULL AS curr_prod_i2_life_cyc_cd,
         sum(disp_net_qty) AS disp_net_qty,
              sum(trg_net_qty) AS trg_net_qty,
         -- ABS(sum(trg_net_qty) - sum(disp_net_qty)) AS net_AE,
         sum(disp_dlvry_plan_qty) AS disp_dlvry_plan_qty,
              sum(trg_dlvry_plan_qty) AS trg_dlvry_plan_qty,
         -- ABS(sum(trg_dlvry_plan_qty) - sum(disp_dlvry_plan_qty)) AS dlvry_plan_AE,
         sum(disp_futr_qty) AS disp_futr_qty,
              sum(trg_futr_qty) AS trg_futr_qty,
         -- ABS(sum(trg_futr_qty) - sum(disp_futr_qty)) AS futr_AE,
         sum(disp_ao_qty) AS disp_ao_qty,
              sum(trg_ao_qty) AS trg_ao_qty,
         -- ABS(sum(trg_ao_qty) - sum(disp_ao_qty)) AS ao_AE,
         sum(disp_replen_qty) AS disp_replen_qty,
              sum(trg_replen_qty) AS trg_replen_qty,
         -- ABS(sum(trg_replen_qty) - sum(disp_replen_qty)) AS replen_AE,
         sum(disp_futr_qty) AS disp_auth_futr_qty,
              sum(trg_auth_futures_qty) AS trg_auth_futures_qty --,
         -- ABS(sum(trg_auth_futures_qty) - sum(disp_futr_qty)) AS auth_futures_AE
         FROM rpt_fam_FWEQ_detail
         WHERE plan_ctry &where_plan_ctry
         and level_num = 1 -- 'SUB-CAT'
         -- AND (promo_ind <> 'Y' OR promo_ind IS null)
         GROUP BY plan_ctry,
         division,
         season,
         monthly_seq,
              bucket_month_date,
         tier_num,
         level_num,
         tier_volume,
         trg_event_num,
         trg_event_type,
         disp_event_num,
         max_event_num,
         first_display_event_num,
         level_type,
         level_value,
         sap_cat_cd,
         sap_cat_desc,
         sap_sub_cat_cd,
         sap_sub_cat_desc,
         sap_prod_typ_grp, -- 'Type Group' in Brio
         typ_grp_desc -- 'Type Group' in Brio
         ) dtl,
         -- The following in-line view returns all of the different combinations
         -- of comparison types in the RPT_FAM_FWEQ_DETAIL table
         -- This select returns the pairing of all forecast types
         SELECT event_type, compare_type, compare_name
         from
         (SELECT event_type, compare_type, compare_type_description || ' to ' || compare_type_description AS compare_name
         FROM rpt_fam_compare_types
         WHERE event_type = 'FCST'
         UNION
         -- This select returns the pairing of all bookings types with forecast types
         SELECT bkng.event_type, fcst.compare_type, bkng.compare_type_description || ' to ' || fcst.compare_type_description AS compare_name
         FROM rpt_fam_compare_types fcst,
         rpt_fam_compare_types bkng
         WHERE fcst.event_type = 'FCST'
         AND bkng.event_type = 'BKNG'
         AND fcst.compare_type = bkng.compare_type
         WHERE event_type || ' ' || compare_type <> 'FCST AUTH_FTRS'
         AND compare_type NOT IN ('NET_SHIP', 'SHIP_NET_FTRS', 'NET_ETS', 'GROSS_FTRS')
         ) cmpr
    -- The two (2) in-line views are joined by EVENT_TYPE (i.e. 'FCST' and 'BKNG')
    -- to form a product of all RPT_FAM_FWEQ_DETAIL rows with comparison types
    WHERE dtl.trg_event_type = cmpr.event_type
    ORDER BY plan_ctry,
    division,
    season,
    monthly_seq,
    tier_num,
    level_num,
    tier_volume,
    trg_event_num,
    disp_event_num,
    max_event_num,
    first_display_event_num,
    level_type,
    level_value
    COMMIT
    INSERT INTO rpt_fam_FWEQ_detail_aggr
    SELECT plan_ctry,
    division,
    season,
    monthly_seq,
         bucket_month_date,
    tier_num,
    level_num,
    tier_volume,
    trg_event_num,
    disp_event_num,
    max_event_num,
    compare_name,
    first_display_event_num,
    level_type,
    level_value,
    'TOTAL' AS row_type,
    material,
    key_material,
    sap_cat_cd,
    sap_cat_desc,
    sap_sub_cat_cd,
    sap_sub_cat_desc,
    sty_colr_sdesc,
    sty_grp_nbr,
    sty_grp_desc,
    matl_typ,
    sap_prod_typ_grp, -- 'Type Group' in Brio
    typ_grp_desc, -- 'Type Group' in Brio
    curr_prod_i2_life_cyc_cd,
    NULL AS promo_ind, -- for future use
    -- Each RPT_FAM_FWEQ_DETAIL row's eight (8) quantity columns are broken down
    -- into F1_QTY from DISP_aaaa_QTY, F2_QTY from TRG_aaaa_QTY and
         -- AE from aaaa_AE where 'aaaa' is equal to one of the COMPARE_TYPEs below:
    -- F1_QTY
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    disp_dlvry_plan_qty
    WHEN compare_type = 'NET' THEN
    disp_net_qty
    WHEN compare_type = 'NET_AO' THEN
    disp_ao_qty
    WHEN compare_type = 'NET_FTRS' THEN
    disp_futr_qty
    WHEN compare_type = 'NET_REPLENS' THEN
    disp_replen_qty
    WHEN compare_type = 'AUTH_FTRS' THEN
    disp_auth_futr_qty
    END as f1_qty,
    -- F2_QTY
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    trg_dlvry_plan_qty
    WHEN compare_type = 'NET' THEN
    trg_net_qty
    WHEN compare_type = 'NET_AO' THEN
    trg_ao_qty
    WHEN compare_type = 'NET_FTRS' THEN
    trg_futr_qty
    WHEN compare_type = 'NET_REPLENS' THEN
    trg_replen_qty
    WHEN compare_type = 'AUTH_FTRS' THEN
    trg_auth_futures_qty
    END as f2_qty,
    -- AE
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    abs(disp_dlvry_plan_qty - trg_dlvry_plan_qty)
    WHEN compare_type = 'NET' THEN
    abs(disp_net_qty - trg_net_qty)
    WHEN compare_type = 'NET_AO' THEN
    abs(disp_ao_qty - trg_ao_qty)
    WHEN compare_type = 'NET_FTRS' THEN
    abs(disp_futr_qty - trg_futr_qty)
    WHEN compare_type = 'NET_REPLENS' THEN
    abs(disp_replen_qty - trg_replen_qty)
    WHEN compare_type = 'AUTH_FTRS' THEN
    abs(disp_auth_futr_qty - trg_auth_futures_qty)
    END as ae,
    SYSDATE AS zz_insert_tmst
    FROM
         -- This in-line view returns only LEVEL_NUM = 2 or LEVEL_TYPE = 'STYLE_GROUP' data
         (SELECT plan_ctry,
         division,
         season,
         monthly_seq,
              bucket_month_date,
         tier_num,
         level_num,
         tier_volume,
         trg_event_num,
         trg_event_type,
         disp_event_num,
         max_event_num,
         first_display_event_num,
         level_type,
         level_value,
         -- The following NULL'd columns' values cannot be saved due to aggregation
         NULL AS material,
         NULL AS key_material,
         sap_cat_cd,
         sap_cat_desc,
         sap_sub_cat_cd,
         sap_sub_cat_desc,
         NULL AS sty_colr_sdesc,
         sty_grp_nbr,
         sty_grp_desc,
         NULL AS matl_typ,
         sap_prod_typ_grp, -- 'Type Group' in Brio
         typ_grp_desc, -- 'Type Group' in Brio
         NULL AS curr_prod_i2_life_cyc_cd,
         sum(disp_net_qty) AS disp_net_qty,
              sum(trg_net_qty) AS trg_net_qty,
         -- ABS(sum(trg_net_qty) - sum(disp_net_qty)) AS net_AE,
         sum(disp_dlvry_plan_qty) AS disp_dlvry_plan_qty,
              sum(trg_dlvry_plan_qty) AS trg_dlvry_plan_qty,
         -- ABS(sum(trg_dlvry_plan_qty) - sum(disp_dlvry_plan_qty)) AS dlvry_plan_AE,
         sum(disp_futr_qty) AS disp_futr_qty,
              sum(trg_futr_qty) AS trg_futr_qty,
         -- ABS(sum(trg_futr_qty) - sum(disp_futr_qty)) AS futr_AE,
         sum(disp_ao_qty) AS disp_ao_qty,
              sum(trg_ao_qty) AS trg_ao_qty,
         -- ABS(sum(trg_ao_qty) - sum(disp_ao_qty)) AS ao_AE,
         sum(disp_replen_qty) AS disp_replen_qty,
              sum(trg_replen_qty) AS trg_replen_qty,
         -- ABS(sum(trg_replen_qty) - sum(disp_replen_qty)) AS replen_AE,
         sum(disp_futr_qty) AS disp_auth_futr_qty,
              sum(trg_auth_futures_qty) AS trg_auth_futures_qty --,
         -- ABS(sum(trg_auth_futures_qty) - sum(disp_futr_qty)) AS auth_futures_AE
         FROM rpt_fam_FWEQ_detail
         WHERE plan_ctry &where_plan_ctry
         and level_num = 2 -- 'STYLE-GRP' or 'STYLE'
         -- AND (promo_ind <> 'Y' OR promo_ind IS null)
         GROUP BY plan_ctry,
         division,
         season,
         monthly_seq,
              bucket_month_date,
         tier_num,
         level_num,
         tier_volume,
         trg_event_num,
         trg_event_type,
         disp_event_num,
         max_event_num,
         first_display_event_num,
         level_type,
         level_value,
         sap_cat_cd,
         sap_cat_desc,
         sap_sub_cat_cd,
         sap_sub_cat_desc,
         sty_grp_nbr,
         sty_grp_desc,
         sap_prod_typ_grp, -- 'Type Group' in Brio
         typ_grp_desc -- 'Type Group' in Brio
         ) dtl,
         -- The following in-line view returns all of the different combinations
         -- of comparison types in the RPT_FAM_FWEQ_DETAIL table
         -- This select returns the pairing of all forecast types
         SELECT event_type, compare_type, compare_name
         from
         (SELECT event_type, compare_type, compare_type_description || ' to ' || compare_type_description AS compare_name
         FROM rpt_fam_compare_types
         WHERE event_type = 'FCST'
         UNION
         -- This select returns the pairing of all bookings types with forecast types
         SELECT bkng.event_type, fcst.compare_type, bkng.compare_type_description || ' to ' || fcst.compare_type_description AS compare_name
         FROM rpt_fam_compare_types fcst,
         rpt_fam_compare_types bkng
         WHERE fcst.event_type = 'FCST'
         AND bkng.event_type = 'BKNG'
         AND fcst.compare_type = bkng.compare_type
         WHERE event_type || ' ' || compare_type <> 'FCST AUTH_FTRS'
         AND compare_type NOT IN ('NET_SHIP', 'SHIP_NET_FTRS', 'NET_ETS', 'GROSS_FTRS')
         ) cmpr
    -- The two (2) in-line views are joined by EVENT_TYPE (i.e. 'FCST' and 'BKNG')
    -- to form a product of all RPT_FAM_FWEQ_DETAIL rows with comparison types
    WHERE dtl.trg_event_type = cmpr.event_type
    ORDER BY plan_ctry,
    division,
    season,
    monthly_seq,
    tier_num,
    level_num,
    tier_volume,
    trg_event_num,
    disp_event_num,
    max_event_num,
    first_display_event_num,
    level_type,
    level_value
    COMMIT
    INSERT INTO rpt_fam_FWEQ_detail_aggr
    SELECT plan_ctry,
    division,
    season,
    monthly_seq,
         bucket_month_date,
    tier_num,
    level_num,
    tier_volume,
    trg_event_num,
    disp_event_num,
    max_event_num,
    compare_name,
    first_display_event_num,
    level_type,
    level_value,
    'TOTAL' AS row_type,
    material,
    key_material,
    sap_cat_cd,
    sap_cat_desc,
    sap_sub_cat_cd,
    sap_sub_cat_desc,
    sty_colr_sdesc,
    sty_grp_nbr,
    sty_grp_desc,
    matl_typ,
    sap_prod_typ_grp, -- 'Type Group' in Brio
    typ_grp_desc, -- 'Type Group' in Brio
    curr_prod_i2_life_cyc_cd,
    NULL AS promo_ind, -- for future use
    -- Each RPT_FAM_FWEQ_DETAIL row's eight (8) quantity columns are broken down
    -- into F1_QTY from DISP_aaaa_QTY, F2_QTY from TRG_aaaa_QTY and
         -- AE from aaaa_AE where 'aaaa' is equal to one of the COMPARE_TYPEs below:
    -- F1_QTY
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    disp_dlvry_plan_qty
    WHEN compare_type = 'NET' THEN
    disp_net_qty
    WHEN compare_type = 'NET_AO' THEN
    disp_ao_qty
    WHEN compare_type = 'NET_FTRS' THEN
    disp_futr_qty
    WHEN compare_type = 'NET_REPLENS' THEN
    disp_replen_qty
    WHEN compare_type = 'AUTH_FTRS' THEN
    disp_auth_futr_qty
    END as f1_qty,
    -- F2_QTY
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    trg_dlvry_plan_qty
    WHEN compare_type = 'NET' THEN
    trg_net_qty
    WHEN compare_type = 'NET_AO' THEN
    trg_ao_qty
    WHEN compare_type = 'NET_FTRS' THEN
    trg_futr_qty
    WHEN compare_type = 'NET_REPLENS' THEN
    trg_replen_qty
    WHEN compare_type = 'AUTH_FTRS' THEN
    trg_auth_futures_qty
    END as f2_qty,
    -- AE
    CASE WHEN compare_type = 'DELIVERY_PLAN' THEN
    abs(disp_dlvry_plan_qty - trg_dlvry_plan_qty)
    WHEN compare_type = 'NET' THEN
    abs(disp_net_qty - trg_net_qty)
    WHEN compare_type = 'NET_AO' THEN
    abs(disp_ao_qty - trg_ao_qty)
    WHEN compare_type = 'NET_FTRS' THEN
    abs(disp_futr_qty - trg_futr_qty)
    WHEN compare_type = 'NET_REPLENS' THEN
    abs(disp_replen_qty - trg_replen_qty)
    WHEN compare_type = 'AUTH_FTRS' THEN
    abs(disp_auth_futr_qty - trg_auth_futures_qty)
    END as ae,
    SYSDATE AS zz_insert_tmst
    FROM
         -- This in-line view returns only LEVEL_NUM = 3 or LEVEL_TYPE = 'MATL' data
         (SELECT plan_ctry,
         division,
         season,
         monthly_seq,
              bucket_month_date,
         tier_num,
         level_num,
         tier_volume,
         trg_event_num,
         trg_event_type,
         disp_event_num,
         max_event_num,
         first_display_event_num,
         level_type,
         level_value,
         material,
         key_material,
         sap_cat_cd,
         sap_cat_desc,
         sap_sub_cat_cd,
         sap_sub_cat_desc,
         sty_colr_sdesc,
         sty_grp_nbr,
         sty_grp_desc,
         matl_typ,
         sap_prod_typ_grp, -- 'Type Group' in Brio
         typ_grp_desc, -- 'Type Group' in Brio
         curr_prod_i2_life_cyc_cd,
         sum(disp_net_qty) AS disp_net_qty,
              sum(trg_net_qty) AS trg_net_qty,
         -- ABS(sum(trg_net_qty) - sum(disp_net_qty)) AS net_AE,
         sum(disp_dlvry_plan_qty) AS disp_dlvry_plan_qty,
              sum(trg_dlvry_plan_qty) AS trg_dlvry_plan_qty,
         -- ABS(sum(trg_dlvry_plan_qty) - sum(disp_dlvry_plan_qty)) AS dlvry_plan_AE,
         sum(disp_futr_qty) AS disp_futr_qty,
              sum(trg_futr_qty) AS trg_futr_qty,
         -- ABS(sum(trg_futr_qty) - sum(disp_futr_qty)) AS futr_AE,
         sum(disp_ao_qty) AS disp_ao_qty,
              sum(trg_ao_qty) AS trg_ao_qty,
         -- ABS(sum(trg_ao_qty) - sum(disp_ao_qty)) AS ao_AE,
         sum(disp_replen_qty) AS disp_replen_qty,
              sum(trg_replen_qty) AS trg_replen_qty,
         -- ABS(sum(trg_replen_qty) - sum(disp_replen_qty)) AS replen_AE,
         sum(disp_futr_qty) AS disp_auth_futr_qty,
              sum(trg_auth_futures_qty) AS trg_auth_futures_qty --,
         -- ABS(sum(trg_auth_futures_qty) - sum(disp_futr_qty)) AS auth_futures_AE
         FROM rpt_fam_FWEQ_detail
         WHERE plan_ctry &where_plan_ctry
         and level_num = 3 -- 'MATERIAL'
         -- AND promo_ind <> 'Y'
         GROUP BY plan_ctry,
         division,
         season,
         monthly_seq,
              bucket_month_date,
         tier_num,
         level_num,
         tier_volume,
         trg_event_num,
         trg_event_type,
         disp_event_num,
         max_event_num,
         first_display_event_num,
         level_type,
         level_value,
         material,
         key_material,
         sap_cat_cd,
         sap_cat_desc,
         sap_sub_cat_cd,
         sap_sub_cat_desc,
         sty_colr_sdesc,
         sty_grp_nbr,
         sty_grp_desc,
         matl_typ,
         sap_prod_typ_grp, -- 'Type Group' in Brio
         typ_grp_desc, -- 'Type Group' in Brio
         curr_prod_i2_life_cyc_cd
         ) dtl,
         -- The following in-line view returns all of the different combinations
         -- of comparison types in the RPT_FAM_FWEQ_DETAIL table
         -- This select returns the pairing of all forecast types
         SELECT event_type, compare_type, compare_name
         from
         (SELECT event_type, compare_type, compare_type_description || ' to ' || compare_type_description AS compare_name
         FROM rpt_fam_compare_types
         WHERE event_type = 'FCST'
         UNION
         -- This select returns the pairing of all bookings types with forecast types
         SELECT bkng.event_type, fcst.compare_type, bkng.compare_type_description || ' to ' || fcst.compare_type_description AS compare_name
         FROM rpt_fam_compare_types fcst,
         rpt_fam_compare_types bkng
         WHERE fcst.event_type = 'FCST'
         AND bkng.event_type = 'BKNG'
         AND fcst.compare_type = bkng.compare_type
         WHERE event_type || ' ' || compare_type <> 'FCST AUTH_FTRS'
         AND compare_type NOT IN ('NET_SHIP', 'SHIP_NET_FTRS', 'NET_ETS', 'GROSS_FTRS')
         ) cmpr
    -- The two (2) in-line views are joined by EVENT_TYPE (i.e. 'FCST' and 'BKNG')
    -- to form a product of all RPT_FAM_FWEQ_DETAIL rows with comparison types
    WHERE dtl.trg_event_type = cmpr.event_type
    ORDER BY plan_ctry,
    division,
    season,
    monthly_seq,
    tier_num,
    level_num,
    tier_volume,
    trg_event_num,
    disp_event_num,
    max_event_num,
    first_display_event_num,
    level_type,
    level_value
    COMMIT
    /

    I agree.
    SELECT ticket_no,name_of_the_passenger..
    FROM ticket_master
    WHERE ticket_no NOT IN
    (SELECT Ticket_no
    FROM ticket_cancellations
    WHERE trip_id = my_trip_id);
    This involves creating a little temp table for each record in ticket_no. Then full scanning it.
    Change it to
    SELECT ticket_no,name_of_the_passenger..
    FROM ticket_master B
    WHERE ticket_no NOT EXISTS
    (SELECT null
    FROM ticket_cancellations A
    WHERE A.ticket_no = B.ticket_no
    AND trip_id = my_trip_id);
    Then you get an index hit in both cases.

  • There are many complaints about iMesh, but no answers as to how to get iMesh OFF the browser after it's been uninstalled. Can Firefox PLEASE direct us how to get rid of this program. Thank you. Lucille H

    Many complaints in ASK QUESTIONS about getting rid of iMesh in a browser, but no answer is provided. Please instruct your users how to get rid of this program. I got the install information from iMesh directly but my browser will not clear it, even if I change my home page. It's an impossible program to get rid of. This can't be legal. Thanks,
    Lucille Hunt
    Mack Avenue Records.

    Hi St. Peter. Thanks for your advice. I tried entering firefox.exe as you suggeted, but got the Just Ask Jeeves page again. You suggested uninstalling Just Ask Jeeves, but I`m not sure how to go about this since it doesn`t appear in my programmes. Thanks for your help.

  • How to improve performance of the program

    I have this program which loops 3 times and in each loop it creates differents variants and calls the program passing these variants. Now the pple who run this program say that the performance of the program decreased. They say that if this run it takes 3times more time than running individual program 3 times seperately. Any ideas on how i should go about this. Seems like with in the loop the all the information about the second program which is being called is stored.Any ideas on how to clear the program memory with in the loop.

    Let me explain in little more detail. The program which i wrote create variants in a loop and passes them to the report which is also called inside the loop like.
    do 3 times.
    *create variant.
    submit <program> X via selection-screen using tables....
    enddo.
    Now what this report does is it just retrieves like 500,000 records and updates them to another table.

  • How to improve profamance of this

    Hi Gurus,
    how to increase perfomance of this statement .
    LOOP AT HEADCOUNT_TABLE.
        SELECT COUNT(*) INTO HEADCOUNT_TABLE-ZSEXEMPT
          FROM PA0000 INNER JOIN PA0001
            ON PA0000PERNR =  PA0001PERNR
         WHERE PA0001~KOSTL =  HEADCOUNT_TABLE-KOSTL
           AND PA0001~BUKRS =  HEADCOUNT_TABLE-BUKRS
           AND PA0000~BEGDA <= PROCESS_DATE
           AND PA0000~ENDDA >= PROCESS_DATE
           AND PA0000~STAT1 =  '3'
           AND PA0001~BEGDA <= PROCESS_DATE
           AND PA0001~ENDDA >= PROCESS_DATE
           AND PA0001~PERSG IN ('O', 'X', 'E', 'Y', 'T', 'A', 'I', 'L','F',
                                'S','D').
    SELECT COUNT(*) INTO HEADCOUNT_TABLE-ZSCONTRACTOR
          FROM PA0000 INNER JOIN PA0001
            ON PA0000PERNR =  PA0001PERNR
         WHERE PA0001~KOSTL =  HEADCOUNT_TABLE-KOSTL
           AND PA0001~BUKRS =  HEADCOUNT_TABLE-BUKRS
           AND PA0000~BEGDA <= PROCESS_DATE
           AND PA0000~ENDDA >= PROCESS_DATE
           AND PA0000~STAT1 =  '3'
           AND PA0001~BEGDA <= PROCESS_DATE
           AND PA0001~ENDDA >= PROCESS_DATE
           AND PA0001~PERSG IN ('7', '8', '9').
    endloop.
    Thanks,
    Kumar

    Let's all go back to the requirement of this guy.
    Please correct me if I'm wrong kumar.
    The requirement are for each combination of company code (BUKRS) and cost center (KOSTL), count the number of active 'ZSEXEMPT' personnel (persg in ('O', 'X', 'E', 'Y', 'T', 'A', 'I', 'L','F','S','D')) and the number of active 'ZSCONTRACTOR' personnel (PERSG IN ('7', '8', '9')) in a specific key date (PROCESS_DATE).
    Rightfuly, combination of BUKRS and KOSTL should be unique in HEADCOUNT_TABLE if above is the requirement and in the specific key date, PERNR is the key for P0000 and P0001.
    If HEADCOUNT_TABLE does not contain all combination of BUKRS and KOSTL, you have to use for all entries as below example.
    if HEADCOUNT_TABLE[] is not initial.
    Select PA0000~PERNR
                       PA0001~KOSTL
                      PA0001~BUKRS
                       into table itab_ZSEXEMPT
                      from PA0000 INNER JOIN PA0001
    ON PA0000~PERNR = PA0001~PERNR
    for all entries in headcount_table
    WHERE PA0001~KOSTL = HEADCOUNT_TABLE-KOSTL
    AND PA0001~BUKRS = HEADCOUNT_TABLE-BUKRS
    AND PA0000~BEGDA <= PROCESS_DATE
    AND PA0000~ENDDA >= PROCESS_DATE
    AND PA0000~STAT1 = '3'
    AND PA0001~BEGDA <= PROCESS_DATE
    AND PA0001~ENDDA >= PROCESS_DATE
    AND PA0001~PERSG IN ('O', 'X', 'E', 'Y', 'T', 'A', 'I', 'L','F',
    'S','D').
    Select PA0000~PERNR
              PA0001~KOSTL
              PA0001~BUKRS into table itab_ZSCONTRACTOR
                      from PA0000 INNER JOIN PA0001
    ON PA0000~PERNR = PA0001~PERNR
    for all entries in headcount_table
    WHERE PA0001~KOSTL = HEADCOUNT_TABLE-KOSTL
    AND PA0001~BUKRS = HEADCOUNT_TABLE-BUKRS
    AND PA0000~BEGDA <= PROCESS_DATE
    AND PA0000~ENDDA >= PROCESS_DATE
    AND PA0000~STAT1 = '3'
    AND PA0001~BEGDA <= PROCESS_DATE
    AND PA0001~ENDDA >= PROCESS_DATE
    AND PA0001~PERSG IN ('7', '8', '9').
    endif.
    sort itab_ZSEXEMPT by kostl bukrs.
    sort itab_ZSCONTRACTOR by kostl bukrs.
    refresh temp_itab.
    loop at HEADCOUNT_TABLE assigning <FS_HEADCOUNT>.
       temp_itab[] = itab_zsexempt[].
       delete temp_itab where bukrs NE <FS_HEADCOUNT>-bukrs and
                                      kostl NE <FS_HEADCOUNT>-kostl.
       describe table temp_itab lines <FS_HEADCOUNT>-ZSEXEMPT.
       refresh temp_itab.
       temp_itab[] = itab_ZSCONTRACTOR [].
       delete temp_itab where bukrs NE <FS_HEADCOUNT>-bukrs and
                                      kostl NE <FS_HEADCOUNT>-kostl.
       describe table temp_itab lines <FS_HEADCOUNT>-ZSCONTRACTOR .
       refresh temp_itab.
    endloop.
    Try that and compare the performance.
    Regards,
    Abraham

  • How to Improve perfomance of this query

    Hi,
    Please help me to improve this query performance. Objective of this query is to find out individual count who order the product in last two year and create a matrix with time period
    Challenge is Both the table having more than 600 million record so it is taking to much time to execute
    SELECT count(unique b.individual_id),
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955'))>= SYSDATE - 45 THEN 1 ELSE 0 END )) AS one_month ,
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955'))>= SYSDATE - 105 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 45 THEN 1 ELSE 0 END )) AS Three_month,
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 195 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 105 THEN 1 ELSE 0 END )) AS six_month,
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 380 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 195 THEN 1 ELSE 0 END )) AS one_year,
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 745 and NVL(ORDER_DT,TO_DATE('05-MAY-1955'))<= SYSDATE - 380 THEN 1 ELSE 0 END )) AS two_year
    from ORDER b, address a
    where b.individual_id = a.individual_id
    and a.COUNTRY_CD ='US'
    group by a.COUNTRY_CD ;
    Thanks
    Neeraj
    Edited by: user4522368 on Aug 17, 2010 12:10 AM

    user4522368 wrote:
    Hi,
    Please help me to improve this query performance. Objective of this query is to find out individual count who order the product in last two year and create a matrix with time period
    Challenge is Both the table having more than 600 million record so it is taking to much time to execute Dombrooks has provided you with an excellent response.
    In addition, you should mention how much time the query is currently taking and how much do you expect it to take, what is your database version etc.
    One of the most important thing is to post your SQLs and EXPLAIN PLAN outcomes in readable format. You can do this by wrapping it within \ and \ tags.
    Now, based on the limited details that you have provided, following are my questions/observations:
    a) You claim that both tables have more than 600 million rows but your plan shows that optimizer is expecting to find only 46 million rows in ORDER table. You may want to confirm if statistics on both the tables are correct.
    b) Your plan appears to suggest that the UNIQUE is not affecting the query results. Based on your knowledge of your data, do you need the COUNT(UNIQUE individual_id) or can it be just COUNT(individual_id)?
    c) Finally, if you are interested in only last two years of data, you should probably have a WHERE predicate on your ORDER table which filters data based on ORDER_DT. Something like following:
    SELECT count(unique b.individual_id),
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955'))>= SYSDATE - 45 THEN 1 ELSE 0 END )) AS one_month ,
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955'))>= SYSDATE - 105 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 45 THEN 1 ELSE 0 END )) AS Three_month,
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 195 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 105 THEN 1 ELSE 0 END )) AS six_month,
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 380 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 195 THEN 1 ELSE 0 END )) AS one_year,
    sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 745 and NVL(ORDER_DT,TO_DATE('05-MAY-1955'))<= SYSDATE - 380 THEN 1 ELSE 0 END )) AS two_year
    from ORDER b, address a
    where b.individual_id = a.individual_id
    and a.COUNTRY_CD ='US'
    and b.ORDER_DT <= (SYSDATE - 380)
    group by a.COUNTRY_CD ;

  • How to improve performance of this SQL query?

    Hi,
    I have a query that tries to build a string (RPATH) for use as a url parameter. The query is:
    SELECT DISTINCT USERNAME, PASSWORD, ROLE, RIGHTS,
    DECODE(GEO, ROLE, 'g='||NVL(GEO,'none'), NULL)||
         DECODE(AREA, ROLE, 'g='||NVL(GEO,'none')||'&a='||NVL(AREA,'none'), NULL)||
         DECODE(REGION, ROLE, 'g='||NVL(GEO,'none')||'&a='||NVL(AREA,'none')||'&r='||NVL(REGION,'none'), NULL)||
         DECODE(DISTRICT, ROLE, 'g='||NVL(GEO,'none')||'&a='||NVL(AREA,'none')||'&r='||NVL(REGION,'none')||'&d='||NVL(DISTRICT,'none'), NULL)||
         DECODE(OFFICE, ROLE, 'g='||NVL(GEO,'none')||'&a='||NVL(AREA,'none')||'&r='||NVL(REGION,'none')||'&d='||NVL(DISTRICT,'none')||'&o='||NVL(OFFICE,'none')
    , NULL) RPATH
    FROM (SELECT U.*, L.*
         FROM (SELECT * FROM T_USERS WHERE USERNAME='xxx' AND PASSWORD='yyy') U, T_LOC_SUB L
         WHERE U.ROLE IN ('WW', L.GEO, L.AREA, L.REGION, L.DISTRICT, L.OFFICE))
    GROUP BY USERNAME, PASSWORD, ROLE, RIGHTS, GEO, AREA, REGION, DISTRICT, OFFICE;
    T_USERS is defined as
    CREATE TABLE T_USERS (
    username          VARCHAR2(10)     CONSTRAINT T_USERS_username_pk PRIMARY KEY,
    password          VARCHAR2(10),
    role                    CONSTRAINT T_USERS_role_FK REFERENCES T_LOC_MAIN(loc),
    rights          VARCHAR2(3)
    T_LOC_SUB is defined as
    CREATE TABLE T_LOC_SUB (
    geo          CONSTRAINT T_LOC_SUB_geo_FK REFERENCES T_LOC_MAIN(loc),
    area          CONSTRAINT T_LOC_SUB_area_FK REFERENCES T_LOC_MAIN(loc),
    region          CONSTRAINT T_LOC_SUB_region_FK REFERENCES T_LOC_MAIN(loc),
    district     CONSTRAINT T_LOC_SUB_district_FK REFERENCES T_LOC_MAIN(loc),
    office          CONSTRAINT T_LOC_SUB_office_FK REFERENCES T_LOC_MAIN(loc)
    T_LOC_MAIN is defined as
    CREATE TABLE T_LOC_MAIN (
    loc          VARCHAR2(4)     CONSTRAINT T_LOC_MAIN_loc_PK PRIMARY KEY,
    label          VARCHAR2(60),
    rank          NUMBER
    REGION and DISTRICT columns in T_LOC_SUB may be NULL at times. How can I rewrite the SQL to make it run faster or more efficiently?
    Please help.. Thank you..

    Hi,
    I just realised I can simplify the query to:
    SELECT DISTINCT USERNAME, PASSWORD, ROLE, RIGHTS,
    DECODE(ROLE,
         GEO, 'g='||NVL(GEO,'none'),
         AREA, 'g='||NVL(GEO,'none')||'&a='||NVL(AREA,'none'),
         REGION, 'g='||NVL(GEO,'none')||'&a='||NVL(AREA,'none')||'&r='||NVL(REGION,'none'),
         DISTRICT, 'g='||NVL(GEO,'none')||'&a='||NVL(AREA,'none')||'&r='||NVL(REGION,'none')||'&d='||NVL(DISTRICT,'none'),
         OFFICE, 'g='||NVL(GEO,'none')||'&a='||NVL(AREA,'none')||'&r='||NVL(REGION,'none')||'&d='||NVL(DISTRICT,'none')||'&o='||NVL(OFFICE,'none'),
         NULL) RPATH
    FROM (SELECT U.*, L.*
    FROM (SELECT * FROM T_USERS WHERE USERNAME='xxx' AND PASSWORD='yyy') U, T_LOC_SUB L
    WHERE U.ROLE IN ('WW', L.GEO, L.AREA, L.REGION, L.DISTRICT, L.OFFICE))
    GROUP BY USERNAME, PASSWORD, ROLE, RIGHTS, GEO, AREA, REGION, DISTRICT, OFFICE;
    Anyone can offer a better and more efficient improvement?
    Thanx!

  • How to improve Performace of this data.

    Hi All,
    We have ticket_master table with 200,000 currently and grows 2000 records per day. structure is
    ticket_no VARCHAR2(20) PK,
    trip_id VARCHAR2(20) RK refers to trip_master(trip_id),
    passenger_name,fare,boarding etc...
    second table is Ticket_cancellations currently 5000 records and daily it gets 50 records minimum.
    Ticket_no RK references to TIcket_master(ticket_no),
    cancellation_charges.... etc.
    like if we need to see list of passengers for any trip we are querying like this
    SELECT ticket_no,name_of_the_passenger.. FROM ticket_master WHERE ticket_no NOT IN (SELECT Ticket_no FROM ticket_cancellations) WHERE trip_id = my_trip_id;
    it seems the performance is getting reduced with the growing size of both tables.
    Is there any way we can improve this performace. we have indexes created on both tables.
    Thanks in advance

    I agree.
    SELECT ticket_no,name_of_the_passenger..
    FROM ticket_master
    WHERE ticket_no NOT IN
    (SELECT Ticket_no
    FROM ticket_cancellations
    WHERE trip_id = my_trip_id);
    This involves creating a little temp table for each record in ticket_no. Then full scanning it.
    Change it to
    SELECT ticket_no,name_of_the_passenger..
    FROM ticket_master B
    WHERE ticket_no NOT EXISTS
    (SELECT null
    FROM ticket_cancellations A
    WHERE A.ticket_no = B.ticket_no
    AND trip_id = my_trip_id);
    Then you get an index hit in both cases.

  • How to improve performence of CRM_ORDER_MAINTAIN?

    Hi Experts,
    I am doing lead upload from flat file using CRM_ORDER_MAINTAIN.
    If the file contains records upto 50 ,it is taking aorund 6 to 10 min.
    If file contains records upto 100,it is taking 30 to 40 min.
    For around 250 records ,it has taken around 4 hours.
    Please advice on improving the performance.
    Thanks,
    Adi.

    Adi,
    I would look at using CRMXIF_ORDER_SAVE instead to upload your leads.  You also need to look at your "block size", which is basically how many records do you upload before performing a commit work in CRM? 
    Also check to see if you are properly refreshing the buffers during each upload of a block of transactions.
    Take care,
    Stephen

  • I do not receive MLB in my area for Yankees, Mets, or Phillies. How do I  receive for this program?

    This is terrible, how confusing to any senior using this APPLE TV PRODUCT!!!

    You have to subscribe, I believe, if you have not done so already:
    http://mlb.mlb.com/mlb/subscriptions/index.jsp?product=appletv
    and then some games are subject to blackouts in some areas. Read the information at the bottom of that page, and there's a list of national games that are blacked out here:
    http://mlb.mlb.com/mlb/official_info/broadcasts/national_wkend.jsp
    Regards.

  • How to improve performence of the procedure using regular expressions

    Hi all,
    I have used substr, instr functions in this procedure .
    Kindly tell me how use regular_expressions in this procedure .
    /* Formatted on 2011/07/20 17:18 (Formatter Plus v4.8.8) */
    PROCEDURE pr_insrt_prcdr_rvne_edit ( --ver 4.4
    p_pa_rqst_sid IN NUMBER,
    p_err_code OUT NUMBER,
    p_err_msg OUT VARCHAR2
    IS
    v_count NUMBER;
    CURSOR error_dtls
    IS
    SELECT parent_target_table_sid, inbnd_target_table_cid,
    target_table_sid
    FROM inbnd_278_error
    WHERE parent_target_table_sid = p_pa_rqst_sid
    AND SUBSTR (error_data_value, INSTR (error_data_value, ':') + 1) IN
    ('5056', '5031');
    CURSOR error_values (
    p_target_table_sid inbnd_278_error.target_table_sid%TYPE
    IS
    SELECT MAX (DECODE (SUBSTR (error_data_value,
    INSTR (error_data_value, ':', 1) + 1
    '5056', SUBSTR (error_data_value,
    1,
    INSTR (error_data_value, ':', 1) - 1
    ) AS e5056,
    MAX (DECODE (SUBSTR (error_data_value,
    INSTR (error_data_value, ':', 1) + 1
    '5031', SUBSTR (error_data_value,
    1,
    INSTR (error_data_value, ':', 1) - 1
    ) AS e5031
    FROM inbnd_278_error
    WHERE target_table_sid = p_target_table_sid
    AND SUBSTR (error_data_value, INSTR (error_data_value, ':', 1) + 1) IN
    ('5056', '5031');
    v_error_values error_values%ROWTYPE;
    BEGIN
    p_err_code := 0;
    p_err_msg := 'Success';
    FOR curr_error_dtls_rec IN error_dtls
    LOOP
    OPEN error_values (curr_error_dtls_rec.target_table_sid);
    FETCH error_values
    INTO v_error_values;
    IF (v_error_values.e5056 IS NOT NULL
    AND v_error_values.e5031 IS NOT NULL
    THEN
    DELETE FROM inbnd_278_error
    WHERE SUBSTR (error_data_value,
    INSTR (error_data_value, ':') + 1
    ) IN ('5056', '5031')
    AND target_table_sid = curr_error_dtls_rec.target_table_sid
    AND inbnd_target_table_cid = 109;
    INSERT INTO inbnd_278_error
    (inbnd_278_error_sid,
    parent_target_table_sid, inbnd_target_table_cid,
    target_table_sid, meta_data_cid,
    error_data_value,
    created_by, created_date
    VALUES (inbnd_278_error_seq.NEXTVAL,
    curr_error_dtls_rec.parent_target_table_sid, 109,
    curr_error_dtls_rec.target_table_sid, 161,
    v_error_values.e5056
    || ','
    || v_error_values.e5031
    || ':'
    || '5059',
    1, SYSDATE
    END IF;
    CLOSE error_values;
    END LOOP;
    EXCEPTION
    WHEN OTHERS
    THEN
    p_err_code := SQLCODE;
    p_err_msg :=
    'Error occured in pr_insrt_prcdr_rvne_edit procedure '
    || SUBSTR (SQLERRM, 1, 100);
    END pr_insrt_prcdr_rvne_edit;
    Thanks,
    P Prakash
    Edited by: prakash on Jul 20, 2011 4:48 AM

    Yes as explained in the forum FAQ which you should read
    http://forums.oracle.com/forums/ann.jspa?annID=1535
    *2. How do I ask a question on the forums?*
    SQL and PL/SQL FAQ
    And the section beginning.
    *9) Formatting with {noformat}{noformat} Tags*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to Make Sub_menu in this programming

    Hi Friends,
    I'm Ravi Maheshwari a silent member of Sun Developer Network. I have a problem. I am making drop down menu but not able to make sub-menu for that. I'm using JSP file in which i'm inculding JS File for the menu running on Tomcat.
    Here i'm giving a piece of code for your consideration ple give me the solution how i can make sub-menu. It is urgent.
    Thanks in advance...
    Coding::
    Part of JS File where it creats menu:
    var menu1=new Array()
    menu1[0]='Add / Modify'
    menu1[1]='Assign' //onclick="openMyWindow()"
    menu1[2]='Setting'
    menu1[3]='Import / Export Data'
    menu1[4]='Search'
    menu1[5]='Test Summry'
    JSP File where i'm calling it :
    <tr>
    <td height="40" align="left" valign="top"> </td>
    <td align="left" valign="top"><img src="images/admin1.jpg" width="155" height="32"></td>
    </tr>
    ple help me...or let me know where i'm commiting mistake....

    .or let me know where i'm commiting mistake....You are posting this on a Java forum rather than JavaScript forum.

  • Can someone explain how garbage collector works in this program ?

    class Chair {
    static boolean gcrun = false;
    static boolean f = false;
    static int created = 0;
    static int finalized = 0;
    int i;
    Chair() {
    i = ++created;
    if(created == 47)
    System.out.println("Created 47");
    public void finalize() {
    if(!gcrun) {
    // The first time finalize() is called:
    gcrun = true;
    System.out.println(
    "Beginning to finalize after " +
    created + " Chairs have been created");
    if(i == 47) {
    System.out.println(
    "Finalizing Chair #47, " +
    "Setting flag to stop Chair creation");
    f = true;
    finalized++;
    if(finalized >= created)
    System.out.println(
    "All " + finalized + " finalized");
    public class Garbage {
    public static void main(String[] args) {
    // As long as the flag hasn't been set,
    // make Chairs and Strings:
    while(!Chair.f) {
    new Chair();
    new String("To take up space");
    System.out.println(
    "After all Chairs have been created:\n" +
    "total created = " + Chair.created +
    ", total finalized = " + Chair.finalized);
    // Optional arguments force garbage
    // collection & finalization:
    if(args.length > 0) {
    if(args[0].equals("gc") ||
    args[0].equals("all")) {
    System.out.println("gc():");
    System.gc();
    if(args[0].equals("finalize") ||
    args[0].equals("all")) {
    System.out.println("runFinalization():");
    System.runFinalization();
    System.out.println("bye!");
    } ///:~
    This code is From Bruce Eckel's "thinking in Java"
    Here is what I understand and what I don't
    At a certain point during the execution of the while loop (in the method main), the garbage collector kicks in and will call the method finalize() -
    I am at a loss as to what happens afterwards -
    Do the chairs continue to get created (which means the variable i keeps incrementing) and the finalize method keep getting called (which means finalized keeps incrementing) till the system realizes it is really low on memory and starts reclaiming memory ie i now starts decrementing ?
    What I would like to know is the exact flow or execution of the code after the garbage collector starts kicking in ie. what happens to the variables "i" (does it increment and then decrement), "created" (does it keep incrementing ), "finalized" (does it keep incrementing) and when is the if i==47{ } statement within finalize() get executed.
    There is no part of the code where i is being decremented (so I am guessing that it is the garbage collector reclaiming object memory that must be decrementing it).
    I am really confused -unfortunately there's very little in the book that really explains the flow of execution after the garbage collector kicks in and finalize() is called.
    Any help would be greatly appreciated

    Nice example, but Bruce chose some suboptimal names, I think.
    "i" can be thought of as the "ID" of a given Chair (note that it is not static). It is neither incremented nor decremented - it's just assigned from "created". This lets us identify specific chairs (like, say, "Chair #47").
    "created" is a running total of the number of times the Chair constructor has been called.
    "finalized" is a running total of the number of Chairs that have been finalized.
    The process starts creating Chairs as fast as it can. Eventually, memory gets low, and gc() starts collecting Chairs. While that's happening, chairs are still being created in the main Thread. So "created" and "finalized" may both be incrementing at the same time.
    When gc() picks Chair#47, the finalizer code sets a flag that causes new Chairs to stop being created. This causes the program to fall out of the while() loop, and the program spits out its data and exits.
    On my machine, the program created 29,542 chairs before exiting.
    Remember - often, gc() runs only when/if the JVM decides it's running low on memory. Specifics depend on the JVM and the startup options you use - some JVMs are very, very clever about doing incremental garbage-collection these days.
    Does that make more sense?
    Grant
    (PS - it's very, very good that you posted a working code sample. But learn about the \[code\] and \[code\] tags, please - makes your sample WAY easier to read...)

  • How to improve performance for this code

    Hi,
    LOOP AT lt_element INTO ls_element.
    READ TABLE lt_element_ident INTO ls_element_ident
    WITH KEY element_id = ls_element-element_id BINARY SEARCH.
    IF sy-subrc EQ 0.
    MOVE ls_element_ident-value TO lv_guid.
    SELECT * FROM zcm_valuation_at
    APPENDING CORRESPONDING FIELDS OF TABLE lt_caseattributes
    WHERE case_guid = lv_guid.
    ENDIF.
    ENDLOOP.
    LOOP AT lt_caseattributes INTO ls_caseattributes.
    IF ls_caseattributes-ext_key IS INITIAL.
    SELECT SINGLE ext_key
    INTO CORRESPONDING FIELDS OF ls_caseattributes
    FROM scmg_t_case_attr
    WHERE case_guid = ls_caseattributes-case_guid.
    ENDIF.
    *To get the Status description of the Case
    SELECT SINGLE stat_ordno_descr
    INTO ls_caseattributes-status
    FROM scmgstatprofst AS a
    INNER JOIN scmg_t_case_attr AS b
    ON aprofile_id = bprofile_id
    AND astat_orderno = bstat_orderno
    WHERE case_guid = ls_caseattributes-case_guid.
    MODIFY lt_caseattributes FROM ls_caseattributes INDEX sy-tabix TRANSPORTING status ext_key.
    ENDLOOP.
    READ TABLE lt_caseattributes INTO ls_caseattributes INDEX 1.
    Regards,
    Maruti

    Hi,
    try this kind of code:
    ==================================
    start new
    DATA:
      lt_scmgstatprofst LIKE scmgstatprofst OCCURS 0 WITH HEADER LINE,
      wa_scmg_t_case_attr LIKE scmg_t_case_attr.
    SELECT * FROM scmgstatprofst INTO TABLE lt_scmgstatprofst.
    SORT lt_scmgstatprofst BY profile_id stat_orderno.
    end new
    LOOP AT lt_element INTO ls_element.
      READ TABLE lt_element_ident INTO ls_element_ident
      WITH KEY element_id = ls_element-element_id BINARY SEARCH.
      IF sy-subrc EQ 0.
        MOVE ls_element_ident-value TO lv_guid.
        SELECT * FROM zcm_valuation_at
        APPENDING CORRESPONDING FIELDS OF TABLE lt_caseattributes
        WHERE case_guid = lv_guid.
      ENDIF.
    ENDLOOP.
    LOOP AT lt_caseattributes INTO ls_caseattributes.
      IF ls_caseattributes-ext_key IS INITIAL.
        SELECT SINGLE ext_key
        INTO CORRESPONDING FIELDS OF ls_caseattributes
        FROM scmg_t_case_attr
        WHERE case_guid = ls_caseattributes-case_guid.
      ENDIF.
    *To get the Status description of the Case
    start deletion
    SELECT SINGLE stat_ordno_descr
    INTO ls_caseattributes-status
    FROM scmgstatprofst AS a
    INNER JOIN scmg_t_case_attr AS b
    ON aprofile_id = bprofile_id
    AND astat_orderno = bstat_orderno
    WHERE case_guid = ls_caseattributes-case_guid.
    end deletion
    start new
      CLEAR wa_scmg_t_case_attr.
      SELECT SINGLE * FROM scmg_t_case_attr INTO wa_scmg_t_case_attr
        WHERE case_guid = ls_caseattributes-case_guid.
      READ TABLE lt_scmgstatprofst WITH KEY
        profile_id   = wa_scmg_t_case_attr-profile_id
        stat_orderno = wa_scmg_t_case_attr-stat_orderno
        BINARY SEARCH.
      IF sy-subrc IS INITIAL.
        ls_caseattributes-status = lt_scmgstatprofst-stat_ordno_descr.
      ENDIF.
    end new
      MODIFY lt_caseattributes FROM ls_caseattributes INDEX sy-tabix
      TRANSPORTING status ext_key.
    ENDLOOP.
    READ TABLE lt_caseattributes INTO ls_caseattributes INDEX 1.
    ==================================
    Regards
    Walter Habich
    Edited by: Walter Habich on Jun 17, 2008 8:41 AM

  • How to Improve Performance of this query??

    Hi experts,
    Kindly suggest me some perfomance optimization on the below code.
    SELECT * FROM vtrdi AS v
                   INTO TABLE six
                   FOR ALL ENTRIES IN r_vbeln
                   WHERE vbeln EQ  r_vbeln-low
                   AND   trsta IN  s_trsta
                   AND   vstel IN  s_vstel
                   AND   tddat IN  s_tddat
                   AND   vbtyp IN  r_vbtyp
                   AND   lstel IN  s_lstel
                   AND   route IN  s_route
                   AND   tragr IN  s_tragr
                   AND   vsbed IN  s_vsbed
                   AND   land1 IN  s_land1
                   AND   lzone IN  s_lzone
                   AND   wadat IN  s_wadat
                   AND   wbstk IN  s_wbstk
                   AND   lddat IN  s_lddat
                   AND   lfdat IN  s_lfdat
                   AND   kodat IN  s_kodat
                   AND   kunnr IN  s_kunnr
                   AND   spdnr IN  s_spdnr
                   AND   inco1 IN  s_inco1
                   AND   inco2 IN  s_inco2
                   AND   lprio IN  s_lprio
                   AND EXISTS ( SELECT * FROM likp
                                  WHERE vbeln EQ v~vbeln
                                  AND lifnr IN s_lifnr    
                                  AND lgtor IN s_lgtor
                                  AND lgnum IN s_lgnum
                                  AND lfuhr IN s_lfuhr
                                  AND aulwe IN s_aulwe
                                  AND traty IN s_traty
                                  AND traid IN s_traid
                                  AND vsart IN s_vsart
                                  AND trmtyp IN s_trmtyp
                                  AND sdabw IN s_sdabw
                                  AND cont_dg IN r_cont_dg ).
    Thanks in Advance...
    Santosh.

    Try to write 2 select
    SELECT * FROM vtrdi AS v
    INTO TABLE six
    FOR ALL ENTRIES IN r_vbeln
    WHERE vbeln EQ r_vbeln-low
    AND trsta IN s_trsta
    AND vstel IN s_vstel
    AND tddat IN s_tddat
    AND vbtyp IN r_vbtyp
    AND lstel IN s_lstel
    AND route IN s_route
    AND tragr IN s_tragr
    AND vsbed IN s_vsbed
    AND land1 IN s_land1
    AND lzone IN s_lzone
    AND wadat IN s_wadat
    AND wbstk IN s_wbstk
    AND lddat IN s_lddat
    AND lfdat IN s_lfdat
    AND kodat IN s_kodat
    AND kunnr IN s_kunnr
    AND spdnr IN s_spdnr
    AND inco1 IN s_inco1
    AND inco2 IN s_inco2
    AND lprio IN s_lprio.
    SELECT * FROM likp  into table itab
    WHERE vbeln EQ v~vbeln
    AND lifnr IN s_lifnr
    AND lgtor IN s_lgtor
    AND lgnum IN s_lgnum
    AND lfuhr IN s_lfuhr
    AND aulwe IN s_aulwe
    AND traty IN s_traty
    AND traid IN s_traid
    AND vsart IN s_vsart
    AND trmtyp IN s_trmtyp
    AND sdabw IN s_sdabw
    AND cont_dg IN r_cont_dg
    loop at six
      check whether entry is exists or not
    if not remove from six interbal table.
    endloop.
    Thanks
    Venkat

Maybe you are looking for