<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SQL trace in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586645#M591933</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried,&lt;/P&gt;&lt;P&gt;I have done the steps you provide above. I can see that the duration for select statement of table COAS and COEP is very long. My question: How do I go about reducing this duration? &lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Aug 2007 07:48:01 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-28T07:48:01Z</dc:date>
    <item>
      <title>SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586633#M591921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plz tel me how to use ST05 ( step wise ) for checking performance issues in a program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Binay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2007 13:48:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586633#M591921</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-06T13:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586634#M591922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL trace(ST05) provides the developer with the ability to analyse database select statements. Simply execute ST05 to turn on SQL trace, then execute the statement/program you want to analyse. Now turn off SQL trace using ST05 &lt;/P&gt;&lt;P&gt;and click on list trace to view the details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also perform traces on other items such as authorisation objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on the SPFLI table in our test program is mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Performance Tuning is useful mainly reducing load on database. It is very important aspect while writing the programs/FM etc.....&lt;/P&gt;&lt;P&gt;SQL Trace&lt;/P&gt;&lt;P&gt;Use&lt;/P&gt;&lt;P&gt;The SQL Trace function is an on-demand log of selected SQL statements that are issued against the database through the Open SQL Engine. The SQL Trace can be switched on or off dynamically. The log format is database independent. Besides the SQL statement text, each log record contains information about the point in time when the statement was executed, its duration, its input parameters and results (where applicable) as well as context information.&lt;/P&gt;&lt;P&gt;Features&lt;/P&gt;&lt;P&gt;The SQL Trace is especially useful for:&lt;/P&gt;&lt;P&gt;Development:&lt;/P&gt;&lt;P&gt;SQL Trace can help JDO, enterprise beans, servlet and JSP developers to learn which kind of database accesses their code produces.&lt;/P&gt;&lt;P&gt;&amp;amp;#61489;&amp;amp;#61486; Performance analysis&lt;/P&gt;&lt;P&gt;Typically, performance issues are caused by inefficient database accesses. In this case SQL Trace can be used to show the issued SQL statements and their duration, thus helping to identify inefficient SQL statements.&lt;/P&gt;&lt;P&gt;Functions&lt;/P&gt;&lt;P&gt;The following functions are available on the initial screen:&lt;/P&gt;&lt;P&gt;Select trace:&lt;/P&gt;&lt;P&gt;&amp;#149; Select the trace mode SQL Trace, Enqueue Trace, RFC Trace, or Table Buffer Trace. You can select mutliple trace modes simultaneously.&lt;/P&gt;&lt;P&gt;Select trace function:&lt;/P&gt;&lt;P&gt;&amp;#149; Start the trace recording.&lt;/P&gt;&lt;P&gt;&amp;#149; Stop the trace recording.&lt;/P&gt;&lt;P&gt;&amp;#149; Branch to trace list, detailed list, or time-sorted list.&lt;/P&gt;&lt;P&gt;&amp;#149; Branch to Explain SQL to analyze an SQL statement without an explicit trace file.&lt;/P&gt;&lt;P&gt;Trace files are managed by the system. Thus they can be saved, like any other object;&lt;/P&gt;&lt;P&gt;saved trace files can be displayed and deleted.&lt;/P&gt;&lt;P&gt;Trace Status&lt;/P&gt;&lt;P&gt;A trace can only be activated once on any application server. The Trace Status display informs you whether another user in the system has already activated a particular trace.&lt;/P&gt;&lt;P&gt;Starting the Trace&lt;/P&gt;&lt;P&gt;Prerequisites&lt;/P&gt;&lt;P&gt;You can only switch on the Performance Trace for a single instance. You should already have decided the scope and targets of your performance analysis. &lt;/P&gt;&lt;P&gt;Procedure&lt;/P&gt;&lt;P&gt;To analyze a trace file, do the following:&lt;/P&gt;&lt;P&gt;... 1. Choose the menu path Test &amp;amp;#61614; Performance Trace in the ABAP Workbench.&lt;/P&gt;&lt;P&gt;The initial screen of the test tool appears. In the lower part of the screen, the status of the Performance Trace is displayed. This provides you with information as to whether any of the Performance Traces are switched on and the users for which they are enabled. It also tells you which user has switched the trace on.&lt;/P&gt;&lt;P&gt;2. Using the selection buttons provided, set which trace functions you wish to have switched on (SWL trace, enqueue trace, RFC trace, table buffer trace).&lt;/P&gt;&lt;P&gt;3. If you want to switch on the trace under your user name, choose Trace on. &lt;/P&gt;&lt;P&gt;If you want to pass on values for one or several filter criteria, choose Trace with Filter. &lt;/P&gt;&lt;P&gt;Typical filter criteria are: the name of the user, transaction name, process name, and program name.&lt;/P&gt;&lt;P&gt;4. Now run the program to be analyzed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will normally analyze the performance trace file immediately. In this case, it is a good idea to use a separate session to start, stop, and analyze the Performance Trace &lt;/P&gt;&lt;P&gt;If you are shown trace kernel errors on the initial screen (for example, not enough storage space available), you must first remove the errors or have them removed by your system administrator.&lt;/P&gt;&lt;P&gt;The selected trace types can be changed as required during a performance trace interval (time between switching on and off the trace). The user (user group) must remain unchanged.&lt;/P&gt;&lt;P&gt;Result&lt;/P&gt;&lt;P&gt;The results of the trace recording are written to a trace file. If trace records are overwritten during the trace interval, the system displays a message to inform you when you analyze the trace file.&lt;/P&gt;&lt;P&gt;The results of the trace recording are stored to ten trace files. Overwriting trace records, however, cannot be entirely excluded in this case either.&lt;/P&gt;&lt;P&gt;The Performance Trace records all database access calls, table buffer calls, remote calls, or calls for user lock activity. These measurements can affect the performance of the application server where the trace is running. To preserve system performance, you should therefore turn off the trace as soon as you finish recording your application. &lt;/P&gt;&lt;P&gt;Stopping the Trace&lt;/P&gt;&lt;P&gt;Prerequisites&lt;/P&gt;&lt;P&gt;You have started the trace and finished running the program that you want to analyze. &lt;/P&gt;&lt;P&gt;For performance reasons, you should switch off the traces as soon as you have finished recording.&lt;/P&gt;&lt;P&gt;Procedure&lt;/P&gt;&lt;P&gt;To deactivate the trace:&lt;/P&gt;&lt;P&gt;... 1. Choose Test &amp;amp;#61614;Performance Trace in the ABAP Workbench.&lt;/P&gt;&lt;P&gt;The initial screen of the test tool appears. It contains a status line displaying the traces that are active, the users for whom they are active, and the user who activated them.&lt;/P&gt;&lt;P&gt;2. Select the trace functions that you want to switch off.&lt;/P&gt;&lt;P&gt;3. Choose Deactivate Trace.&lt;/P&gt;&lt;P&gt;If you started the trace yourself, you can now switch it off immediately. If the performance trace was started by a different user, a confirmation prompt appears before deactivation-&lt;/P&gt;&lt;P&gt;Result&lt;/P&gt;&lt;P&gt;The results of the trace are stored in one or more trace files. You can then analyze the performance data stored in the trace file. See also, Analyzing Performance Data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look at the below link&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapbrainsonline.com/TOOLS/SQLTRACE/SQL_TRACE.html" target="test_blank"&gt;http://www.sapbrainsonline.com/TOOLS/SQLTRACE/SQL_TRACE.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2007 13:51:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586634#M591922</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-06T13:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586635#M591923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;just added that to a similar question in the General forum: Please try and come back with detailed questions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there no detailed description available ... I expected some references.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the meantime:&lt;/P&gt;&lt;P&gt;Open a second mode, execute your program in the first mode at least once, better several times to fill buffers and caches&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Start trace in second mode,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Run program again&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Switch off the trace and display the trace results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is a very long result screen, showing each execution, very often with several lines per statement. That is usually too much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore go to 'table' 'summarize by sql statements'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is an overview with one line per statement! show number of executions, &lt;/P&gt;&lt;P&gt;duration, number of records etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And most important the explain! Select your problematic statement, use 'explain', the new screen shows you which index is used. Unfortunately, the explains can have very different layouts, depending on your database. Some are more easy and some more difficult to read, but the iindex is always displayed somewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your new index helps, then it will appear here in your next execution, better check status without index first and execute it again with index. Check the difference in runtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Aug 2007 13:55:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586635#M591923</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-06T13:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586636#M591924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;2.   SQL Trace transaction ST05&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on the SPFLI table in our test program is mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2007 06:32:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586636#M591924</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-07T06:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586637#M591925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) CLick on Activate in ST05 before you do some DB operation ( Or you know that invloves DB operations)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Execute the DB operation by means of program or transaction execution&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) Come back to ST05 deactivate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) Display Trace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2007 06:39:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586637#M591925</guid>
      <dc:creator>seshatalpasai_madala</dc:creator>
      <dc:date>2007-08-07T06:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586638#M591926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I would strongly emphazise the most important point:  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore go to drop down list box on the left 'table -&amp;gt; summarize by sql statements'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&amp;gt; the following display is much more condensed and useful. It contains all what you need!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2007 09:18:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586638#M591926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-07T09:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586639#M591927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Attach below is my program. It seems like the execution time is too long...&lt;/P&gt;&lt;P&gt;Can you guys help me out? I have tried to minimize the execution time by using SELECT ... FOR ALL ENTRIES but to no avail....&lt;/P&gt;&lt;P&gt;I also used CLIENT SPECIFIED field as selection criteria... &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Program    : YZZ_SDPROJCONTROL                                      *
