How to improve perofrmance of ABAP Prgs

To Improve the <b>Performance of ABAP Programs</b> what are the steps to follow,can anybody give me brief explanation.
Thanks & Regards
Chinna.T

Hai Chinna
go through the following Documents having Example Code
For all entries
Nested selects
Select using JOINS
Use the selection criteria
Use the aggregated functions
Select with view
Select with index support
Select … Into table
Select with selection list
Key access to multiple lines
Copying internal tables
Modifying a set of lines
Deleting a sequence of lines
Linear search vs. binary
Comparison of internal tables
Modify selected components
Appending two internal tables
Deleting a set of lines
Tools available in SAP to pin-point a performance problem
Optimizing the load of the database
For all entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Some steps that might make FOR ALL ENTRIES more efficient:
Removing duplicates from the driver table
Sorting the driver table
If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
               FOR ALL ENTRIES IN i_tab
                  WHERE mykey >= i_tab-low and
             mykey <= i_tab-high.
Nested selects
The plus:
Small amount of data
Mixing processing and reading of data
Easy to code - and understand
The minus:
Large amount of data
when mixed processing isn’t needed
Performance killer no. 1
Select using JOINS
The plus
Very large amount of data
Similar to Nested selects - when the accesses are planned by the programmer
In some cases the fastest
Not so memory critical
The minus
Very difficult to program/understand
Mixing processing and reading of data not possible
Use the selection criteria
SELECT * FROM SBOOK.                   
  CHECK: SBOOK-CARRID = 'LH' AND       
                  SBOOK-CONNID = '0400'.        
ENDSELECT.                             
SELECT * FROM SBOOK                     
  WHERE CARRID = 'LH' AND               
        CONNID = '0400'.                
ENDSELECT.                              
Use the aggregated functions
C4A = '000'.              
SELECT * FROM T100        
  WHERE SPRSL = 'D' AND   
        ARBGB = '00'.     
  CHECK: T100-MSGNR > C4A.
  C4A = T100-MSGNR.       
ENDSELECT.                
SELECT MAX( MSGNR ) FROM T100 INTO C4A 
WHERE SPRSL = 'D' AND                
       ARBGB = '00'.                  
Select with view
SELECT * FROM DD01L                    
  WHERE DOMNAME LIKE 'CHAR%'           
        AND AS4LOCAL = 'A'.            
  SELECT SINGLE * FROM DD01T           
    WHERE   DOMNAME    = DD01L-DOMNAME 
        AND AS4LOCAL   = 'A'           
        AND AS4VERS    = DD01L-AS4VERS 
        AND DDLANGUAGE = SY-LANGU.     
ENDSELECT.                             
SELECT * FROM DD01V                    
WHERE DOMNAME LIKE 'CHAR%'           
       AND DDLANGUAGE = SY-LANGU.     
ENDSELECT.                             
Select with index support
SELECT * FROM T100            
WHERE     ARBGB = '00'      
       AND MSGNR = '999'.    
ENDSELECT.                    
SELECT * FROM T002.             
  SELECT * FROM T100            
    WHERE     SPRSL = T002-SPRAS
          AND ARBGB = '00'      
          AND MSGNR = '999'.    
  ENDSELECT.                    
ENDSELECT.                      
Select … Into table
REFRESH X006.                 
SELECT * FROM T006 INTO X006. 
  APPEND X006.                
ENDSELECT
SELECT * FROM T006 INTO TABLE X006.
Select with selection list
SELECT * FROM DD01L              
  WHERE DOMNAME LIKE 'CHAR%'     
        AND AS4LOCAL = 'A'.      
ENDSELECT
SELECT DOMNAME FROM DD01L    
INTO DD01L-DOMNAME         
WHERE DOMNAME LIKE 'CHAR%' 
       AND AS4LOCAL = 'A'.  
ENDSELECT
Key access to multiple lines
LOOP AT TAB.          
CHECK TAB-K = KVAL. 
ENDLOOP.              
LOOP AT TAB WHERE K = KVAL.     
ENDLOOP.                        
Copying internal tables
REFRESH TAB_DEST.              
LOOP AT TAB_SRC INTO TAB_DEST. 
  APPEND TAB_DEST.             
ENDLOOP.                       
TAB_DEST[] = TAB_SRC[].
Modifying a set of lines
LOOP AT TAB.             
  IF TAB-FLAG IS INITIAL.
    TAB-FLAG = 'X'.      
  ENDIF.                 
  MODIFY TAB.            
ENDLOOP.                 
TAB-FLAG = 'X'.                  
MODIFY TAB TRANSPORTING FLAG     
           WHERE FLAG IS INITIAL.