*&amp;amp; Author     : FF-MOHDMF (ACN)                                        *
*&amp;amp; GSKC Forum :                                                        *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Description                                                         *
*&amp;amp;                                                                     *
*&amp;amp; To create a project controlling report based on the internal order  *
*&amp;amp; and its project number.                                             *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Modification Log                                                    *
*&amp;amp;                                                                     *
*&amp;amp; Date       GSKC#    Modified By                                     *
*&amp;amp; Chg Req    Version  Description of Changes                          *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
REPORT  YZZ_SDPROJCONTROL NO STANDARD PAGE HEADING
                         MESSAGE-ID zi
                         LINE-SIZE 148.

* table declaration ----------------------------------------------------
tables: vbak,
        coas,
        kna1,
        bkpf,
        bseg,
        cobk,
        vbfa,
        coep,
        ekkn,
        ekbe,
        vbpa,
        skat,
        makt.

* data declaration -----------------------------------------------------
TYPES: BEGIN OF t_vbak2,
        vbeln    LIKE vbak-vbeln,
        auart    LIKE vbak-auart,
        vkorg    LIKE vbak-vkorg,
        kunnr    LIKE vbak-kunnr,
        flg(1) TYPE c,
      END OF t_vbak2.

DATA: it_vbak TYPE TABLE OF t_vbak2 WITH HEADER LINE.

TYPES: BEGIN OF t_vbak,
        vbeln    LIKE vbak-vbeln,
        auart    LIKE vbak-auart,
        vkorg    LIKE vbak-vkorg,
        kunnr    LIKE vbak-kunnr,
      END OF t_vbak.
DATA: wa_vbak TYPE t_vbak.

TYPES: BEGIN OF t_coas,
        aufnr    LIKE coas-aufnr,
        ktext    LIKE coas-ktext,
        kdauf    LIKE coas-kdauf,
        kokrs    like coas-kokrs,
        objnr    like coas-objnr,
        xblnr    like bkpf-xblnr,      "For downpayment logic
      END OF t_coas.

DATA: wa_coas TYPE t_coas.

DATA: it_coas TYPE TABLE OF t_coas WITH HEADER LINE.

types: begin of t_coep,
        kokrs like coep-kokrs,
        belnr like coep-belnr,
        objnr like coep-objnr,
        perio like coep-perio,
        gjahr like coep-gjahr,
        BEKNZ like coep-BEKNZ,
        wkgbtr like coep-wkgbtr,
        kstar  like coep-kstar,
        mbgbtr like coep-mbgbtr,
      end of t_coep.
data: it_coep type table of t_coep with header line.

DATA: BEGIN OF it_error OCCURS 0,
        aufnr   LIKE coas-aufnr,
      END OF it_error.

DATA: BEGIN OF it_name OCCURS 0,
        vbeln LIKE vbpa-vbeln,
        kunnr LIKE kna1-kunnr,
        name1 LIKE kna1-name1,
      END OF it_name.

DATA: BEGIN OF it_kna1 OCCURS 0,
        kunnr LIKE kna1-kunnr,
        name1 LIKE kna1-name1,
      END OF it_kna1.

DATA: BEGIN OF it_vbpa OCCURS 0,
        vbeln LIKE vbpa-vbeln,
        kunnr LIKE vbpa-kunnr,
      END OF it_vbpa.

types: begin of t_bkpf,
          bukrs like bkpf-bukrs,
          belnr like bkpf-belnr,
          gjahr like bkpf-gjahr,
          xblnr like bkpf-xblnr,
      end of t_bkpf.
DATA: it_bkpf TYPE TABLE OF t_bkpf WITH HEADER LINE.

data: begin of it_bseg occurs 0,
          bukrs like bseg-bukrs,
          gjahr like bseg-gjahr,
          belnr like bseg-belnr,
          bschl like bseg-bschl,
          pswbt like bseg-pswbt,
          augbl like bseg-augbl,
          shkzg like bseg-shkzg,
          hkont like bseg-hkont,
          zfbdt like bseg-zfbdt,
      end of it_bseg.
data: it_bseg1 like it_bseg occurs 0 with header line.

types: begin of t_vbfa,
          vbelv like vbfa-vbelv,
          posnv like vbfa-posnv,
          vbeln like vbfa-vbeln,
          posnn like vbfa-posnn,
          vbtyp_n like vbfa-vbtyp_n,
          erdat like vbfa-erdat,
          matnr like vbfa-matnr,
          rfwrt like vbfa-rfwrt,
          rfmng like vbfa-rfmng,
      end of t_vbfa.
data: it_vbfa type table of t_vbfa with header line.

data: begin of it_final occurs 0,
          kokrs like coas-kokrs,          "Sales Org
          kdauf like coas-kdauf,          "Project No
          aufnr like coas-aufnr,          "Internal order