Deleting a sequence of lines
DO 101 TIMES.               
  DELETE TAB_DEST INDEX 450.
ENDDO.                      
DELETE TAB_DEST FROM 450 TO 550.
Linear search vs. binary
READ TABLE TAB WITH KEY K = 'X'.
READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH.
Comparison of internal tables
DESCRIBE TABLE: TAB1 LINES L1,      
                TAB2 LINES L2.      
IF L1 <> L2.                        
  TAB_DIFFERENT = 'X'.              
ELSE.                               
  TAB_DIFFERENT = SPACE.            
LOOP
AT TAB1.                     
    READ TABLE TAB2 INDEX SY-TABIX. 
    IF TAB1 <> TAB2.                
      TAB_DIFFERENT = 'X'. EXIT.    
    ENDIF.                          
  ENDLOOP.                          
ENDIF.                              
IF TAB_DIFFERENT = SPACE.           
ENDIF.                              
IF TAB1[] = TAB2[].  
ENDIF.               
Modify selected components
LOOP AT TAB.           
TAB-DATE = SY-DATUM. 
MODIFY TAB.          
ENDLOOP.               
WA-DATE = SY-DATUM.                    
LOOP AT TAB.                           
MODIFY TAB FROM WA TRANSPORTING DATE.
ENDLOOP.                               
Appending two internal tables
LOOP AT TAB_SRC.              
  APPEND TAB_SRC TO TAB_DEST. 
ENDLOOP
APPEND LINES OF TAB_SRC TO TAB_DEST.
Deleting a set of lines
LOOP AT TAB_DEST WHERE K = KVAL. 
  DELETE TAB_DEST.               
ENDLOOP
DELETE TAB_DEST WHERE K = KVAL.
Tools available in SAP to pin-point a performance problem
·                The runtime analysis (SE30)
·                SQL Trace (ST05)
·                Tips and Tricks tool
·                The performance database
Optimizing the load of the database
Using table buffering
Using buffered tables improves the performance considerably. Note that in some cases a statement can not be used with a buffered table, so when using these statements the buffer will be bypassed. These statements are:
Select DISTINCT
ORDER BY / GROUP BY / HAVING clause
Any WHERE clause that contains a sub query or IS NULL expression
JOIN s
A SELECT... FOR UPDATE
If you wan t to explicitly bypass the buffer, use the BYPASS BUFFER addition to the SELECT clause.
Use the ABAP SORT Clause Instead of ORDER BY
The ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The database server will usually be the bottleneck, so sometimes it is better to move the sort from the database server to the application server.
If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT statement to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the database server sort it.
Avoid the SELECT DISTINCT Statement
As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.
Thanks & regards
Sreeni

Similar Messages

  • How to become a good ABAPER

    Hi Friends ,
    i want to become a String and very good ABAPER..
    1) how to improve my ABAP SKILLS .
    2) First how to analyze the Issue when issue comes  from Functional Consultant?
    3) how do improve to writting ABAP coding??
    pls advice.
    Rgeards,
    Sreenu

    Hi Sreenu,
    Let me take a simple example of a report program which displays the sales order data. If the functional consultant gives you an issue which says that the net price appearing in the output is incorrect. I would follow the following steps if given such an issue:
    1) Identify which report program is an issue. In other words find which object is giving an issue
    2) Understand the issue so that you can narrow your search further. Since the net price is incorrect, I will check the portion of the code where in, the net price (NETWR field in VBAP table) is being populated.
    3) If the net price is being populated from the right table, check if it is being manipulated further down in the code.
    4) if not, check if this is being changed before the display of the output.
    This is only an example and once you get different kind of issues, you will become more used to fixing issues.
    Before fixing any code, keep in mind the following:
    Will there be any other impacts by fixing the code.
    Look at performance considerations
    Ensure proper unit testing is done by you and by the functional consultant before the code is transported
    Thanks,
    Sandeep

  • How to improve the performance of the abap program

    hi all,
    I have created an abap program. And it taking long time since the number of records are more. And can anyone let me know how to improve the performance of my abap program.
    Using se30 and st05 transaction.
    can anyone help me out step by step
    regds
    haritha

    Hi Haritha,
    ->Run Any program using SE30 (performance analysis)
    Note: Click on the Tips & Tricks button from SE30 to get performance improving tips.
    Using this you can improve the performance by analyzing your code part by part.
    ->To turn runtim analysis on within ABAP code insert the following code
    SET RUN TIME ANALYZER ON.
    ->To turn runtim analysis off within ABAP code insert the following code
    SET RUN TIME ANALYZER OFF.
    ->Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
    ->Avoid for all entries in JOINS
    ->Try to avoid joins and use FOR ALL ENTRIES.
    ->Try to restrict the joins to 1 level only ie only for tables
    ->Avoid using Select *.
    ->Avoid having multiple Selects from the same table in the same object.
    ->Try to minimize the number of variables to save memory.
    ->The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
    ->Avoid creation of index as far as possible
    ->Avoid operators like <>, > , < & like % in where clause conditions
    ->Avoid select/select single statements in loops.
    ->Try to use 'binary search' in READ internal table. -->Ensure table is sorted before using BINARY SEARCH.
    ->Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
    ->Avoid using ORDER BY in selects
    ->Avoid Nested Selects
    ->Avoid Nested Loops of Internal Tables
    ->Try to use FIELD SYMBOLS.
    ->Try to avoid into Corresponding Fields of
    ->Avoid using Select Distinct, Use DELETE ADJACENT
    Check the following Links
    Re: performance tuning
    Re: Performance tuning of program
    http://www.sapgenie.com/abap/performance.htm
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    check the below link
    http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
    See the following link if it's any help:
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    Check also http://service.sap.com/performance
    and
    books like
    http://www.sap-press.com/product.cfm?account=&product=H951
    http://www.sap-press.com/product.cfm?account=&product=H973
    http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    Performance tuning for Data Selection Statement
    http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
    Debugger
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
    http://www.cba.nau.edu/haney-j/CIS497/Assignments/Debugging.doc
    http://help.sap.com/saphelp_erp2005/helpdata/en/b3/d322540c3beb4ba53795784eebb680/frameset.htm
    Run Time Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
    SQL trace
    http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
    CATT - Computer Aided Testing Too
    http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
    Test Workbench
    http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
    Coverage Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
    Runtime Monitor
    http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
    Memory Inspector
    http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
    ECATT - Extended Computer Aided testing tool.
    http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
    Just refer to these links...
    performance
    Performance
    Performance Guide
    performance issues...
    Performance Tuning
    Performance issues
    performance tuning
    performance tuning
    You can go to the transaction SE30 to have the runtime analysis of your program.Also try the transaction SCI , which is SAP Code Inspector.
    edited by,
    Naveenan

  • How to improve ABAP logics

    Hi
    How to Improve ABAP logics(Programming) in all areas.
    I need guidence from you all. How to start to improve them.
    Regards,
    Maruti

    Hi,
    Following are the performance standards need to be following in writing ABAP programs:
    1.      Unused/Dead code
    Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --> check --> extended program to check for the variables, which are not used statically. 
    2.      Subroutine Usage
    For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example:  
    This is better:
    IF f1 NE 0.
      PERFORM sub1.
    ENDIF. 
    FORM sub1.
    ENDFORM.  
    Than this:
    PERFORM sub1.
    FORM sub1.
      IF f1 NE 0.
      ENDIF.
    ENDFORM. 
    3.      Usage of IF statements
    When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first. 
    Example - nested IF's:
      IF (least likely to be true).
        IF (less likely to be true).
         IF (most likely to be true).
         ENDIF.
        ENDIF.
       ENDIF. 
    Example - IF...ELSEIF...ENDIF :
      IF (most likely to be true).
      ELSEIF (less likely to be true).
      ELSEIF (least likely to be true).
      ENDIF. 
    Example - AND:
       IF (least likely to be true) AND
          (most likely to be true).
       ENDIF.
    Example - OR:
            IF (most likely to be true) OR
          (least likely to be true). 
    4.      CASE vs. nested Ifs
    When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient. 
    5.      MOVE statements
    When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to  MOVE-CORRESPONDING a TO b.
    MOVE BSEG TO *BSEG.
    is better than
    MOVE-CORRESPONDING BSEG TO *BSEG. 
    6.      SELECT and SELECT SINGLE
    When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT.   If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times. 
    7.      Small internal tables vs. complete internal tables
    In general it is better to minimize the number of fields declared in an internal table.  While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table.
    For example:
    Instead of this:
    data:  t_mara like mara occurs 0 with header line.
    Use this:
    data: begin of t_mara occurs 0,
            matnr like mara-matnr,
            end of t_mara. 
    8.      Row-level processing and SELECT SINGLE
    Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info), you should do the following to improve performance:
    o       Use the SELECT into <itab> to buffer the necessary rows in an internal table, then
    o       sort the rows by the key fields, then
    o       use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).
    9.      READing single records of internal tables
    When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ.  This means that if the data is not sorted according to the key, the system must sequentially read the table.   Therefore, you should:
    o       SORT the table
    o       use READ TABLE WITH KEY BINARY SEARCH for better performance. 
    10.  SORTing internal tables
    When SORTing internal tables, specify the fields to SORTed.
    SORT ITAB BY FLD1 FLD2.
    is more efficient than
    SORT ITAB.  
    11.  Number of entries in an internal table
    To find out how many entries are in an internal table use DESCRIBE.
    DESCRIBE TABLE ITAB LINES CNTLNS.
    is more efficient than
    LOOP AT ITAB.
      CNTLNS = CNTLNS + 1.
    ENDLOOP. 
    12.  Performance diagnosis
    To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs. 
    13.  Nested SELECTs versus table views
    Since releASE 4.0, OPEN SQL allows both inner and outer table joins.  A nested SELECT loop may be used to accomplish the same concept.  However, the performance of nested SELECT loops is very poor in comparison to a join.  Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join. 
    14.  If nested SELECTs must be used
    As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:
    Use this:
    form select_good.
      data: t_vbak like vbak occurs 0 with header line.
      data: t_vbap like vbap occurs 0 with header line.
      select * from vbak into table t_vbak up to 200 rows.
      select * from vbap
              for all entries in t_vbak
              where vbeln = t_vbak-vbeln.
      endselect.
    endform.
    Instead of this:
    form select_bad.
    select * from vbak up to 200 rows.
      select * from vbap where vbeln = vbak-vbeln.
      endselect.
    endselect.
    endform.
    Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:
    Firstly, SAP automatically removes any duplicates from the rest of the retrieved records.  Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).
    Secondly,  if you were able to code "SELECT ... FROM <database table> FOR ALL ENTRIES IN TABLE <itab>" and the internal table <itab> is empty, then all rows from <database table> will be retrieved.
    Thirdly, if the internal table supplying the selection criteria (i.e. internal table <itab> in the example "...FOR ALL ENTRIES IN TABLE <itab> ") contains a large number of entries, performance degradation may occur.
    15.  SELECT * versus SELECTing individual fields
    In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance.  For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few.  In the latter case, the performace gains can be substantial.  For example:
    Use:
    select vbeln auart vbtyp from table vbak
      into (vbak-vbeln, vbak-auart, vbak-vbtyp)
      where ...
    Instead of using:
    select * from vbak where ... 
    16.  Avoid unnecessary statements
    There are a few cases where one command is better than two.  For example:
    Use:
    append <tab_wa> to <tab>.
    Instead of:
    <tab> = <tab_wa>.
    append <tab> (modify <tab>).
    And also, use:
    if not <tab>[] is initial.
    Instead of:
    describe table <tab> lines <line_counter>.
    if <line_counter> > 0. 
    17.  Copying or appending internal tables
    Use this:
    <tab2>[] = <tab1>[].  (if <tab2> is empty)
    Instead of this:
    loop at <tab1>.
      append <tab1> to <tab2>.
    endloop.
    However, if <tab2> is not empty and should not be overwritten, then use:
    append lines of <tab1> [from index1] [to index2] to <tab2>.

  • How to improve ABAP OO logics

    Hi
    How to improve ABAP OO logics and concepts. Can you please guide me.
    Regards,
    Maruti

    if u want to download the books then just go through this link
    [http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/ABAP_tutorial.html]
    just cick on the book no.....scrool down the next page .....at the bottom u will find thE DOWNLOAD button...rest all u know well...
    if u want more specific link for the oops concepts then....
    [http://www.****************/Tutorials/OOPS/Concepts/page1.htm]

  • How to improve the performance of adobe forms

    Hi,
    Please give me some suggestions as to how to improve the performance of adobe form?
    Right now when I' am doing user events it is working fine for first 6 or 7 user events. From the next
    one it is hanging.
    I read about Wizard form design approach, how to use the same here.
    Thanks,
    Aravind

    Hi Otto,
    The form is created using HCM forms and processes. I' am performing user events in the form.
    User events will doa round trip, in which form data will be sent to backend SAP system. Processing will
    happen on the ABAP side and result will appear on the form. First 6 or 7 user events works correctly,
    the result is appearing on the form. Around 8 or 9th one, the wait symbol appears and the form is not
    re-rendered. The form is of size 6 pages. The issue is not coming with form of size 1 page.
    I was reading ways to improve performance during re-rendering given below.
    http://www.adobe.com/devnet/livecycle/articles/DynamicInteractiveFormPerformance.pdf
    It talks about wizard form design approach. But in SFP transaction, I am not seeing any kind of wizard.
    Let me know if you need further details.
    Thanks,
    Aravind

  • Hi very urgent  How to improve the performence of the program

    Hi all please tell me 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.
     

    Hi
    You check in SM50 by executing the programing, You will come to know which select is taking more time and accordingly you modify that select.
    You can do SQL trace and Run time analysis and analyse and see.
    check this and use
    1) Dont use nested select statements
    2) If possible use for all entries in addition
    3) In the where addition make sure you give all the primary key
    4) Use Index for the selection criteria.
    5) You can also use inner joins
    6) You can try to put the data from the first select statement into an Itab and then in order to select the data from the second table use for all entries in.
    7) Use the runtime analysis SE30 and SQL Trace (ST05) to identify the performance and also to identify where the load is heavy, so that you can change the code accordingly
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5d0db4c9-0e01-0010-b68f-9b1408d5f234
    ABAP performance depends upon various factors and in devicded in three parts:
    1. Database
    2. ABAP
    3. System
    Run Any program using SE30 (performance analys) to improve performance refer to tips and trics section of SE30, Always remember that ABAP perfirmance is improved when there is least load on Database.
    u can get an interactive grap in SE30 regarding this with a file.
    also if u find runtime of parts of codes then use :
    Switch on RTA Dynamically within ABAP Code
    *To turn runtim analysis on within ABAP code insert the following code
    SET RUN TIME ANALYZER ON.
    *To turn runtim analysis off within ABAP code insert the following code
    SET RUN TIME ANALYZER OFF.
    Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
    Avoid for all entries in JOINS
    Try to avoid joins and use FOR ALL ENTRIES.
    Try to restrict the joins to 1 level only ie only for tables
    Avoid using Select *.
    Avoid having multiple Selects from the same table in the same object.
    Try to minimize the number of variables to save memory.
    The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
    Avoid creation of index as far as possible
    Avoid operators like <>, > , < & like % in where clause conditions
    Avoid select/select single statements in loops.
    Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
    Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
    Avoid using ORDER BY in selects
    Avoid Nested Selects
    Avoid Nested Loops of Internal Tables
    Try to use FIELD SYMBOLS.
    Try to avoid into Corresponding Fields of
    Avoid using Select Distinct, Use DELETE ADJACENT
    Check the following Links
    Re: performance tuning
    Re: Performance tuning of program
    http://www.sapgenie.com/abap/performance.htm
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    check the below link
    http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
    See the following link if it's any help:
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    Check also http://service.sap.com/performance
    and
    books like
    http://www.sap-press.com/product.cfm?account=&product=H951
    http://www.sap-press.com/product.cfm?account=&product=H973
    http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    Performance tuning for Data Selection Statement
    http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
    Debugger
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
    http://www.cba.nau.edu/haney-j/CIS497/Assignments/Debugging.doc
    http://help.sap.com/saphelp_erp2005/helpdata/en/b3/d322540c3beb4ba53795784eebb680/frameset.htm
    Run Time Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
    SQL trace
    http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
    CATT - Computer Aided Testing Too
    http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
    Test Workbench
    http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
    Coverage Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
    Runtime Monitor
    http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
    Memory Inspector
    http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
    ECATT - Extended Computer Aided testing tool.
    http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
    Just refer to these links...
    performance
    Performance
    Performance Guide
    performance issues...
    Performance Tuning
    Performance issues
    performance tuning
    performance tuning
    You can go to the transaction SE30 to have the runtime analysis of your program.Also try the transaction SCI , which is SAP Code Inspector.
    1 Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
    2 Avoid for all entries in JOINS
    3 Try to avoid joins and use FOR ALL ENTRIES.
    4 Try to restrict the joins to 1 level only ie only for 2 tables
    5 Avoid using Select *.
    6 Avoid having multiple Selects from the same table in the same object.
    7 Try to minimize the number of variables to save memory.
    8 The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
    9 Avoid creation of index as far as possible
    10 Avoid operators like <>, > , < & like % in where clause conditions
    11 Avoid select/select single statements in loops.
    12 Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
    13 Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
    14 Avoid using ORDER BY in selects
    15 Avoid Nested Selects
    16 Avoid Nested Loops of Internal Tables
    17 Try to use FIELD SYMBOLS.
    18 Try to avoid into Corresponding Fields of
    19 Avoid using Select Distinct, Use DELETE ADJACENT.
    Regards
    Anji

  • How to improve the load performance

    can any body tell me how to improve the load performance

    Hi,
    for all loads: improve your ABAP code in routines.
    for master data load:
    - load master data attributes before the charateristic itself
    - switch number range buffering on for initial loads
    for transactional loads:
    - load all your master data IObjs prior loading your cube / ODS
    - depending on the ratio No.Records loaded / No.Records in Cube F fact table, drop / recreate indexes (if ration is mor than 40/50%
    - switch on number range buffering for dimensions with high number of records for initial loads
    - switch on number range buffering on master data IObjs which aren't loaded via master data (SIDs always created while transactional loads; eg document, item....)
    these recommendations are just some among others like system tuning, DB parameters...
    hope this helps...
    Olivier.

  • How to improve the perforamnce

    Hi ,
    How to improve the performance of the  report.
    Thanks and rgds,
    Roopa

    1. Unused/Dead code
    Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --> check --> extended program to check for the variables, which are not used statically.
    2. Subroutine Usage
    For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example:
    This is better:
    IF f1 NE 0.
    PERFORM sub1.
    ENDIF.
    FORM sub1.
    ENDFORM.
    Than this:
    PERFORM sub1.
    FORM sub1.
    IF f1 NE 0.
    ENDIF.
    ENDFORM.
    3. Usage of IF statements
    When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first.
    Example - nested IF's:
    IF (least likely to be true).
    IF (less likely to be true).
    IF (most likely to be true).
    ENDIF.
    ENDIF.
    ENDIF.
    Example - IF...ELSEIF...ENDIF :
    IF (most likely to be true).
    ELSEIF (less likely to be true).
    ELSEIF (least likely to be true).
    ENDIF.
    Example - AND:
    IF (least likely to be true) AND
    (most likely to be true).
    ENDIF.
    Example - OR:
    IF (most likely to be true) OR
    (least likely to be true).
    4. CASE vs. nested Ifs
    When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient.
    5. MOVE statements
    When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b.
    MOVE BSEG TO *BSEG.
    is better than
    MOVE-CORRESPONDING BSEG TO *BSEG.
    6. SELECT and SELECT SINGLE
    When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT. If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times.
    7. Small internal tables vs. complete internal tables
    In general it is better to minimize the number of fields declared in an internal table. While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table.
    For example:
    Instead of this:
    data: t_mara like mara occurs 0 with header line.
    Use this:
    data: begin of t_mara occurs 0,
    matnr like mara-matnr,
    end of t_mara.
    8. Row-level processing and SELECT SINGLE
    Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info), you should do the following to improve performance:
    o Use the SELECT into <itab> to buffer the necessary rows in an internal table, then
    o sort the rows by the key fields, then
    o use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).
    9. READing single records of internal tables
    When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ. This means that if the data is not sorted according to the key, the system must sequentially read the table. Therefore, you should:
    o SORT the table
    o use READ TABLE WITH KEY BINARY SEARCH for better performance.
    10. SORTing internal tables
    When SORTing internal tables, specify the fields to SORTed.
    SORT ITAB BY FLD1 FLD2.
    is more efficient than
    SORT ITAB.
    11. Number of entries in an internal table
    To find out how many entries are in an internal table use DESCRIBE.
    DESCRIBE TABLE ITAB LINES CNTLNS.
    is more efficient than
    LOOP AT ITAB.
    CNTLNS = CNTLNS + 1.
    ENDLOOP.
    12. Performance diagnosis
    To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs.
    13. Nested SELECTs versus table views
    Since releASE 4.0, OPEN SQL allows both inner and outer table joins. A nested SELECT loop may be used to accomplish the same concept. However, the performance of nested SELECT loops is very poor in comparison to a join. Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join.
    14. If nested SELECTs must be used
    As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:
    Use this:
    form select_good.
    data: t_vbak like vbak occurs 0 with header line.
    data: t_vbap like vbap occurs 0 with header line.
    select * from vbak into table t_vbak up to 200 rows.
    select * from vbap
    for all entries in t_vbak
    where vbeln = t_vbak-vbeln.
    endselect.
    endform.
    Instead of this:
    form select_bad.
    select * from vbak up to 200 rows.
    select * from vbap where vbeln = vbak-vbeln.
    endselect.
    endselect.
    endform.
    Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:
    Firstly, SAP automatically removes any duplicates from the rest of the retrieved records. Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).
    Secondly, if you were able to code "SELECT ... FROM <database table> FOR ALL ENTRIES IN TABLE <itab>" and the internal table <itab> is empty, then all rows from <database table> will be retrieved.
    Thirdly, if the internal table supplying the selection criteria (i.e. internal table <itab> in the example "...FOR ALL ENTRIES IN TABLE <itab> ") contains a large number of entries, performance degradation may occur.
    15. SELECT * versus SELECTing individual fields
    In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance. For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few. In the latter case, the performace gains can be substantial. For example:
    Use:
    select vbeln auart vbtyp from table vbak
    into (vbak-vbeln, vbak-auart, vbak-vbtyp)
    where ...
    Instead of using:
    select * from vbak where ...
    16. Avoid unnecessary statements
    There are a few cases where one command is better than two. For example:
    Use:
    append <tab_wa> to <tab>.
    Instead of:
    <tab> = <tab_wa>.
    append <tab> (modify <tab>).
    And also, use:
    if not <tab>[] is initial.
    Instead of:
    describe table <tab> lines <line_counter>.
    if <line_counter> > 0.
    17. Copying or appending internal tables
    Use this:
    <tab2>[] = <tab1>[]. (if <tab2> is empty)
    Instead of this:
    loop at <tab1>.
    append <tab1> to <tab2>.
    endloop.
    However, if <tab2> is not empty and should not be overwritten, then use:
    append lines of <tab1> [from index1] [to index2] to <tab2>.
    P.S : Please reward if you find this useful..

  • Ask The Experts How to Improve Your PC's Performanc​e on June 1st at 3:30 pm PDT

    Learn how to improve your PC 's performance on June 1st from 3:30 -4:30 pm PDT. We'll have a team of experts available to answer your questions.   
    When it comes to performance, your PC is similar to your car. Both need to be cared for to keep them running run well. But unlike your car, you don’t need to bring your PC into a shop for a tune up. You can easily do it yourself if you know the right steps to take.  Our experts will answer your questions and provide tips on how to make your PC run better.  Topics that may be covered in this real-time chat event include the following:
    How to customize your PC to increase performance; 
    How to prolong your notebook’s battery life;
    How to choose the right video card, power supply, or add the right amount of memory; or
    How to use the tools built into your PC that can make it run better and fix common problems. 
    While you can attend this real-time chat event without signing up in advance, you must be a member of the HP Support Forums to ask questions. Signing up is easy and only takes a few moments, plus it will allow you to post questions or give answers on the Forums.
    And it is all free!
    So, come and learn how to get the most out of your PC. Please be sure to come on time as space is limited!
    Message Edited by timhsu on 05-12-2009 05:33 PM
    I work for HP, supporting the HP Experts who volunteer their time and technical knowledge to help others.
    This question was solved.
    View Solution.

    Here is the transcript of the chat event on improving PC performance. 
    Please note that I have altered the transcript so that follow up questions are included in the logical order.
    I am in the process of planning the next chat event. I would love to hear what topics would interest you, what day of the week and time is best for you, and if you think an hour is too long.
    So, if you get a minute, please let me know.
    I work for HP, supporting the HP Experts who volunteer their time and technical knowledge to help others.

  • How to improve the query performance in to report level and designer level

    How to improve the query performance in to report level and designer level......?
    Plz let me know the detail view......

    first its all based on the design of the database, universe and the report.
    at the universe Level, you have to check your Contexts very well to get the optimal performance of the universe and also your joins, keep your joins with key fields, will give you the best performance.
    at the report level, try to make the reports dynamic as much as you can, (Parameters) and so on.
    and when you create a paremeter try to get it match with the key fields in the database.
    good luck
    Amr

  • How to improve battery backup in iphone 3gs

    I bought my iphone 3gs a month back. Its performance is very good. However, the battery back up hardly lasts for a day only or even less. My earlier Nokia E52 used to last for 2 to 3 days. I do not use 3G, wi-fi. Push mail is on of course. Please suggest as how to improve the battery back up. Thank you.

    Take a look at this article.
    Apple - Batteries - iPhone

  • Performance blocker on cFP-2020: file-I/O! How to improve?

    Hi all,
    after resolving my serial-communication problems I still have a performance problem. The code is way too slow which causes e.g. the ftp-server on the fieldpoint to not respond anymore to requests from my PC. I always get timeouts. I also frequently get loop-finished-late events within my two state-machines. I have now used the timing and performance monitor to sse which vi is taking so much time. The result: A file-I/O vi that writes data and log-entries into three different log-files. With a former verion I simply used one vi that appends a string to an existing file. However, since this function disappeared with LV8.2 I had to rewrite the code to use the following sequence of LV-functions:
    - file open
    - set pointer to the end
    - write string
    - file close
    My vi shich calls this sequence is horribly slow - execution time per run is about 200ms and the top of the list in the performance monitor. Are there any suggestions on how to improve this code? I simply want to add a string to the end of the log-file......
    The vi is attached. There are two features in the code which are not self-explanatory: The first sub-vi generates a new file if is used for longer than a preset time (15 minutes in my case). So the create-time of the file is stored in the filename and whenever the current time exceeds create-time plus 15 min. A new file name is created. For simplicity, the name is stored only for the first of the three log-files. The other two are created by string operations from the first filename. Second, whenever a file is "created", that means is does not exist yet, a data-header is written to the file, before data is appended.
    Can you see simple improvements here that will accelerate this code? Maybe open the file only once and then append data subsequently and only close it when a new file is created? But I do not need all three files all the times, there may be situations where only one file is needed, and the others need not be created at all.
    Thanks,
    Olaf
    Attachments:
    makedatalogfiles.vi ‏42 KB

    Ravens Fan wrote:
    I think moving the open file, move to end of file, and close file out of the loop would certainly help.  These functions could be associated with or built into your "determine new file" VI.  Since the file paths get passed into the loops, you could pass them through with shift registers so that you can close them after the loops end.
    One other thing to look at is your initialize array and insert into array functions.  I believe insert into array is one of the costlier functions.  Build array would be better.  And initializing a much larger array and using replace array subset is better yet.  But if you wind up with more elements than you had originally initialized for, you will have to use build array to enlarge it.   I would recommend searching the Labview forum for insert into array, build array, and replace array subset for threads that do a better job explaining the differences and advantages of each.
    Thanks, that improved the performance of this vi by about two orders of magnitude. The application is now much more stable.
    However, I cannot connect to the cFP-2020 anymore by ftp. I even swithed the fieldpoint to boot without vi.
    To be specific, I can access the cFP and cd into all directories except for the directory with the data. I assume that there is a large
    amount of files in it now, but used to work before even with lots of files. The only thing that might be not so nice is that there is a space
    in the folder name, but that has been like that for years now and used to work.
    Is there any reason (corrupted file or something like that) that can cause the ftp to fail on this specific directory?
    Thanks,
    Olaf
    ...at least I am very close now to a satisfying and running system.... :-)

  • How to improve performance of MediaPlayer?

    I tried to use the MediaPlayer with a On2 VP6 flv movie.
    Showing a video with a resolution of 1024x768 works.
    Showing a video with a resolution of 1280x720 and a average bitrate of 1700 kb/s leads to a delay of the video signal behind the audio signal of a couple of seconds. VLC, Media Player Classic and a couple of other players have no problem with the video. Only the FX MediaPlayer shows a poor performance.
    Additionally mouse events in a second stage (the first stage is used for the video) are not processed in 2 of 3 cases. If the MediaPlayer is switched off, the mouse events work reliable.
    Does somebody know a solution for this problems?
    Cheers
    masim

    duplicate thread..
    How to improve performance of attached query

  • How to improve performance of a game in samsung mobile

    hi,
    I have developed a game which i am trying to port to various handsets, its works fine for nokia, sony,motorola. But it is giving problems when i run with samsung emulator.
    the game became very slow when i tried running it in samsung emulator and it is taking the ket events very late.
    can any one plz help in how to improve the speed of the game on samsung mobile. it kind of urgent.
    Thanks

    Hi Raj,
      How is your direct access datasource built ?  Is this a standard datasource or generic datasource on any view/table/function module. This strengthens my second point.
    Suppose you built a virtual cube on direct access datasource built  on AUFK table with Order as primary key (Order master data). when you use Order as selection on query built on this virtual cube then it retrievies the data faster than firing the query on other selections.
    If your selections are different. You can possibly create a secondary index on the table with selections used in query.
    Regards
    vamsi