*          prdcat type string,             "Product / Category
*          prdcat(15) type C,             "Product / Category
          prdcat(15) type N,             "Product / Category

          ktext like coas-ktext,          "Description
          peryr type string,              "Period / Year
          dmbtr like bseg-dmbtr,          "Amount
          qty type I,                     "Quantity
          docno type string,              "DocNo
      end of it_final.

data: it_final1 like it_final occurs 0 with header line.

data: begin of it_ekkn occurs 0,
          ebeln like ekkn-ebeln,
          ebelp like ekkn-ebelp,
          aufnr like ekkn-aufnr,
      end of it_ekkn.

data: begin of it_ekbe occurs 0,
          belnr like ekbe-belnr,
          budat like ekbe-budat,
          wrbtr like ekbe-wrbtr,
          ebeln like ekbe-ebeln,
          ebelp like ekbe-ebelp,
          shkzg like ekbe-shkzg,
      end of it_ekbe.

data: begin of it_cobk occurs 0,
          kokrs like cobk-kokrs,
          belnr like cobk-belnr,
          gjahr like cobk-gjahr,
          refbn like cobk-refbn,
      end of it_cobk.
* selection-screen -----------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_vkorg FOR  vbak-vkorg OBLIGATORY no-extension no intervals,
                s_vbeln FOR  vbak-vbeln OBLIGATORY,
                s_kunnr FOR  vbak-kunnr,
                s_shipto FOR  vbpa-kunnr.

selection-screen skip 1.
parameter:  p_cdown as checkbox default 'X'.
SELECTION-SCREEN END OF BLOCK blk1.
*----------------------------------------------------------------------*
*    AT SELECTION SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.

data: l_aufnr like coas-aufnr.

  REFRESH it_vbak. CLEAR it_vbak.
  REFRESH it_error. CLEAR it_error.

  SELECT vbeln auart vkorg kunnr FROM vbak
    INTO wa_vbak
   WHERE vbeln IN s_vbeln
     AND vkorg IN s_vkorg
     AND kunnr IN s_kunnr.


   IF wa_vbak-auart NE 'KB'.
     it_error-aufnr = wa_vbak-vbeln.
     APPEND it_error. CLEAR it_error.
   ELSE.
     CLEAR wa_coas.
     SELECT SINGLE aufnr ktext kdauf kokrs objnr FROM coas client specified
       INTO wa_coas
      WHERE bukrs = wa_vbak-vkorg
        AND kdauf = wa_vbak-vbeln
        and mandt = sy-mandt.
     IF NOT wa_coas IS INITIAL.
       move: wa_coas-aufnr to l_aufnr.
       shift l_aufnr left deleting leading '0'.
       concatenate 'PROJ' l_aufnr into wa_coas-xblnr.
       APPEND wa_coas to it_coas.
     ELSE.
       it_error-aufnr = wa_vbak-vbeln.
       APPEND it_error. CLEAR it_error.
     ENDIF.

     it_vbak-vbeln = wa_vbak-vbeln.
     it_vbak-auart = wa_vbak-auart.
     it_vbak-vkorg = wa_vbak-vkorg.
     it_vbak-kunnr = wa_vbak-kunnr.
     APPEND it_vbak. CLEAR it_vbak.
   ENDIF.

  ENDSELECT.

*----------------------------------------------------------------------*
*    START OF SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.

  perform select_data.          "Select header data

  if p_cdown = 'X'.
      perform dwn_pay_logic.
  endif.

  perform sales_value.
  perform prod_mat_list.
  perform app_serv_rev.
*  perform app_serv_cost.
  perform int_order_po.
  perform int_order_misc.
  perform display_header.
  perform display_footer.
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  display_header
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM display_header .

loop at it_vbak.


  READ TABLE it_coas WITH KEY kdauf = it_vbak-vbeln.
  IF SY-SUBRC NE 0.
    CLEAR it_coas.
  ENDIF.

  READ TABLE it_kna1 WITH KEY kunnr = it_vbak-kunnr.
  IF SY-SUBRC NE 0.
    CLEAR it_kna1.
  ENDIF.

  READ TABLE it_name WITH KEY vbeln = it_vbak-vbeln.
  IF SY-SUBRC NE 0.
    CLEAR it_name.
  ENDIF.

  NEW-PAGE.
  SKIP.
  WRITE : /122 'Date :'(004), SY-DATUM DD/MM/YY, SY-UZEIT,
          /47 'PROJECT CONTROLLING REPORT'(005),
          122 'User :'(006), SY-UNAME.

  SKIP.
  ULINE AT 1(147).
  WRITE :   /1 sy-vline,
             4 'Criteria'(007),
            25  ':',
            27 'Project Number'(008),
            44 ':',
            46 it_vbak-vbeln,
            59 '; Internal Order'(009),
            78 ':',
            80 it_coas-aufnr,
           147 sy-vline.

  WRITE :   /1 sy-vline,
             4 'Project Description'(010),
            25  ':',
            27 it_coas-ktext,
           147 sy-vline.

  WRITE :   /1 sy-vline,
             4 'Customer/Sold-to'(011),
            25  ':',
            27 it_kna1-kunnr,
            35 it_kna1-name1,
           147 sy-vline.

  WRITE :   /1 sy-vline,
             4 'Ship-to'(012),
            25  ':',
            27 it_name-kunnr,
            35 it_name-name1,
           147 sy-vline.
  SET BLANK LINES ON.
  ULINE AT 1(147).

** Item Header
  write  :  /1  sy-vline,
                'Product/Category'(013),
            25  'Description'(014),
            60  'Period/Year'(015),
            80  'Amount'(016),
           100  'Quantity'(017),
           120  'DocNo.'(019),
           147  sy-vline.
  write  :  /1  sy-vline, 147 sy-vline.
  perform write_details.

endloop.

ENDFORM.                    " display_header
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  select_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM select_data .

  IF it_vbak[] IS INITIAL.
       message e999 with 'No data available.Please ensure correct selection.'(003).
  else.

  REFRESH it_kna1. CLEAR it_kna1.
  SELECT kunnr name1 FROM kna1
    INTO TABLE it_kna1
    FOR ALL ENTRIES IN it_vbak
    WHERE kunnr = it_vbak-kunnr.

    REFRESH it_vbpa. CLEAR it_vbpa.
    SELECT vbeln kunnr FROM vbpa
      INTO TABLE it_vbpa
      FOR ALL ENTRIES IN it_vbak
      WHERE vbeln = it_vbak-vbeln
        AND kunnr IN s_shipto
        AND parvw = 'WE'.

  REFRESH it_name. CLEAR it_name.
    LOOP AT it_vbpa.

      SELECT SINGLE name1 FROM kna1
        INTO it_name-name1
        WHERE kunnr = it_vbpa-kunnr.

      IF NOT it_name-name1 IS INITIAL.
        it_name-vbeln = it_vbpa-vbeln.
        it_name-kunnr = it_vbpa-kunnr.
        APPEND it_name. CLEAR it_name.
      ENDIF.
    ENDLOOP.
  endif.

ENDFORM.                    " select_data
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  dwn_pay_logic
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM dwn_pay_logic .

data: l_xblnr(15) type C.
*      l_hkont like bseg-hkont.

  select bukrs belnr gjahr xblnr from bkpf
      into table it_bkpf
      for all entries in it_coas
        where xblnr = it_coas-xblnr
          and blart = 'DZ'
          and bukrs = it_coas-kokrs.

          if not it_bkpf[] is initial.      "Got downpayment, so pick details
              select bukrs gjahr belnr bschl pswbt augbl shkzg hkont zfbdt from bseg
                  into table it_bseg
                  for all entries in it_bkpf
                    where bukrs = it_bkpf-bukrs
                      and gjahr = it_bkpf-gjahr
                      and belnr = it_bkpf-belnr
                      and bschl = '19'.
          endif.

          if not it_bseg[] is initial.
              select bukrs gjahr belnr bschl pswbt augbl shkzg hkont zfbdt from bseg
                  into table it_bseg1
                  for all entries in it_bseg
                    where bukrs = it_bseg-bukrs
                      and gjahr = it_bseg-gjahr
                      and belnr = it_bseg-augbl
                      and bschl = '09'.
          endif.

          loop at it_bseg.                    "Downpayment details
            read table it_bkpf with key bukrs = it_bseg-bukrs
                                        belnr = it_bseg-belnr
                                        gjahr = it_bseg-gjahr binary search.

            read table it_coas with key kokrs = it_bkpf-bukrs
                                        xblnr = it_bkpf-xblnr binary search.

            select single txt20 from skat        "pick prdcat/hkont desc
                   into it_final-ktext
                       where saknr = it_bseg-hkont.

              if it_bseg-augbl ne space.      "Got cleared downpayment
                  loop at it_bseg1 where belnr = it_bseg-augbl
                                     and bukrs = it_bseg-bukrs.