Maybe you are looking for

  • Is there a way to upgrade the iOS software to 5 only by means of bypassing the automatic upgrade to 5.0.1?

    I believe that we all know the latest version of iOS now has an issue with regards to battery life. I proved it and tested it to my iPhone 4S. Few days ago, the battery life of my iPhone 4S, last for one week (almost) in a stand by mode without charg

  • Error:WSDL creation in PI 7.1

    Hi, Scenario is Soap to File, we are using PI 7.1 in which we need to create the wsdl to trigger from the source file. we created all the objects in IR & ID have activated in the SOAP Sender communication channel we use HTTP as HTTP security and the

  • Can't see video display in color

    I'm new to color and I can't seem to see my video playback. The video output setting comes up disabled and won't let me choose a display. Everything is grayed out. How do I get it so I can see my playback above the scopes? I'm working in standard def

  • ERROR_INTERNET_SECURITY_CHANNEL_ERROR

    Hi, We are receiving the error mentioned while clicking on the collaboration link in the bidding process in SRM. We get page cannot be displayed when we click on the link.

  • PowerMac G5 HELP!

    I just scored a powermac G5 quad 2.5 from work. I don't thing the CPU has been leaked onto, because im getting no light errors or anything abnormal and it is making the startup sound. I do not have a way of connecting it to a monitor right now, as am