*                      clear it_final.
*                      select single txt20 from skat        "pick prdcat/hkont desc
*                           into it_final-ktext
*                               where saknr = it_bseg-hkont.

                      move: it_bseg1-zfbdt to it_final-peryr,
                            it_bseg1-pswbt to it_final-dmbtr,
                            it_bseg1-belnr to it_final-docno,
                            it_bseg1-hkont to it_final-prdcat.
                      move: it_coas-kokrs to it_final-kokrs,
                            it_coas-aufnr to it_final-aufnr,
                            it_coas-kdauf to it_final-kdauf.
                      if it_bseg1-shkzg = 'H'.
                          it_final-dmbtr = it_final-dmbtr * -1.
                      endif.
                      shift it_final-prdcat left deleting leading '0'.
                      shift it_final-aufnr left deleting leading '0'.
                      concatenate it_final-peryr+4(2) it_final-peryr(4) into it_final-peryr separated by '/'.
                      append it_final.
                  endloop.
              else.                            "No cleared downpayment
                  move: it_bseg-hkont to it_final-prdcat,
                        it_bseg-zfbdt to it_final-peryr,
                        it_bseg-pswbt to it_final-dmbtr,
                        it_bseg-belnr to it_final-docno,
                        it_bseg-hkont to it_final-prdcat.
                      move: it_coas-kokrs to it_final-kokrs,
                            it_coas-aufnr to it_final-aufnr,
                            it_coas-kdauf to it_final-kdauf.

                      if it_bseg1-shkzg = 'H'.
                          it_final-dmbtr = it_final-dmbtr * -1.
                      endif.
                      shift it_final-prdcat left deleting leading '0'.
                      shift it_final-aufnr left deleting leading '0'.
                      concatenate it_final-peryr+4(2) it_final-peryr(4) into it_final-peryr separated by '/'.
                  append it_final.
              endif.
          endloop.

ENDFORM.                    " dwn_pay_logic
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  display_footer
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM display_footer .

  skip 2.

  loop at it_error.
    at first.
      write: /10 'Sales order number entered is not a project!'(018).
    endat.
      write: /10 it_error-aufnr.
  endloop.
ENDFORM.                    " display_footer
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  write_details
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM write_details .

    sort it_final ascending by kokrs kdauf aufnr prdcat.
    sort it_final1 by kokrs kdauf aufnr ktext.

    shift it_coas-aufnr left deleting leading '0'.

    loop at it_final where kdauf = it_vbak-vbeln and aufnr = it_coas-aufnr .

        write: /01 sy-vline,
                   it_final-prdcat,
               25  it_final-ktext,
               60  it_final-peryr,
               75  it_final-dmbtr currency bseg-pswsl,
              100  it_final-qty no-zero,
              120  it_final-docno,
              147  sy-vline.

              at end of prdcat.
                sum.
                write: /01 sy-vline,
                        60 'Total'(001),
                        75 it_final-dmbtr,
                       100 it_final-qty no-zero,
                       147 sy-vline.
                write: /01 sy-vline, 147 sy-vline.
              endat.


              at end of aufnr.
                  write: /01 sy-uline(147).

                  loop at it_final1 where kokrs = it_final-kokrs
                                      and kdauf = it_final-kdauf
                                      and aufnr = it_final-aufnr.
                      at new aufnr.
                          write: /01  sy-vline,
                                      'Details from Internal Order'(002),
                                  147 sy-vline.
                          write: /01  sy-vline,
                                 147  sy-vline.
                      endat.

                      write: /01 sy-vline,
                                 it_final1-prdcat no-zero,
                             25  it_final1-ktext,
                             60  it_final1-peryr,
                             75  it_final1-dmbtr currency bseg-pswsl,
                            100  it_final1-qty no-zero,
                            120  it_final1-docno,
                            147  sy-vline.

                      at end of prdcat.
                        sum.
                        write: /01 sy-vline,
                                60 'Total'(001),
                                75 it_final1-dmbtr,
                               100 it_final1-qty no-zero,
                               147 sy-vline.
                        write: /01 sy-vline, 147 sy-vline.
                      endat.

                      at last.
                        write: /01 sy-uline(147).
                      endat.
                  endloop.
              endat.
    endloop.

ENDFORM.                    " write_details
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  sales_value
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM sales_value .

data: l_erdat like vbfa-erdat,
      l_belnr like cobk-belnr.

refresh it_coep.

  select vbelv posnv vbeln posnn vbtyp_n erdat from vbfa
    into table it_vbfa
    for all entries in it_coas
        where vbelv = it_coas-kdauf
          and vbtyp_n = 'M'.

  loop at it_coas.
*   clear it_final.
    shift it_coas-aufnr left deleting leading '0'.
    move: it_coas-kokrs to it_final-kokrs,
          it_coas-kdauf to it_final-kdauf,
          it_coas-aufnr to it_final-aufnr.

          loop at it_vbfa where vbelv = it_coas-kdauf.
              move: it_vbfa-erdat(4) to l_erdat.

              select single belnr from cobk into l_belnr
                  where refbn = it_vbfa-vbeln
                    and kokrs = it_coas-kokrs
                    and gjahr = l_erdat.

*****Start do performance tuning here!!
*                select kokrs belnr objnr perio gjahr beknz wkgbtr kstar mbgbtr from coep
*                  into table it_coep
*                    where kokrs = it_coas-kokrs
*                      and belnr = l_belnr
*                      and mbgbtr ne 0.
                select kokrs belnr objnr perio gjahr beknz wkgbtr kstar mbgbtr from coep client specified
                  into table it_coep
                    where mandt = sy-mandt
                      and kokrs = it_coas-kokrs
                      and belnr = l_belnr
                      and mbgbtr ne 0
                      .
*****End do performance tuning here!!


              loop at it_coep.
                  select single txt20 from skat into it_final-ktext
                      where saknr = it_coep-kstar
                        and spras = sy-langu.

                    move: it_coep-kstar to it_final-prdcat,
                          it_coep-wkgbtr to it_final-dmbtr,
                          it_coep-mbgbtr to it_final-qty.
                    concatenate it_coep-perio it_coep-gjahr into it_final-peryr separated by '/'.
                    shift it_final-prdcat left deleting leading '0'.
                    move: it_vbfa-vbeln to it_final-docno.
                    append it_final.
              endloop.
*                endselect.
          endloop.

  endloop.
ENDFORM.                    " sales_value
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  prod_mat_list
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM prod_mat_list .

  refresh: it_vbfa.

    select vbelv posnv vbeln posnn vbtyp_n erdat matnr rfwrt rfmng from vbfa
       into table it_vbfa
       for all entries in it_coas
          where vbelv eq it_coas-kdauf
            and vbtyp_n eq 'R'
            and rfwrt ne 0.

  loop at it_coas.
    shift it_coas-aufnr left deleting leading '0'.
    move: it_coas-kokrs to it_final-kokrs,
          it_coas-kdauf to it_final-kdauf,
          it_coas-aufnr to it_final-aufnr.

          loop at it_vbfa where vbelv = it_coas-kdauf.
              select single maktx from makt
                  into it_final-ktext
                  where spras eq sy-langu
                    and matnr eq it_vbfa-matnr.

              move: it_vbfa-matnr to it_final-prdcat,
                    it_vbfa-rfwrt to it_final-dmbtr,
                    it_vbfa-rfmng to it_final-qty,
                    it_vbfa-vbeln to it_final-docno.
              shift it_final-prdcat left deleting leading '0'.
              concatenate it_vbfa-erdat+4(2) it_vbfa-erdat(4) into it_final-peryr separated by '/'.

              append it_final.
          endloop.
          clear it_final.
  endloop.

ENDFORM.                    " prod_mat_list
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  int_order_po
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM int_order_po .

    select ebeln ebelp aufnr from ekkn
        into table it_ekkn
        for all entries in it_coas
          where aufnr = it_coas-aufnr.

      if not it_ekkn[] is initial.
          select belnr budat wrbtr ebeln ebelp from ekbe
              into table it_ekbe
              for all entries in it_ekkn
                  where ebeln = it_ekkn-ebeln
                    and ebelp = it_ekkn-ebelp
                    and bewtp = 'Q'.
      endif.

      loop at it_coas.
          clear it_final1.

          move: it_coas-aufnr to it_final1-prdcat,
                it_coas-aufnr to it_final1-aufnr,
                it_coas-kokrs to it_final1-kokrs,
                it_Coas-kdauf to it_final1-kdauf,
                it_coas-ktext to it_final1-ktext.
          shift it_final1-prdcat left deleting leading '0'.
          shift it_final1-aufnr left deleting leading '0'.

                loop at it_ekkn where aufnr = it_coas-aufnr.
                         loop at it_ekbe where ebeln = it_ekkn-ebeln
                                           and ebelp = it_ekkn-ebelp.

                              concatenate it_ekbe-budat+4(2) it_ekbe-budat(4) into it_final1-peryr separated by '/'.
                              move: it_ekbe-wrbtr to it_final1-dmbtr,
                                    it_ekbe-belnr to it_final1-docno.

                              case it_ekbe-shkzg.
                                  when 'H'.
                                      it_final1-dmbtr = it_final1-dmbtr * -1.
                              endcase.
                              append it_final1.
                         endloop.

                endloop.

      endloop.

ENDFORM.                    " int_order_po
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  int_order_misc
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM int_order_misc .

refresh: it_coep.

*      select kokrs belnr objnr perio gjahr BEKNZ wkgbtr from coep
*          into table it_coep
*          for all entries in it_coas
*              where kokrs = it_coas-kokrs
*                and objnr = it_Coas-objnr
*                and wrttp = '11'.
        select kokrs belnr objnr perio gjahr BEKNZ wkgbtr from coep client specified
            into table it_coep
            for all entries in it_coas
                    where kokrs = it_coas-kokrs
                      and objnr = it_coas-objnr
                      and wrttp = '11'
                      and mandt = sy-mandt.
          loop at it_coas.
                clear: it_final1.
                shift it_coas-aufnr left deleting leading '0'.
                move: it_coas-aufnr to it_final1-aufnr,
                      it_coas-kdauf to it_final1-kdauf,
                      it_coas-kokrs to it_final1-kokrs.

                loop at it_coep where kokrs = it_coas-kokrs
                                  and objnr = it_coas-objnr.
                    move: 'Miscellaneous Expenses' to it_final1-ktext,
                          it_coep-wkgbtr to it_final1-dmbtr,
                          it_coep-belnr to it_final1-docno.
                    concatenate it_coep-perio it_coep-gjahr into it_final1-peryr separated by '/'.

                    if it_coep-BEKNZ = 'H'.
                        it_final1-dmbtr = it_final1-dmbtr * -1.
                    endif.

                    append it_final1.
                endloop.
          endloop.

ENDFORM.                    " int_order_misc
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  app_serv_rev
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM app_serv_rev .

data: l_erdat like vbfa-erdat.

    refresh: it_vbfa.

    select vbelv posnv vbeln posnn vbtyp_n erdat matnr rfwrt rfmng from vbfa
       into table it_vbfa
       for all entries in it_coas
          where vbelv eq it_coas-kdauf
            and vbtyp_n eq 'M'.

    loop at it_vbfa.
        l_erdat = it_vbfa-erdat(4).

        select kokrs belnr gjahr refbn from cobk
*          into table it_cobk
          appending table it_cobk
            for all entries in it_coas
              where refbn = it_vbfa-vbeln
                and kokrs = it_Coas-kokrs
                and gjahr = l_erdat.
    endloop.

***Insert COEP selection here. Requirements starting from (H) onwards in func tech.

ENDFORM.                    " app_serv_rev
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2007 03:03:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586639#M591927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-27T03:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586640#M591928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enter SQL Trace &amp;#150; ST05&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Starting the Trace:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;To analyze a trace file, do the following:&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Choose the menu path Test &amp;amp;#61614; Performance Trace in the ABAP Workbench or go to Transaction ST05. The initial screen of the test tool appears. In the lower part of the screen, the status of the Performance Trace is displayed. This provides you with information as to whether any of the Performance Traces are switched on and the users for which they are enabled. It also tells you which user has switched the trace on.&lt;/P&gt;&lt;P&gt;Using the selection buttons provided, set which trace functions you wish to have switched on (SWL trace, enqueue trace, RFC trace, table buffer trace).&lt;/P&gt;&lt;P&gt;If you want to switch on the trace under your user name, choose Trace on.  If you want to pass on values for one or several filter criteria, choose Trace with Filter.  Typical filter criteria are: the name of the user, transaction name, process name, and program name.&lt;/P&gt;&lt;P&gt;Now run the program to be analyzed.&lt;/P&gt;&lt;P&gt;Stopping the Trace:&lt;/P&gt;&lt;P&gt;To deactivate the trace:&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Choose Test &amp;amp;#61614;Performance Trace in the ABAP Workbench. The initial screen of the test tool appears. It contains a status line displaying the traces that are active, the users for whom they are active, and the user who activated them.&lt;/P&gt;&lt;P&gt;Select the trace functions that you want to switch off.&lt;/P&gt;&lt;P&gt;Choose Deactivate Trace. If you started the trace yourself, you can now switch it off immediately. If the performance trace was started by a different user, a confirmation prompt appears before deactivation-&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;Analyzing a Sample trace data:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt; PREPARE: Prepares the OPEN statement for use and determines the access method.&lt;/P&gt;&lt;P&gt;OPEN: Opens the cursor and specifies the selection result by filling the selection fields with concrete values. &lt;/P&gt;&lt;P&gt;FETCH: Moves the cursor through the dataset created by the OPEN operation. The array size displayed beside the fetch data means that the system can transfer a maximum package size of 392 records at one time into the buffered area.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2007 06:36:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586640#M591928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-27T06:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586641#M591929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i had explained all the steps &lt;/P&gt;&lt;P&gt;reward if usefull&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2007 06:45:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586641#M591929</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-27T06:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586642#M591930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;one more time, but the last time,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;follow the explanations abouut the SQL trace and use the summary as I have explained. Even if nobody else recommends it, I knwso what I am talking about.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add the summary here, this will show where the problems of your program are.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2007 07:58:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586642#M591930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-27T07:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586643#M591931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Naresh,&lt;/P&gt;&lt;P&gt;Thanks for the reply. I have done all of the required steps. I can see that the FETCH operation of almost all select statements give me red color. The duration of this FETCH operation is huge! How to resolve this? Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2007 01:05:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586643#M591931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-28T01:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586644#M591932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry, you did not follow my explanation ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Execute your program at least once before you trace it, otherwise you measure disk performance, that is not what you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create the SQL Statement Summary, there are not fetches anymore.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, the fetch operations are the slowest, the rest is preparation, red color is irrelevant, you must see the numbers in relation to the found records. The time is in microseconds, I looks larger than it is &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write down total time and time for top statements!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2007 07:19:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586644#M591932</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-28T07:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: SQL trace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586645#M591933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried,&lt;/P&gt;&lt;P&gt;I have done the steps you provide above. I can see that the duration for select statement of table COAS and COEP is very long. My question: How do I go about reducing this duration? &lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2007 07:48:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-trace/m-p/2586645#M591933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-28T07:48:01Z</dc:date>
    </item>
  </channel>
</rss>

