Oracle internal queries taking more CPU time

Hi,
Following are queries taking more CPU time. I got this from awr report. Can anyone tell me why these queries are running? Is it a oracle enterprise manager query? should I use
emctl stop dbconsole to stop this?
DECLARE job BINARY_INTEGER := :job; next_date DATE := :mydate; broken BOOLEAN := FALSE; BEGIN EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS(); :mydate := next_date; IF broken THEN :b := 1; ELSE :b := 0; END IF; END;
SELECT COUNT(*) FROM MGMT_METRIC_DEPENDENCY_DETAILS DEP, MGMT_SEVERITY SEV WHERE DEP.TARGET_GUID = :B5 AND DEP.METRIC_GUID = :B4 AND DEP.KEY_VALUE = :B3 AND DEP.EDEP_TARGET_GUID = SEV.TARGET_GUID AND DEP.EDEP_METRIC_GUID = SEV.METRIC_GUID AND DEP.DEP_KEY_VALUE = SEV.KEY_VALUE AND SEV.COLLECTION_TIMESTAMP BETWEEN :B2 AND :B1
SELECT CURRENT_STATUS FROM MGMT_CURRENT_AVAILABILITY WHERE TARGET_GUID = :B1
Thanks in advance
With Regards
boobathi.P

Hi,
maybe this document will help if you are using 10g:
SQL run by SYSMAN consuming a lot of resources on OMS with 800+ targets [ID 330383.1]
https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=PROBLEM&id=330383.1
there you'll find Cause and Solution too:
SYSMAN Job and Queries are Taking Up High CPU (DB Console) [ID 1288301.1]
https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=PROBLEM&id=1288301.1
For databases above version 11.1 there are paches available.
Best,
Michael T. Z.

Similar Messages

  • Dbms_stats.cleanup_stats_db_proc taking more CPU time.

    Hi All,
    Oracle 11g R2(11.2.0.3) EE , on Linux machine.
    Oracle auto optimizer stats collection enabled in our environment. In that dbms_stats.cleanup_stats_db_proc() taking more CPU time (more than 24 hours).
    Could you please suggest any solution.
    Thanks in advance.
    BR,
    Surya

    suresh.ratnaji wrote:
    NAME                                 TYPE        VALUE
    _optimizer_cost_based_transformation string      OFF
    filesystemio_options                 string      asynch
    object_cache_optimal_size            integer     102400
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.4
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      choose
    optimizer_secure_view_merging        boolean     TRUE
    plsql_optimize_level                 integer     2
    please let me know why it taking more time in INDEX RANGE SCAN compare to the full table scan?Suresh,
    Any particular reason why you have a non-default value for a hidden parameter, optimizercost_based_transformation ?
    On my 10.2.0.1 database, its default value is "linear". What happens when you reset the value of the hidden parameter to default?

  • Process SERVER0 its taking High CPU Time in XI

    Hi,
    We installed XI 3.0 develpoment server ,Process <b>SERVER0</b> its taking more CPU time.
    We are using AS/400 OS & DB2 datbase.Can any one tell me the reason & Solution for this.
    Thanks & Regards,
    Gopinath.

    hi,
    Actually the user XIRWBUSER its an RFC user but its running on many dialog process.I think high CPU time due to this user only.
    using 5 work processes and 3/4 of the available CPU for an extended amount of time.
    Total Total DB
    Job or CPU Sync Async CPU
    Task User Number Thread Pty Util I/O I/O Util
    WP11 D6464 485368 00000010 20 54.0 25 37 27.8
    WP05 X4242 498642 00000098 20 49.6 5 0 36.7
    WP04 X4242 498641 00000014 20 48.8 1 0 39.1
    WP02 X4242 498639 0000025A 20 47.1 2 0 37.8
    WP06 X4242 498643 000001E6 20 43.7 0 0 38.3
    WP00 X4242 498637 00000014 20 11.1 502 194 2.9
    pls can any one help me
    Regards,
    Gopinath.

  • How to find which query taking more cpu

    Hi,
    How to find which query taking more CPU
    at a particular point of time .
    Chhers,

    Take a look at Server Standard Reports. It has a few CPU usage oriented reports.
    You can also track CPU usage by server-side tracing:
    http://www.sqlusa.com/bestpractices/createtrace/
    Glenn Berry's CPU usage query:
    SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime],
    qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count,
    ISNULL(qs.execution_count/DATEDIFF(Second, qs.cached_time, GETDATE()), 0) AS [Calls/Second],
    qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count
    AS [avg_elapsed_time], qs.cached_time
    FROM sys.procedures AS p WITH (NOLOCK)
    INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
    ON p.[object_id] = qs.[object_id]
    WHERE qs.database_id = DB_ID()
    ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE);
    LINK:
    http://dba.stackexchange.com/questions/52216/sql-server-2008-high-cpu-historical-queries
    Query optimization:
    http://www.sqlusa.com/articles/query-optimization/
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to find top 10  SQL statments which are consuming more cpu time.

    hi all,
    Is there any command or script to monitor the top 10 sql statments which are consuming more cpu time.
    I know by using AWR REPORT we can find it, i want the command or script to find the top cpu utilization sql statments.
    Regards
    Subhash.

    Subhash,
    A quick and dirty Google search could have get you started with the following:
    Thread: how to get top CPU consuming sql oracle 10g
    Re: how to get top CPU consuming sql oracle 10g
    Oracle SQL top sessions
    http://www.dba-oracle.com/oracle10g_tuning/t_sql_top_sessions.htm
    "How to Find top 10 expensive sql's", version 9.2.0
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:73325450402303
    HTH,
    Thierry

  • Urgt:How to identify TOP 5 SQL using more CPU time  without using statspack

    How to identify the TOP 5 SQL queries which are consuming more CPU time during the timespan of 24 hours for entire database. There are N number of users who have issued sql queries, out of which few users have disconnected and few user are still connected to the database(I need to consider all sessions). My database version is 9.0.1. I don't want to use statspack. Is there any way to identify TOP 5 SQL consuming more CPU time without affecting the performance of the database. Can any one help me on this? Its urgent!!. I don't want to use statspack becasue it degrades the performance and i cannot afford to run it for 24 hours.

    You don't run statspack for 24 hours, that would infact be pointless...
    Run statspack for say a 10 or 15 minute window during a particular "busy" period on your database. If you run it for longer then all the useful data will have been "averaged out". You want a snapshot in time, not an average over the day.

  • How to identify TOP 5 SQL consuming more CPU time without using statspack

    How to identify the TOP 5 SQL queries which are consuming more CPU time during the timespan of 24 hours for entire database. There are N number of users who have issued sql queries, out of which few users have disconnected and few user are still connected to the database(I need to consider all sessions). My database version is 9.0.1. I don't want to use statspack. Is there any way to identify TOP 5 SQL consuming more CPU time without affecting the performance of the database. Can any one help me on this? Its urgent!!.

    My database version is 9.0.1. I don't want
    to use statspack. Is there any way to identify TOP 5
    SQL consuming more CPU time without affecting the
    performance of the database. Can any one help me on
    this? Its urgent!!.I cant understand why you dont want to use statspack. As it is very easy to use and very quick to identify bottlenecks. Try using statspack. Its really wonderful.
    Particularly in your case statspack is the best.
    Regards,
    Sanju.

  • Query to find adhoc queries taking high cpu on server

    Hi,
    I want to find all the adhoc and other queries consuming high cpu on sql server. sys.dm_exec_cahched_plan will only have cached queries and not the currently running ones.

    Hi Preetha7,
    According to your description, if you want to identify the most expensive SQL Server queries based on the cumulative CPU cost, you can use the DMVs of the sys.dm_exec_sql_text , the sys.dm_exec_query_plan and sys.dm_exec_query_stats. For example, you can
    refer to the following T-SQL statement.
    SELECT TOP 20
    qs.sql_handle,
    qs.execution_count,
    qs.total_worker_time AS Total_CPU,
    total_CPU_inSeconds = --Converted from microseconds
    qs.total_worker_time/1000000,
    average_CPU_inSeconds = --Converted from microseconds
    (qs.total_worker_time/1000000) / qs.execution_count,
    qs.total_elapsed_time,
    total_elapsed_time_inSeconds = --Converted from microseconds
    qs.total_elapsed_time/1000000,
    st.text,
    qp.query_plan
    FROM
    sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
    CROSS apply sys.dm_exec_query_plan (qs.plan_handle) AS qp
    ORDER BY qs.total_worker_time DESC
    Or you can run the "Performance - Top Queries By Total CPU Time" report in SSMS. In addition, you can use SQL Server Extended Events session for troubleshooting the high consumed of CPU time. For more information about finding currently session that is costing
    high CPU.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/cb3e29ca-f1ef-4440-8f1a-db4924a43c5c/find-currently-session-that-is-costing-high-cpu?forum=sqldatabaseengine
    http://blogs.msdn.com/b/batala/archive/2011/07/23/troubleshoot-high-cpu-issue-without-using-profile-traces.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Oracle Drop command taking more time in AIX When compared to Windows

    Hi
    We are firing a normal Drop command on our database and the databse version is 10.2.0.4.The catabase is running on AIX v5.The command is taking more time than usual .
    There are no waits on session.Let me try to put the scenario in more simple terms.I have a nested table NT_TEST with record count 0 and i am dropping the statement using "Drop table NT_TEST" in windows it is getting dropped say some 218 Milli seconds.
    The same table when i am dropping it in AIX it is taking around 6 seconds.
    There are no locks ,Flashback is off,Triggers are not involved.Drop is not waiting on any transaction to complete.
    Could anybody help me out on this.

    Quite possible. On most Unixes asynchronous I/O requires purchasing extra options, and most sites just purchase the default O/S. Or asynchronous I/O is not enabled by default or the database is located on an ufs file system.
    You provided no info at all on your AIX configuration. AIX does have asynchronous I/O, it is not always enabled, and the number of slaves is usually way too low.
    As root, run smit aio and report the results.
    At his point your unfavorable comparison of Windows and AIX is quite unfair. Unix doesn't run out of the box.
    You know that famous joke 'If operating systems were airplanes'?
    In that joke, the Unix airplane is assembled on the spot, but the Windows airplane is three months late.
    Sybrand Bakker
    Senior Oracle DBA

  • REPORT TAKING MORE CPU UTILIZATION

    Hello Experts,
    my following report is of sales order report it gives me an output in less than 250 seconds,
    But taking 80 percentage CPU time so tell me how to overcome this problem ??
    <b>&----
    *& Report  ZMSL_SALES_ORDER_REPORT
    REPORT  ZMSL_SALES_ORDER_REPORT.
    DEFINE: M_FIELDCAT.
      ADD 1 TO LS_FIELDCAT-COL_POS.
      LS_FIELDCAT-FIELDNAME = &1.
      LS_FIELDCAT-SELTEXT_L = &2.
      LS_FIELDCAT-OUTPUTLEN = &3.
      LS_FIELDCAT-TABNAME = 'gt_final_data'.
      APPEND LS_FIELDCAT TO FELD_CAT.
    END-OF-DEFINITION.
    *==================Start of Datebase tables Declaration=================
    TABLES : VBAK, "Sales Document: Header Data
             VBAP, "Sales Document: Item Data
             MARA, "Matrial Master
             VBEP, "Sales Document: Schedule Line Data
             VBPA, "Sales Document: Partner
             TVROT,
             YMSLT_MAIL_ID.
    *=================End of Datebase tables Declaration====================
    *==================Start of Virable  ALV  declaration=================
    **=============================
    TYPE POOLS
    *=============================
    TYPE-POOLS: SLIS.
    *=============================
    *FIELD CATALOG DECLARATION
    *=============================
    CONSTANTS : CO_FORMNAME_TOP_OF_PAGE  TYPE SLIS_FORMNAME
                                         VALUE 'TOP_OF_PAGE'.
    DATA : G_TABNAME_HEADER TYPE SLIS_TABNAME,
           G_TABNAME_ITEM   TYPE SLIS_TABNAME.
    DATA:  FELD_CAT TYPE SLIS_T_FIELDCAT_ALV," WITH HEADER LINE ,
           ALV_LAYOUT   TYPE SLIS_LAYOUT_ALV,
           T_EVENTS           TYPE SLIS_T_EVENT,
           G_SAVE(1) TYPE C,
           G_VARIANT LIKE DISVARIANT,
           GX_VARIANT LIKE DISVARIANT,
           EVENTS   TYPE SLIS_T_EVENT,
           G_EXIT(1) TYPE C,
           LAYOUT   TYPE SLIS_LAYOUT_ALV,
           ALV_PRINT        TYPE SLIS_PRINT_ALV,
           ALV_DETAIL_FUNC(30),
          EVENTS   TYPE SLIS_T_EVENT,
           T_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
    CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    RANGES : R_PARVW FOR VBPA-PARVW.
    *=================End of Virable  tables Declaration====================
    *==================Start of Selection Screen Declaration================
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN BEGIN OF BLOCK VAR WITH FRAME TITLE VARIANT.
    PARAMETERS     : P_VARI LIKE DISVARIANT-VARIANT.
    SELECTION-SCREEN END OF BLOCK VAR.
    SELECTION-SCREEN :BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    SELECT-OPTIONS : S_VKORG FOR VBAK-VKORG OBLIGATORY, " Sales Org.
                     S_VKBUR FOR VBAK-VKBUR, " Sales Office
                     S_VKGRP FOR VBAK-VKGRP, " Sales Group
                     S_VTWEG FOR VBAK-VTWEG. " Distribution Channel
    SELECTION-SCREEN :END OF BLOCK B2.
    SELECTION-SCREEN :BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
    SELECT-OPTIONS : S_KUNNR FOR VBAK-KUNNR, "Customer Number
                     S_VBELN FOR VBAK-VBELN, "Sales Order Number
                     S_ERDAT FOR VBAK-ERDAT, "OBLIGATORY, "Sales Order Date
                     S_AUGRU FOR VBAK-AUGRU, "Order Reason
                     S_BSTNK FOR VBAK-BSTNK, "PO Number
                     S_AUART FOR VBAK-AUART. "Sales order type
    SELECTION-SCREEN :END OF BLOCK B3.
    SELECTION-SCREEN :BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004.
    SELECT-OPTIONS : S_WERKS FOR VBAP-WERKS,  "plant,
                     S_MATNR FOR VBAP-MATNR, " Matrial Code
                     S_PSTYV FOR VBAP-PSTYV, "Sales Order Item cat.
                     S_EDATU FOR VBEP-EDATU,  "Conformatin Date
                     S_REQDAT FOR VBAP-ZZCUST_REQDAT. "Req.Del Date
    SELECTION-SCREEN :END OF BLOCK B4.
    SELECTION-SCREEN :BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-005.
    SELECT-OPTIONS : S_ZE FOR  VBPA-KUNNR NO INTERVALS NO-EXTENSION , "Partner Function
                     S_ZS FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION, "Partner Function
                     S_ZA FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION, "Partner Function
                     S_ZR FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION, "Partner Function
                     S_ZI FOR VBPA-KUNNR NO INTERVALS NO-EXTENSION. "Partner Function
    *FOR VBPA-KUNNR MATCHCODE OBJECT ZSMR ,
    ***SELECT-OPTIONS : S_ZE FOR  VBPA-PARVW NO INTERVALS NO-EXTENSION , "Partner Function
                    S_ZS FOR VBPA-PARVW NO INTERVALS NO-EXTENSION, "Partner Function
                    S_ZA FOR VBPA-PARVW NO INTERVALS NO-EXTENSION, "Partner Function
                    S_ZR FOR VBPA-PARVW NO INTERVALS NO-EXTENSION, "Partner Function
                    S_ZI FOR VBPA-PARVW NO INTERVALS NO-EXTENSION. "Partner Function
    SELECTION-SCREEN :END OF BLOCK B5.
    SELECTION-SCREEN : BEGIN OF BLOCK B6 WITH FRAME TITLE TEXT-006.
    PARAMETER :  P_SCREEN RADIOBUTTON GROUP RTYP DEFAULT 'X' USER-COMMAND
                                                     UCOMM ,
                 P_FILE  RADIOBUTTON GROUP RTYP,
                 P_MAIL  RADIOBUTTON GROUP RTYP.
    SELECTION-SCREEN :END OF BLOCK B6.
    SELECTION-SCREEN : BEGIN OF BLOCK B7 WITH FRAME TITLE TEXT-007.
    PARAMETER :  P_PEN RADIOBUTTON GROUP RE1 DEFAULT 'X' USER-COMMAND
                                                     UCOMM , " Pending Sales order
                 P_ALL  RADIOBUTTON GROUP RE1,  " ALL Sales order
                 P_BLOCK  RADIOBUTTON GROUP RE1.  " Blocked Sales order
                P_DELE   RADIOBUTTON GROUP RE1.  " Delevered Sales order
    SELECTION-SCREEN :END OF BLOCK B7.
    SELECTION-SCREEN : END OF BLOCK B1.
    *=================End of Selection Screen Declaration===================
    *==================Start of Internal table Declaration==================
    Internal table for vbak
    DATA : BEGIN OF GT_VBAK OCCURS 0 ,
                VBELN             LIKE VBAK-VBELN , " Sales Document Number
                ERDAT             LIKE VBAK-ERDAT , " Order Date
                AUART             LIKE VBAK-AUART,  "Sales Document Type
                VTWEG             LIKE VBAK-VTWEG,  "Distribution Channel
                SPART             LIKE VBAK-SPART,  "Division
                KNUMV             LIKE VBAK-KNUMV ,  "Number of the document condition
                BSTNK             LIKE VBAK-BSTNK, " cUSTOMER pURCHASE ORDER NUMBER
                BSTDK             LIKE VBAK-BSTDK,  "Customer purchase order date
                KUNNR             LIKE VBAK-KUNNR,  " Customer Code
                ZOA_RECP_PLAN_DT  LIKE VBAK-ZOA_RECP_PLAN_DT, "Order receipt at plant
           END OF GT_VBAK.
    Internal table for VBAP
    DATA : BEGIN OF GT_VBAP OCCURS 0,
              VBELN LIKE VBAP-VBELN, " Sales Document Number
              POSNR LIKE VBAP-POSNR, " Sales Doc. Line item number
              MATNR LIKE VBAP-MATNR,
              ABGRU LIKE VBAP-ABGRU, "Reason for rejection
              MEINS LIKE VBAP-MEINS,  "Base Unit of Measure
              FAKSP LIKE VBAP-FAKSP,
              NETWR  LIKE VBAP-NETWR, " Net Value
              KWMENG LIKE VBAP-KWMENG, " Order Quantity
              WERKS LIKE VBAP-WERKS, "PLANT
              LGORT LIKE VBAP-LGORT, "S.Loc
              ROUTE LIKE VBAP-ROUTE, " Route
              ZZWIDTH LIKE VBAP-ZZWIDTH, " widht
              ZZKDMAT LIKE VBAP-ZZKDMAT, " customer Matrial
              ZZBRAND LIKE VBAP-ZZBRAND, " bRAND
              ZZSPLDIA LIKE VBAP-ZZSPLDIA, "Spool Diameter
              ZZCUST_REQDAT LIKE VBAP-ZZCUST_REQDAT, " REquested Date
              ZZCOATING LIKE VBAP-ZZCOATING,
              ZZWEIGHT LIKE VBAP-ZZWEIGHT,
              ZZWEIGHT_UMO LIKE VBAP-ZZWEIGHT_UMO,
             END OF GT_VBAP.
    Internal table for VBEP
    DATA : BEGIN OF GT_VBEP OCCURS 0,
              VBELN LIKE VBEP-VBELN, " Sales Doc. Number
              POSNR LIKE VBEP-POSNR, " Sales Doc. Item Number
              ETENR LIKE VBEP-ETENR, "Delivery Schedule Line Number
              EDATU LIKE VBEP-EDATU, "Schedule line date
             END OF GT_VBEP.
    Internal table for VBPA
    DATA : BEGIN OF GT_VBPA OCCURS 0,
             VBELN LIKE VBAP-VBELN, "Sales Document Number
             POSNR LIKE VBAP-POSNR, "Sales Document Item Number
             PARVW LIKE VBPA-PARVW, "Partner Function
             KUNNR LIKE VBPA-KUNNR, " Customer Number
          END OF GT_VBPA.
    Internal table for VBKD
    DATA : BEGIN OF GT_VBKD OCCURS 0,
            VBELN LIKE VBKD-VBELN , " Sales Documet number
            KDGRP LIKE VBKD-KDGRP, " Custoemr Group
            INCO1 LIKE VBKD-INCO1, "Incoterms (Part 1)
            INCO2 LIKE VBKD-INCO2, "Incoterms (Part 2)
            ZTERM LIKE VBKD-ZTERM, " Payment Term
            STCUR LIKE VBKD-STCUR, " Exchang Rate
         END OF GT_VBKD.
    Internal table VBFA
    DATA : BEGIN OF GT_VBFA OCCURS 0 ,
             VBELV   LIKE VBFA-VBELV, " Preceding sales and distribution document
             POSNV   LIKE VBFA-POSNV, "Preceding item of an SD document
             VBELN   LIKE VBFA-VBELN, "Subsequent sales and distribution document
             POSNN   LIKE VBFA-POSNN, "Subsequent item of an SD document
             VBTYP_N LIKE VBFA-VBTYP_N, "Document category of subsequent document
             RFMNG   LIKE VBFA-RFMNG,    "Referenced quantity in base unit of measure
           END OF GT_VBFA.
    Internal table for KONV
    DATA :  BEGIN OF GT_KONV OCCURS 0,
                  KNUMV LIKE KONV-KNUMV, "Number of the document condition
                  KPOSN LIKE KONV-KPOSN, "Condition item number
                  KSCHL LIKE KONV-KSCHL , "Cond Type.
                  KBETR LIKE KONV-KBETR, " Rate per KG
                  WAERS LIKE KONV-WAERS, "currency
                  KWERT LIKE KONV-KWERT, "Condition value
              END OF GT_KONV.
    Internal table for MSKA,
    DATA  : BEGIN OF GT_MSKA OCCURS 0,
               MATNR LIKE MSKA-MATNR, "Matrial
               WERKS LIKE MSKA-WERKS, "PLANT
               LGORT LIKE MSKA-LGORT, "S. Loc
               CHARG  LIKE MSKA-CHARG,"Batch Number
               SOBKZ LIKE MSKA-SOBKZ, "Special Stock Indicator
               VBELN LIKE MSKA-VBELN , "Sales Doc Number
               POSNR LIKE MSKA-POSNR, "Sales Doc Item Number
               KALAB LIKE MSKA-KALAB, "Unrestricted-Use Stock
               KAINS LIKE MSKA-KAINS, " Stock in Quality Inspection
            END OF GT_MSKA.
    Internal table for MARD
    DATA : BEGIN OF GT_MARD OCCURS 0 ,
              MATNR LIKE MARD-MATNR, "Matrial
              WERKS LIKE MARD-WERKS, "PLANT
              LGORT LIKE MARD-LGORT, "S. Loc
              LABST LIKE MARD-LABST, "Valuated Unrestricted-Use Stock
           END OF GT_MARD.
    Internal table for KNA1
    DATA : BEGIN OF GT_KNA1 OCCURS 0,
               KUNNR LIKE KNA1-KUNNR , " Customer Number
               NAME1 LIKE KNA1-NAME1,  "Customer Name
               NAME2 LIKE KNA1-NAME2,  " Customer Name
               ORT01 LIKE KNA1-ORT01, "City
            END OF GT_KNA1.
    DATA: BEGIN OF GT_KNA1_1 OCCURS 0,
              KUNNR LIKE KNA1-KUNNR , " Customer Number
              NAME1 LIKE KNA1-NAME1,  "Customer Name
             ORT01 LIKE KNA1-ORT01,
           END OF GT_KNA1_1.
    Internal table for KNVV
    DATA : BEGIN OF GT_KNVV OCCURS 0,
                KUNNR LIKE KNVV-KUNNR , " Customer Number
                KLABC LIKE KNVV-KLABC, " Custoemr Class
           END OF GT_KNVV.
    Internal table for MAKT,
    DATA : BEGIN OF GT_MAKT OCCURS 0,
             MATNR LIKE MAKT-MATNR,  "Matrial
             SPRAS LIKE MAKT-SPRAS,
             MAKTX LIKE MAKT-MAKTX, "Matrial DESC
             MAKTG LIKE MAKT-MAKTG,
          END OF GT_MAKT.
    Internal table for MVKE
    DATA : BEGIN OF GT_MVKE OCCURS 0 ,
                MATNR LIKE MVKE-MATNR,  "Matrial
                MVGR1 LIKE MVKE-MVGR1, " Matrial Group
          END OF GT_MVKE.
    Internal table for TVM1T
    DATA : BEGIN OF GT_TVM1T OCCURS 0 ,
                 SPRAS LIKE TVM1T-SPRAS,
                 MVGR1 LIKE TVM1T-MVGR1, " Matrial Group
                 BEZEI LIKE TVM1T-BEZEI, "  Matrial Group DESC
          END OF GT_TVM1T.
    Internal table for TSPAT
    DATA : BEGIN OF GT_TSPAT OCCURS 0,
                SPRAS LIKE TSPAT-SPRAS,
                SPART LIKE VBAK-SPART,  "Division
                VTEXT LIKE TSPAT-VTEXT, "Division Desc
           END OF GT_TSPAT.
    Internal table for TVTWT
    DATA : BEGIN OF GT_TVTWT OCCURS 0 ,
            SPRAS LIKE TVTWT-SPRAS,
            VTWEG LIKE VBAK-VTWEG, "  Distribution Channel
            VTEXT LIKE TVTWT-VTEXT, "Distribution Channel Desc
           END OF GT_TVTWT.
    Internal table for TVAKT
    DATA : BEGIN OF GT_TVAKT OCCURS 0,
              SPRAS LIKE TVAKT-SPRAS,
              AUART LIKE VBAK-AUART,  "Sales Document Type
              BEZEI LIKE TVAKT-BEZEI, "sALES dOC TYPE Description
           END OF GT_TVAKT .
    Internal table for T151t
    DATA: BEGIN OF GT_VBUP OCCURS 0,
              VBELN LIKE VBUP-VBELN,
              POSNR LIKE VBUP-POSNR,
              GBSTA LIKE VBUP-GBSTA,
          END OF GT_VBUP.
    DATA : BEGIN OF GT_T151T OCCURS 0,
              SPRAS LIKE T151T-SPRAS,
              KDGRP LIKE VBKD-KDGRP, " Custoemr Group
              KTEXT LIKE T151T-KTEXT, " Custoemr Group Desc
          END OF GT_T151T.
    DATA : BEGIN OF GT_TVROT OCCURS 0,
              SPRAS LIKE TVROT-SPRAS,
              ROUTE LIKE TVROT-ROUTE, " Route code
              BEZEI LIKE TVROT-BEZEI , " Route Desc
           END OF GT_TVROT.
    DATA : BEGIN OF GT_T052U OCCURS 0,
              SPRAS LIKE T052U-SPRAS,
              ZTERM LIKE T052U-ZTERM, " Payment terms
              TEXT1 LIKE T052U-TEXT1, " text
           END OF GT_T052U.
    DATA: BEGIN OF GT_VBUK OCCURS 0,
             VBELN LIKE VBUK-VBELN,
             WBSTK LIKE VBUK-WBSTK,
          END OF GT_VBUK.
    *-------fINAL iNTERNAL TABLE FOR OUTPUT
    DATA : BEGIN OF GT_FINAL_DATA OCCURS 0,
                KUNNR             LIKE VBAK-KUNNR, " cUSTOMER CODE
                NAME(70)          TYPE C, " cUSTOMER NAME
                ORT01             LIKE KNA1-ORT01, "cITY
                S_KUNNR           LIKE VBAK-KUNNR, " cUSTOMER CODE
                S_NAME(70)        TYPE C, " cUSTOMER NAME
                S_ORT01           LIKE KNA1-ORT01, "cITY
                KLABC             LIKE KNVV-KLABC, " Custoemr Class
                VBELN(70)         TYPE C, "   LIKE VBAK-VBELN, "sALES oRDER nUMBER
                POSNR             LIKE VBAP-POSNR, "SALES ORDER LINE NUMBER
                INCO1             LIKE VBKD-INCO1, "Incoterms (Part 1)
                INCO2             LIKE VBKD-INCO2, "Incoterms (Part 2)
                KALAB             LIKE MSKA-KALAB, "Unrestricted-Use Stock
                KAINS             LIKE MSKA-KAINS, " Stock in Quality Inspection
                LABST             LIKE MARD-LABST, "Valuated Unrestricted-Use Stock
                ERDAT             LIKE VBAK-ERDAT , " Order Date
                MATNR             LIKE MAKT-MATNR,  "Matrial
                MAKTX             LIKE MAKT-MAKTX, "Matrial DESC
                MAKTG             LIKE MAKT-MAKTG, "Matrial DESC
                ZZKDMAT           LIKE VBAP-ZZKDMAT, "Customter Mat. Number
                ABGRU             LIKE VBAP-ABGRU, " Reason for rejection
                COLOR(20)         TYPE C,          "Color
                COMPLEX(20)       TYPE C,         "Complex
                WIDTH(10)         TYPE C,          "Width
                KBETR             LIKE KONV-KBETR, " Rate per KG
                WAERS             LIKE KONV-WAERS, "currency
                STCUR             LIKE VBKD-STCUR, " Exchang Rate
                MEINS             LIKE VBAP-MEINS,  "Base Unit of Measure
                KWMENG            LIKE VBAP-KWMENG, " Order Quantity
                RFMNG             LIKE VBFA-RFMNG,    "Referenced quantity in base unit of measure
                BAL_QTY           LIKE VBFA-RFMNG, " Balance QTY
                EDATU             LIKE VBEP-EDATU, "Schedule line date
                DAYS(5)          TYPE C, " Sch.Delay
                BSTNK             LIKE VBAK-BSTNK, " cUSTOMER pURCHASE ORDER NUMBER
                BSTDK             LIKE VBAK-BSTDK,  "Customer purchase order date
                VTWEG             LIKE VBAK-VTWEG,  "Distribution Channel
                SPART             LIKE VBAK-SPART,  "Division
                DIST_NAME         LIKE TVTWT-VTEXT, "Distribution Channels NAME
                DIV_NAME          LIKE TSPAT-VTEXT, "Sales Divisions NAME
                ZA_KUNNR          LIKE KNA1-KUNNR,
                ZA_NAME               LIKE KNA1-NAME1,
                ZE_KUNNR          LIKE KNA1-KUNNR,
                ZE_NAME               LIKE KNA1-NAME1,
                ZI_KUNNR          LIKE KNA1-KUNNR,
                ZI_NAME               LIKE KNA1-NAME1,
                ZR_KUNNR          LIKE KNA1-KUNNR,
                ZR_NAME               LIKE KNA1-NAME1,
                ZS_KUNNR          LIKE KNA1-KUNNR,
                ZS_NAME               LIKE KNA1-NAME1,
                MVGR1(20)         TYPE C          , " Matrial Group
                B_VALUE           LIKE KONV-KWERT, "bASIC value
                EX_VALUE          LIKE KONV-KWERT, "eXCISE value
                EC_VALUE          LIKE KONV-KWERT, "ecess value
                HE_VALUE          LIKE  KONV-KWERT, "hcess value
                VAT_VALUE         LIKE KONV-KWERT, "VAT value
                CST_VALUE         LIKE KONV-KWERT, "CST
                F_VALUE           LIKE KONV-KWERT, "fREIGJT
                C_VALUE           LIKE KONV-KWERT, "cOMISSION
                KDGRP(70)         TYPE C, " Custoemr Group
                NETWR             LIKE VBAP-NETWR, " Net Value
                INR               LIKE VBAP-NETWR, " inr Net Value
                AUART             LIKE VBAK-AUART,  "Sales Document Type
                BEZEI             LIKE TVAKT-BEZEI, "SALES DOC TYPE DESC
                ZOA_RECP_PLAN_DT  LIKE VBAK-ZOA_RECP_PLAN_DT, "Order receipt at plant
                ZZCUST_REQDAT     LIKE VBAP-ZZCUST_REQDAT, " REquested Date
                ROUTE             LIKE VBAP-ROUTE, " Route
                ROUTE_NAME        LIKE  TVROT-BEZEI , "Route name
                ZZBRAND           LIKE VBAP-ZZBRAND, " bRAND
                ZZSPLDIA          LIKE VBAP-ZZSPLDIA, "Spool Diameter
                ZTERM             LIKE VBKD-ZTERM, " Payment Term
                Z_TERM_TEXT(50)   TYPE C, "Payment Terms Text
                Z001(50)          TYPE C, "text
                Z002(50)          TYPE C, "text
                Z003(50)          TYPE C, "text
                Z004(50)          TYPE C, "text
                ZI_001(50)        TYPE C, "text
                ZI_002(50)        TYPE C, "text
                ZZCOATING(20)     TYPE C,
                ZZWEIGHT          LIKE VBAP-ZZWEIGHT,
                ZZWEIGHT_UMO      LIKE VBAP-ZZWEIGHT_UMO,
                WBSTK             LIKE VBUK-WBSTK,
                T_NETWR           LIKE VBAP-NETWR, " Net Value
                FAKSP             LIKE VBAP-FAKSP,
           END OF GT_FINAL_DATA.
    *****Mail Data Decleration.
    DATA : BEGIN OF MAIL_TAB OCCURS 0 ,
                ZE_NAME               LIKE KNA1-NAME1,
                ZS_NAME               LIKE KNA1-NAME1,
                NAME              LIKE KNA1-NAME1,
                ORT01             LIKE KNA1-ORT01, "cITY
                S_NAME            LIKE KNA1-NAME1,
                S_ORT01           LIKE KNA1-ORT01, "cITY
                KLABC             LIKE KNVV-KLABC, " Custoemr Class
                VBELN             LIKE VBAK-VBELN, "sALES oRDER nUMBER
                POSNR             LIKE VBAP-POSNR, "SALES ORDER LINE NUMBER
                ERDAT             LIKE VBAK-ERDAT , " Order Date
                MATNR             LIKE MAKT-MATNR,  "Matrial
                MAKTX             LIKE MAKT-MAKTX, "Matrial DESC
                ZZKDMAT           LIKE VBAP-ZZKDMAT, "Customter Mat. Number
                COLOR(20)         TYPE C,          "Color
                COMPLEX(20)       TYPE C,         "Complex
                WIDTH(10)         TYPE C,          "Width
                KBETR             LIKE KONV-KBETR, " Rate per KG
                WAERS             LIKE KONV-WAERS, "currency
                MEINS             LIKE VBAP-MEINS,  "Base Unit of Measure
                KWMENG            LIKE VBAP-KWMENG, " Order Quantity
                BAL_QTY           LIKE VBFA-RFMNG, " Balance QTY
                EDATU             LIKE VBEP-EDATU, "Schedule line date
                DAYS(5)          TYPE C, " Sch.Delay
                BSTNK             LIKE VBAK-BSTNK, " cUSTOMER pURCHASE ORDER NUMBER
                BSTDK             LIKE VBAK-BSTDK,  "Customer purchase order date
                ZA_NAME               LIKE KNA1-NAME1,
                ZI_NAME               LIKE KNA1-NAME1,
                ZR_NAME               LIKE KNA1-NAME1,
                MVGR1(20)         TYPE C          , " Matrial Group
                ZZCUST_REQDAT     LIKE VBAP-ZZCUST_REQDAT, " REquested Date
                ZZBRAND           LIKE VBAP-ZZBRAND, " bRAND
           END OF MAIL_TAB.
    DATA : IT_MAIL_ID TYPE YMSLT_MAIL_ID OCCURS 0 WITH HEADER LINE.
    DATA : SM_MAIL_ID TYPE YMSLT_MAIL_ID OCCURS 0 WITH HEADER LINE.
    DATA : SP_MAIL_ID TYPE YMSLT_MAIL_ID OCCURS 0 WITH HEADER LINE.
    DATA:   IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
            T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
            T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
            T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
            T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
            W_CNT TYPE I,
            W_SENT_ALL(1) TYPE C,
            W_DOC_DATA LIKE SODOCCHGI1,
            GD_ERROR    TYPE SY-SUBRC,
            GD_RECIEVER TYPE SY-SUBRC.
    DATA STR_VAL TYPE STRING.
    CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
    CONSTANTS:
        CON_TAB  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
        CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
    DATA: GT_VBAK_KNA1 LIKE GT_VBAK OCCURS 0 WITH HEADER LINE,
          GT_VBAP_VBPA LIKE GT_VBAP OCCURS 0 WITH HEADER LINE,
          GT_VBAP_MAKT LIKE GT_VBAP OCCURS 0 WITH HEADER LINE,
          GT_MVKE_TVM1T LIKE GT_MVKE OCCURS 0 WITH HEADER LINE,
          GT_VBAP_MSKA LIKE GT_VBAP OCCURS 0 WITH HEADER LINE,
          GT_VBPA_KNA1 LIKE GT_VBPA OCCURS 0 WITH HEADER LINE,
          GT_VBFA_VBUK LIKE GT_VBFA OCCURS 0 WITH HEADER LINE,
          GT_VBAP_INOB LIKE GT_VBAP OCCURS 0 WITH HEADER LINE.
    DATA : BEGIN OF GT_INOB  OCCURS 0.
              INCLUDE STRUCTURE INOB.
    DATA : END OF GT_INOB.
    DATA: BEGIN OF GT_YCAT_PARAMS OCCURS 0,
           KEY01 TYPE YYKEY01_C10,
           KEY02 TYPE YYKEY02_C16,
           KEY03 TYPE YYKEY03_C20,
           SRNO TYPE YYSRNO_N4,
           VALUE TYPE YYVALUE_C25,
          END OF GT_YCAT_PARAMS.
    DATA: BEGIN OF GT_CABN OCCURS 0,
           ATINN LIKE CABN-ATINN,
           ATNAM LIKE CABN-ATNAM,
          END OF GT_CABN.
    DATA: BEGIN OF GT_AUSP OCCURS 0,
           OBJEK LIKE AUSP-OBJEK,
           ATINN LIKE AUSP-ATINN,
           ATWRT LIKE AUSP-ATWRT,
          END OF GT_AUSP.
    DATA: BEGIN OF GT_CUOBJ OCCURS 0,
          CUOBJ(18) TYPE C,
            CUOBJ TYPE OBJNUM,
          END OF GT_CUOBJ.
    DATA: BEGIN OF GT_CAWN OCCURS 0,
            ATINN LIKE CAWN-ATINN,
            ATZHL LIKE CAWN-ATZHL,
            ATWRT LIKE CAWN-ATWRT,
         END OF GT_CAWN.
    DATA: BEGIN OF GT_CAWNT OCCURS 0,
            ATINN LIKE CAWNT-ATINN,
            ATZHL LIKE CAWNT-ATZHL,
            SPRAS LIKE CAWNT-SPRAS,
            ATWTB LIKE CAWNT-ATWTB,
         END OF GT_CAWNT.
                          START-OF-SELECTION                             *
    INITIALIZATION.
      VARIANT = 'Display Options'.
    RB1 = 'X'.
    REPNAME = SY-REPID.
      PERFORM BUILD_EVENTTAB USING EVENTS[].
      PERFORM BUILD_LAYOUT .
      PERFORM INITIALIZE_VARIANT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
      PERFORM F4_FOR_VARIANT.
    AT SELECTION-SCREEN.
      PERFORM PAI_OF_SELECTION_SCREEN.
    END-OF-SELECTION.
      PERFORM SELECT_DATA.
      PERFORM PROCESS_DATA.
      PERFORM FILTER_PATNER_DATA.
      IF P_FILE = 'X'.
        PERFORM OUT_PUT_FILE.
      ELSEIF P_SCREEN = 'X'.
        PERFORM FILED_CAT_LOG.
        PERFORM CREATE_ALV_LAYOUT.
    PERFORM fill_events.
        PERFORM OUT_PUT_DATA.
      ELSEIF P_MAIL = 'X'.
        PERFORM MAIL_RPT.
      ENDIF.
    *=================Start of Internal table Declaration===================
    *===========
    *&      Form  SELECT_DATA
          sELECTING DATA FROM dATA bASE
    FORM SELECT_DATA .
      REFRESH R_PARVW.
      R_PARVW-SIGN = 'I'.
      R_PARVW-OPTION = 'EQ'.
      IF  NOT  S_ZE[] IS INITIAL.
        R_PARVW-LOW = S_ZE-LOW.
        APPEND R_PARVW.
      ENDIF.
      IF  NOT  S_ZS[] IS INITIAL.
        R_PARVW-LOW = S_ZS-LOW.
        APPEND R_PARVW.
      ENDIF.
      IF  NOT  S_ZA[] IS INITIAL.
        R_PARVW-LOW = S_ZA-LOW.
        APPEND R_PARVW.
      ENDIF.
      IF  NOT  S_ZR[] IS INITIAL.
        R_PARVW-LOW = S_ZR-LOW.
        APPEND R_PARVW.
      ENDIF.
      IF  NOT  S_ZI[] IS INITIAL.
        R_PARVW-LOW = S_ZI-LOW.
        APPEND R_PARVW.
      ENDIF.
    R_PARVW-LOW = 'SH'.
    APPEND R_PARVW.
    sELECTING DATA FROM VBAK TABLE INTO INTERNAL TABLE GT_VBAK
      SELECT  VBELN ERDAT AUART
              VTWEG SPART KNUMV
              BSTNK BSTDK KUNNR
               ZOA_RECP_PLAN_DT
        INTO TABLE GT_VBAK
        FROM VBAK
              WHERE VBELN IN S_VBELN
              AND ERDAT IN S_ERDAT
              AND VBTYP = 'C'
              AND AUART IN S_AUART
              AND AUGRU IN S_AUGRU
              AND VKORG IN S_VKORG
              AND VTWEG IN S_VTWEG
              AND VKGRP IN S_VKGRP
              AND VKBUR IN S_VKBUR
              AND BSTNK  IN S_BSTNK
              AND KUNNR IN S_KUNNR.
      SORT GT_VBAK[] BY VBELN.
      IF NOT GT_VBAK[] IS INITIAL.
    Selecting data from VBAP into Internal tabl gt_vbap
        IF P_BLOCK = 'X' .
          SELECT  VBELN   POSNR
                  MATNR  ABGRU
                  MEINS   FAKSP
                  NETWR KWMENG
                  WERKS   LGORT
                  ROUTE ZZWIDTH
                  ZZKDMAT ZZBRAND
                  ZZSPLDIA ZZCUST_REQDAT
                  ZZCOATING ZZWEIGHT
                  ZZWEIGHT_UMO
            INTO TABLE GT_VBAP
            FROM VBAP
            FOR ALL ENTRIES IN GT_VBAK
            WHERE VBELN = GT_VBAK-VBELN
            AND MATNR IN S_MATNR
            AND ABGRU <> ''
            AND WERKS IN S_WERKS
        ELSEIF P_PEN = 'X'.
          SELECT  VBELN   POSNR
                  MATNR  ABGRU
                  MEINS   FAKSP
                  NETWR KWMENG
                  WERKS   LGORT
                  ROUTE ZZWIDTH
                  ZZKDMAT ZZBRAND
                  ZZSPLDIA ZZCUST_REQDAT
                  ZZCOATING ZZWEIGHT
                  ZZWEIGHT_UMO
            INTO TABLE GT_VBAP
            FROM VBAP
            FOR ALL ENTRIES IN GT_VBAK
            WHERE VBELN = GT_VBAK-VBELN
            AND MATNR IN S_MATNR
            AND FAKSP <> '10'
            AND WERKS IN S_WERKS.
        ELSE.
             SELECT  VBELN   POSNR
                  MATNR  ABGRU
                  MEINS   FAKSP
                  NETWR KWMENG
                  WERKS   LGORT
                  ROUTE ZZWIDTH
                  ZZKDMAT ZZBRAND
                  ZZSPLDIA ZZCUST_REQDAT
                  ZZCOATING ZZWEIGHT
                  ZZWEIGHT_UMO
            INTO TABLE GT_VBAP
            FROM VBAP
            FOR ALL ENTRIES IN GT_VBAK
            WHERE VBELN = GT_VBAK-VBELN
            AND MATNR IN S_MATNR
            AND WERKS IN S_WERKS.
        ENDIF.
      ENDIF.
    IF P_PEN = 'X'.
       SELECT VBELN POSNR GBSTA FROM VBUP INTO TABLE GT_VBUP
              FOR ALL ENTRIES IN GT_VBAP
              WHERE VBELN = GT_VBAP-VBELN AND  POSNR = GT_VBAP-POSNR AND
              GBSTA <> 'C'.
       SORT GT_VBUP[] BY VBELN.
       LOOP AT GT_VBAP.
         READ TABLE GT_VBUP WITH KEY VBELN = GT_VBAP-VBELN
                                     POSNR = GT_VBAP-POSNR.
         IF SY-SUBRC <> 0.
           DELETE GT_VBAP.
         ENDIF.
         CLEAR GT_VBUP.
       ENDLOOP.
        LOOP AT GT_VBAK.
          READ TABLE GT_VBAP WITH KEY VBELN = GT_VBAK-VBELN.
          IF SY-SUBRC <> 0.
            DELETE GT_VBAK.
          ENDIF.
          CLEAR GT_VBAP.
        ENDLOOP.
    ENDIF.
      IF NOT GT_VBAP[] IS INITIAL.
        GT_VBAP_INOB[] = GT_VBAP[].
    SORT GT_VBAP_INOB[] BY MATNR.
    DELETE ADJACENT DUPLICATES FROM GT_VBAP_INOB COMPARING MATNR.
    SELECT * FROM INOB INTO TABLE GT_INOB
         WHERE KLART = '023'
             AND  OBTAB = 'MARA'.
    IF SY-SUBRC = 0.
       SELECT  KEY01 KEY02 KEY03 SRNO VALUE
                     INTO TABLE Gt_YCAT_PARAMS
                     FROM  YCAT_PARAMS
                                 WHERE KEY01 = 'CHAR_NAME'
                                 AND   KEY02 = 'ATNAM'
                                 AND  ( KEY03 = 'COLOR' OR  KEY03 = 'COMPLEX' )
                                 AND   SRNO  = '0001'.
    SELECT ATINN ATNAM INTO TABLE GT_CABN FROM CABN
                              WHERE ( ATNAM = 'COLOUR' OR ATNAM = 'COMPLEX' ).
    LOOP AT GT_INOB.
    GT_CUOBJ-CUOBJ = GT_INOB-CUOBJ.
    APPEND GT_CUOBJ.
    ENDLOOP.
    SELECT OBJEK ATINN ATWRT
          INTO TABLE GT_AUSP FROM AUSP
             FOR ALL ENTRIES IN GT_CUOBJ
              WHERE OBJEK = GT_CUOBJ-CUOBJ.
             AND   ATINN = L_ATINN.
    SELECT ATINN ATZHL ATWRT INTO TABLE GT_CAWN
            FROM CAWN FOR ALL ENTRIES IN GT_AUSP
              WHERE ATWRT = GT_AUSP-ATWRT.
    SELECT ATINN ATZHL SPRAS ATWTB INTO TABLE GT_CAWNT
           FROM CAWNT FOR ALL ENTRIES IN GT_CAWN
              WHERE ATINN = GT_CAWN-ATINN
              AND   ATZHL = GT_CAWN-ATZHL
              AND SPRAS = 'EN'.
    ENDIF.
    Selecting data from VBeP into Internal tabl gt_vbep
        SORT GT_VBAP[] BY VBELN POSNR.
        SELECT  VBELN POSNR
                ETENR EDATU
          INTO TABLE GT_VBEP
          FROM VBEP
          FOR ALL ENTRIES IN GT_VBAP
          WHERE VBELN = GT_VBAP-VBELN
          AND POSNR = GT_VBAP-POSNR
          AND EDATU IN S_EDATU
               AND BMENG <> 0.
        SELECT SPRAS ROUTE BEZEI
              INTO TABLE GT_TVROT
              FROM TVROT
             WHERE SPRAS = 'EN'.
      ENDIF.
      IF NOT GT_VBAP[] IS INITIAL.
        GT_VBAP_VBPA[] = GT_VBAP[].
        SORT GT_VBAP_VBPA[] BY VBELN.
        DELETE ADJACENT DUPLICATES FROM GT_VBAP_VBPA COMPARING VBELN.
    Selecting data from  VBPA into Internal tabl GT_VBPA
        IF NOT R_PARVW[] IS INITIAL.
          SELECT VBELN POSNR
                 PARVW KUNNR
            INTO TABLE GT_VBPA
            FROM VBPA
            FOR ALL ENTRIES IN  GT_VBAP_VBPA
            WHERE VBELN = GT_VBAP_VBPA-VBELN
            AND (  PARVW  IN R_PARVW
            OR PARVW = 'WE' ).
        ELSE.
          SELECT VBELN POSNR
                 PARVW KUNNR
            INTO TABLE GT_VBPA
            FROM VBPA
            FOR ALL ENTRIES IN  GT_VBAP_VBPA
            WHERE VBELN = GT_VBAP_VBPA-VBELN
            AND  ( PARVW  = 'ZE'
            OR  PARVW = 'ZS'
            OR PARVW = 'ZA'
            OR  PARVW = 'ZR'
            OR  PARVW = 'ZI' OR PARVW = 'WE' ).
        ENDIF.
      ENDIF.
      SORT GT_VBPA[].
      GT_VBPA_KNA1[] = GT_VBPA[].
      SORT GT_VBPA_KNA1[] BY KUNNR.
      DELETE ADJACENT DUPLICATES FROM GT_VBPA_KNA1 COMPARING KUNNR.
      IF NOT GT_VBPA_KNA1[] IS INITIAL.
        SELECT KUNNR NAME1 ORT01 FROM KNA1 INTO TABLE
               GT_KNA1_1 FOR ALL ENTRIES IN GT_VBPA_KNA1
                WHERE KUNNR = GT_VBPA_KNA1-KUNNR.
      ENDIF.
    Selecting data from  VBKD into Internal tabl GT_VBKD
      IF NOT GT_VBAK[] IS INITIAL.
        SELECT VBELN  KDGRP
               INCO1 INCO2
               ZTERM  STCUR
          INTO TABLE GT_VBKD
          FROM VBKD
          FOR ALL ENTRIES IN GT_VBAK
          WHERE VBELN = GT_VBAK-VBELN
          AND PRSDT <> ''.
    Selecting data from VBFA into Internal table gt_vbfa
        IF P_PEN = 'X'.
            SELECT VBFAVBELV   VBFAPOSNV
                    VBFAVBELN   VBFAPOSNN
                    VBFAVBTYP_N VBFARFMNG
               INTO TABLE GT_VBFA
               FROM VBFA INNER JOIN
               VBAK ON VBFAVBELV = VBAKVBELN
               WHERE
               ( VBFA~VBTYP_N = 'J' OR
                     VBFA~VBTYP_N = 'R').
    LOOP AT GT_VBFA.
         READ TABLE GT_VBAK WITH KEY VBELN = Gt_VBFA-VBELV.
           IF SY-SUBRC <> 0.
             DELETE GT_VBFA.
           ENDIF.
    CLEAR GT_VBFA.
    ENDLOOP.
         SELECT VBELV   POSNV
                   VBELN   POSNN
                   VBTYP_N RFMNG
              INTO TABLE GT_VBFA
              FROM VBFA
              FOR ALL ENTRIES IN GT_VBAK
              WHERE VBELV = GT_VBAK-VBELN
              AND ( VBTYP_N = 'J' OR
                    VBTYP_N = 'R').
        ELSE.
          SELECT VBELV   POSNV
                 VBELN   POSNN
                 VBTYP_N RFMNG
            INTO TABLE GT_VBFA
            FROM VBFA
            FOR ALL ENTRIES IN GT_VBAK
            WHERE VBELV = GT_VBAK-VBELN
            AND VBTYP_N = 'J'.
        ENDIF.
        SORT GT_VBFA[].
        IF GT_VBFA[] IS NOT INITIAL.
          GT_VBFA_VBUK[] = GT_VBFA[].
          SORT GT_VBFA_VBUK[] BY VBELN.
          DELETE ADJACENT DUPLICATES FROM GT_VBFA_VBUK COMPARING VBELN.
          SELECT VBELN WBSTK FROM VBUK INTO TABLE GT_VBUK
               FOR ALL ENTRIES IN GT_VBFA_VBUK
                  WHERE VBELN = GT_VBFA_VBUK-VBELN.
        ENDIF.
             -----------Selection data from KONv into Internal table gt_konv
        SORT GT_VBAK[] BY KNUMV.
        SELECT KNUMV KPOSN KSCHL
               KBETR WAERS KWERT
             INTO TABLE GT_KONV
             FROM KONV
             FOR ALL ENTRIES IN GT_VBAK
             WHERE KNUMV = GT_VBAK-KNUMV
             AND ( KSCHL = 'ZBAP'
                  OR   KSCHL = 'JEXP'
                  OR   KSCHL = 'JEDC'
                  OR   KSCHL = 'JEDH'
                  OR   KSCHL = 'ZJIP'
                  OR   KSCHL = 'ZCOM'
                  OR   KSCHL = 'JIVC'
                  OR   KSCHL   = 'JFRE' ).
      ENDIF.
      IF NOT GT_VBAP[] IS INITIAL.
    sELECING dATA FROM MSKA INTO INTERNAL TABLE GT_MSKA
        GT_VBAP_MSKA[] = GT_VBAP[].
        SORT GT_VBAP_MSKA[] BY MATNR WERKS VBELN POSNR.
        DELETE ADJACENT DUPLICATES FROM GT_VBAP_MSKA COMPARING MATNR WERKS VBELN POSNR.
        SELECT  MATNR  WERKS
                LGORT  CHARG
                SOBKZ  VBELN
                POSNR
                KALAB  KAINS
          INTO TABLE GT_MSKA
          FROM MSKA
          FOR ALL ENTRIES IN GT_VBAP_MSKA
          WHERE MATNR = GT_VBAP_MSKA-MATNR
          AND WERKS = GT_VBAP_MSKA-WERKS
       AND LGORT = GT_VBAP-LGORT
          AND VBELN = GT_VBAP_MSKA-VBELN
          AND POSNR = GT_VBAP_MSKA-POSNR.
        SORT GT_MSKA[].
        DATA :BEGIN OF TMP_MATNR OCCURS 0,
               MATNR LIKE MARA-MATNR,
              END OF TMP_MATNR.
        LOOP AT GT_VBAP.
          TMP_MATNR-MATNR = GT_VBAP-MATNR.
          TMP_MATNR-MATNR+0(1) ='S'.
          APPEND TMP_MATNR.
        ENDLOOP.
        SORT TMP_MATNR[].
        DELETE ADJACENT DUPLICATES FROM TMP_MATNR COMPARING MATNR.
        SELECT MATNR
               WERKS
               LGORT
               LABST
          FROM MARD
          INTO TABLE GT_MARD
          FOR ALL ENTRIES IN TMP_MATNR
          WHERE MATNR = TMP_MATNR-MATNR."'SDX25000B040GC01'."GT_VBAP-MATNR.
      ENDIF.
      SORT GT_MARD[].
      IF NOT GT_VBAK[] IS INITIAL.
        GT_VBAK_KNA1[] = GT_VBAK[].
        SORT GT_VBAK_KNA1[] BY KUNNR.
        DELETE ADJACENT DUPLICATES FROM GT_VBAK_KNA1 COMPARING KUNNR.
        SELECT  KUNNR
                     NAME1
                     NAME2
                     ORT01
             FROM KNA1
             INTO TABLE GT_KNA1
             FOR ALL ENTRIES IN GT_VBAK_KNA1
             WHERE KUNNR = GT_VBAK_KNA1-KUNNR.
        SELECT KUNNR  KLABC
          FROM KNVV
         INTO TABLE GT_KNVV
         FOR ALL ENTRIES IN GT_VBAK_KNA1
         WHERE KUNNR = GT_VBAK_KNA1-KUNNR.
      ENDIF.
      IF NOT GT_VBAP[] IS INITIAL.
        GT_VBAP_MAKT[] = GT_VBAP[].
        SORT GT_VBAP_MAKT[] BY MATNR.
        DELETE ADJACENT DUPLICATES FROM GT_VBAP_MAKT COMPARING MATNR.
        SELECT   MATNR
                 SPRAS
                 MAKTX
             FROM MAKT
             INTO TABLE GT_MAKT
             FOR ALL ENTRIES IN GT_VBAP_MAKT
             WHERE MATNR = GT_VBAP_MAKT-MATNR AND
                   SPRAS = 'EN'.
        SELECT MATNR
               MVGR1
          FROM MVKE
          INTO TABLE GT_MVKE
          FOR ALL ENTRIES IN GT_VBAP_MAKT
          WHERE MATNR = GT_VBAP_MAKT-MATNR
          AND MVGR1 <> ''.
      ENDIF.
      IF NOT GT_MVKE[] IS INITIAL.
        GT_MVKE_TVM1T[] = GT_MVKE[].
        SORT GT_MVKE_TVM1T[] BY MVGR1.
        DELETE ADJACENT DUPLICATES FROM GT_MVKE_TVM1T COMPARING MVGR1.
        SELECT SPRAS MVGR1 BEZEI
            FROM TVM1T
            INTO TABLE GT_TVM1T
            FOR ALL ENTRIES IN GT_MVKE_TVM1T
            WHERE SPRAS = 'EN' AND
              MVGR1 = GT_MVKE_TVM1T-MVGR1.
      ENDIF.
      IF NOT GT_VBAK[] IS INITIAL.
        SELECT SPRAS
               SPART
               VTEXT
          FROM TSPAT
          INTO TABLE GT_TSPAT
          WHERE SPRAS = 'EN'.
        SELECT  SPRAS
                VTWEG
                VTEXT
              FROM TVTWT
              INTO TABLE GT_TVTWT
              WHERE SPRAS = 'EN'.
        SELECT SPRAS AUART BEZEI
              FROM TVAKT
              INTO TABLE GT_TVAKT
              WHERE
               SPRAS = 'EN'.
      ENDIF.
      IF NOT GT_VBKD[] IS INITIAL.
        SELECT SPRAS KDGRP
               KTEXT
               FROM T151T
          INTO TABLE GT_T151T
        FOR ALL ENTRIES IN GT_VBKD
         WHERE SPRAS = 'EN' .
         AND
             KDGRP = GT_VBKD-KDGRP.
      ENDIF.
      IF NOT GT_VBKD[] IS INITIAL.
        SELECT SPRAS ZTERM TEXT1
          FROM T052U
          INTO TABLE GT_T052U
        FOR ALL ENTRIES IN GT_VBKD
          WHERE SPRAS = 'EN'.
          AND ZTERM = GT_VBKD-ZTERM.
      ENDIF.
    ENDFORM.                    " SELECT_DATA
    *&      Form  PROCESS_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM PROCESS_DATA .
      DATA : T_FLAG(2) TYPE C,
             J_AMT LIKE VBFA-RFMNG,
             M_AMT LIKE VBFA-RFMNG,
             R_AMT LIKE VBFA-RFMNG,
             N_AMT LIKE VBFA-RFMNG,
             JR_AMT LIKE VBFA-RFMNG,
             MN_AMT LIKE VBFA-RFMNG,
             TMP_WBSTK LIKE VBUK-WBSTK,
             SFG_MATNR LIKE MARD-MATNR.
      LOOP AT GT_VBAP.
        CLEAR : GT_FINAL_DATA,
              J_AMT ,
             M_AMT ,
             R_AMT,
             N_AMT ,
             JR_AMT ,
             SFG_MATNR,
             MN_AMT .
        READ TABLE GT_VBAK WITH KEY VBELN = GT_VBAP-VBELN.
        IF SY-SUBRC = 0.
          GT_FINAL_DATA-KUNNR    = GT_VBAK-KUNNR.
          GT_FINAL_DATA-VBELN  = GT_VBAK-VBELN.
          GT_FINAL_DATA-POSNR = GT_VBAP-POSNR.
          GT_FINAL_DATA-ABGRU = GT_VBAP-ABGRU.
        ENDIF.
        READ TABLE GT_KNA1 WITH KEY KUNNR = GT_VBAK-KUNNR.
        IF SY-SUBRC = 0.
          GT_FINAL_DATA-NAME = GT_KNA1-NAME1.
          GT_FINAL_DATA-ORT01 = GT_KNA1-ORT01.
        ENDIF.
        READ TABLE GT_KNVV WITH KEY KUNNR = GT_VBAK-KUNNR.
        IF SY-SUBRC = 0.
          GT_FINAL_DATA-KLABC = GT_KNVV-KLABC.
        ENDIF.
        IF SY-SUBRC = 0.
          READ TABLE GT_VBKD WITH KEY VBELN = GT_VBAK-VBELN.
          GT_FINAL_DATA-INCO1 = GT_VBKD-INCO1. "Incoterms (Part 1)
          GT_FINAL_DATA-INCO2 = GT_VBKD-INCO2. "Incoterms (Part 2)
          GT_FINAL_DATA-ZTERM = GT_VBKD-ZTERM. " Payment Term
        ENDIF.
        LOOP AT  GT_MSKA WHERE  MATNR = GT_VBAP-MATNR
                         AND    WERKS = GT_VBAP-WERKS
                         AND    LGORT = GT_VBAP-LGORT
                         AND    VBELN = GT_VBAP-VBELN
                         AND    POSNR = GT_VBAP-POSNR.
          GT_FINAL_DATA-KALAB = GT_FINAL_DATA-KALAB  + GT_MSKA-KALAB. "Unrestricted-Use Stock
          GT_FINAL_DATA-KAINS = GT_FINAL_DATA-KAINS + GT_MSKA-KAINS. " Stock in Quality Inspection
        ENDLOOP.
        SFG_MATNR = GT_VBAP-MATNR.
        SFG_MATNR+0(1) ='S'.
        READ TABLE  GT_MARD WITH KEY  MATNR = SFG_MATNR
                               WERKS = GT_VBAP-WERKS
                           LGORT = 'SF01'.
       loop at gt_mard where MATNR = SFG_MATNR
                       and  WERKS = GT_VBAP-WERKS.
        IF SY-SUBRC = 0.
          GT_FINAL_DATA-LABST =   GT_FINAL_DATA-LABST + GT_MARD-LABST . "Valuated Unrestricted-Use Stock
        ENDIF.
       endloop.
        GT_FINAL_DATA-MATNR = GT_VBAP-MATNR.  "Matrial
        GT_FINAL_DATA-ZZKDMAT = GT_VBAP-ZZKDMAT. " Customer Mat. N

    Hi Rajan,
    There is a lot of scope for performance tuning the code:
    1. Read statement should be with BINARY SEARCH
    2. Select statement should have FIELDS in the same order as they exist in the table
    3. Select statement where clause should have fields in same order as they exist in the table.
    4. Internal tables seem to be having a huge number of fields. If possible, please limit the fields to only required fields in the internal table.
    Best regards,
    Prashant

  • Consistent gets are reduced by 50% but the query taking more elapsed time.

    Hi All,
    While tuning a application my consistent gets are reduced by 50% but the query is still taking the same time.
    In a Warehouse env data is coming from With clause that is having some 40000 rows .Then these 40K rows are joined to a table that is having 2 Billion records having indexes on primary key and date column(bitmap)indexes .
    It is using Hash Joining method.

    Try forcing a hash join, if possible:
    http://dba-oracle.com/tips_oracle_hash_joins.htm
    Can you post the plans?
    http://www.dba-oracle.com/plsql/t_plsql_plans.htm

  • Server Process taking all CPU time intermittently on Solaris

    Hi,
    What does my program do :-
    We have been facing this problem from many days, We have a server
    process which is continuously listening at a port on Solaris 5.8.
    Whenever a request is sent to this server a new thread & a socket is created for that client.
    This process is running as a proxy server, which connects to some other machine on client request.
    Problem:
    The process start taking whole CPU after few days, happens in a weeks
    period. The process remain in this state for few hours & after that it
    stops responding to any requests.
    & the only thing which can be done, to make it work is to restart the
    process.
    If someone has faced a similar problem then please let me know if you
    have found a solution for that.
    I will give 10 duke dollars to you if you can provide a solution for this problem.
    Regards,
    Sachin

    Here is another class which is used in my code:
    package com.ge.med.service.olea.telnetapplet.proxy;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    * This class is a generic framework for a flexible, multi-threaded server.
    * It listens on any number of specified ports, and, when it receives a
    * connection on a port, passes input and output streams to a specified Service
    * object which provides the actual service. It can limit the number of
    * concurrent connections, and logs activity to a specified stream.
    public class Server {
    // This is the state for the server
    ConnectionManager connectionManager; // The ConnectionManager object
    Hashtable services; // The current services and their ports
    ThreadGroup threadGroup; // The threadgroup for all our threads
    PrintWriter logStream; // Where we send our logging output to
    * This is the Server() constructor. It must be passed a stream
    * to send log output to (may be null), and the limit on the number of
    * concurrent connections. It creates and starts a ConnectionManager
    * thread which enforces this limit on connections.
    public Server(OutputStream logStream, int maxConnections) {
    setLogStream(logStream);
    log("Starting server");
    threadGroup = new ThreadGroup("Server");
    connectionManager = new ConnectionManager(threadGroup, maxConnections);
    connectionManager.start();
    services = new Hashtable();
    * A public method to set the current logging stream. Pass null
    * to turn logging off
    public void setLogStream(OutputStream out) {
    if (out != null) logStream = new PrintWriter(new OutputStreamWriter(out));
    else logStream = null;
    /** Write the specified string to the log */
    protected synchronized void log(String s) {
    if (logStream != null) {
    logStream.println("[" + new Date() + "] " + s);
    logStream.flush();
    /** Write the specified object to the log */
    protected void log(Object o) { log(o.toString()); }
    * This method makes the server start providing a new service.
    * It runs the specified Service object on the specified port.
    public void addService(Service service, int port) throws IOException {
    Integer key = new Integer(port); // the hashtable key
    // Check whether a service is already on that port
    if (services.get(key) != null)
    throw new IllegalArgumentException("Port " + port + " already in use.");
    // Create a Listener object to listen for connections on the port
    Listener listener = new Listener(threadGroup, port, service);
    // Store it in the hashtable
    services.put(key, listener);
    // Log it
    log("Starting service " + service.getClass().getName() +
    " on port " + port);
    // Start the listener running.
    listener.start();
    * This method makes the server stop providing a service on a port.
    * It does not terminate any pending connections to that service, merely
    * causes the server to stop accepting new connections
    public void removeService(int port) {
    Integer key = new Integer(port); // hashtable key
    // Look up the Listener object for the port in the hashtable of services
    final Listener listener = (Listener) services.get(key);
    if (listener == null) return;
    // Ask the listener to stop
    listener.pleaseStop();
    // Remove it from the hashtable
    services.remove(key);
    // And log it.
    log("Stopping service " + listener.service.getClass().getName() +
    " on port " + port);
    * This nested class manages client connections for the server.
    * It maintains a list of current connections and enforces the
    * maximum connection limit. It creates a separate thread (one per
    * server) that sits around and wait()s to be notify()'d that a connection
    * has terminated. When this happens, it updates the list of connections.
    public class ConnectionManager extends Thread {
    int maxConnections; // The maximum number of allowed connections
    Vector connections; // The current list of connections
    * Create a ConnectionManager in the specified thread group to enforce
    * the specified maximum connection limit. Make it a daemon thread so
    * the interpreter won't wait around for it to exit.
    public ConnectionManager(ThreadGroup group, int maxConnections) {
    super(group, "ConnectionManager");
    this.setDaemon(true);
    this.maxConnections = maxConnections;
    connections = new Vector(maxConnections);
    log("Starting connection manager. Max connections: " + maxConnections);
    * This is the method that Listener objects call when they accept a
    * connection from a client. It either creates a Connection object
    * for the connection and adds it to the list of current connections,
    * or, if the limit on connections has been reached, it closes the
    * connection.
    synchronized void addConnection(Socket s, Service service) {
    // If the connection limit has been reached
    if (connections.size() >= maxConnections) {
    try {
    PrintWriter out = new PrintWriter(s.getOutputStream());
    // Then tell the client it is being rejected.
    out.println("Connection refused; " +
    "server has reached maximum number of clients.");
    out.flush();
    // And close the connection to the rejected client.
    s.close();
    // And log it, of course
    log("Connection refused to " + s.getInetAddress().getHostAddress() +
    ":" + s.getPort() + ": max connections reached.");
    } catch (IOException e) {log(e);}
    else {  // Otherwise, if the limit has not been reached
    // Create a Connection thread to handle this connection
    Connection c = new Connection(s, service);
    // Add it to the list of current connections
    connections.addElement(c);
    // Log this new connection
    log("Connected to " + s.getInetAddress().getHostAddress() +
    ":" + s.getPort() + " on port " + s.getLocalPort() +
    " for service " + service.getClass().getName());
    // And start the Connection thread running to provide the service
    c.start();
    * A Connection object calls this method just before it exits.
    * This method uses notify() to tell the ConnectionManager thread
    * to wake up and delete the thread that has exited.
    public synchronized void endConnection() { this.notify(); }
    /** Change the current connection limit */
    public synchronized void setMaxConnections(int max) { maxConnections=max; }
    * Output the current list of connections to the specified stream.
    * This method is used by the Control service defined below.
    public synchronized void printConnections(PrintWriter out) {
    for(int i = 0; i < connections.size(); i++) {
    Connection c = (Connection)connections.elementAt(i);
    out.println("CONNECTED TO " +
    c.client.getInetAddress().getHostAddress() + ":" +
    c.client.getPort() + " ON PORT " + c.client.getLocalPort()+
    " FOR SERVICE " + c.service.getClass().getName());
    * The ConnectionManager is a thread, and this is the body of that
    * thread. While the ConnectionManager methods above are called by other
    * threads, this method is run in its own thread. The job of this thread
    * is to keep the list of connections up to date by removing connections
    * that are no longer alive. It uses wait() to block until notify()'d by
    * the endConnection() method.
    public void run() {
    while(true) {  // infinite loop
    // Check through the list of connections, removing dead ones
    for(int i = 0; i < connections.size(); i++) {
    Connection c = (Connection)connections.elementAt(i);
    if (c != null && !c.isAlive()) {
    connections.removeElementAt(i);
                   try      {
                        //close server socket. SPR SVCge16539. Sachin Joshi.
                        Socket server = ProxyServer.Proxy.getServerSocket(c.client);                    
                        if (server != null)
                             server.close();
                        //close client socket.
                        if (c.client != null)
                             c.client.close();                    
                   catch (java.io.IOException e)     {
                        System.err.println("Error closing connection " + e);
                   catch (Exception e)     {
                        System.err.println("Cannot Establish Connection !! " + e);
    log("Connection to " + c.client.getInetAddress().getHostAddress() +
    ":" + c.client.getPort() + " closed.");
              System.out.println("Total Connections now = " + connections.size());
    // Now wait to be notify()'d that a connection has exited
    // When we wake up we'll check the list of connections again.
    try { synchronized(this) { this.wait(); } }
    catch(InterruptedException e) {}
    * This class is a subclass of Thread that handles an individual connection
    * between a client and a Service provided by this server. Because each
    * such connection has a thread of its own, each Service can have multiple
    * connections pending at once. Despite all the other threads in use, this
    * is the key feature that makes this a multi-threaded server implementation.
    public class Connection extends Thread {
    Socket client; // The socket to talk to the client through
    Service service; // The service being provided to that client
    * This constructor just saves some state and calls the superclass
    * constructor to create a thread to handle the connection. Connection
    * objects are created by Listener threads. These threads are part of
    * the server's ThreadGroup, so all Connection threads are part of that
    * group, too.
    public Connection(Socket client, Service service) {
    super("Server.Connection:" + client.getInetAddress().getHostAddress() +
    ":" + client.getPort());
    this.client = client;
    this.service = service;
    * This is the body of each and every Connection thread.
    * All it does is pass the client input and output streams to the
    * serve() method of the specified Service object. That method
    * is responsible for reading from and writing to those streams to
    * provide the actual service. Recall that the Service object has been
    * passed from the Server.addService() method to a Listener object
    * to the ConnectionManager.addConnection() to this Connection object,
    * and is now finally getting used to provide the service.
    * Note that just before this thread exits it calls the
    * ConnectionManager.endConnection() method to wake up the
    * ConnectionManager thread so that it can remove this Connection
    * from its list of active connections.
    public void run() {
    try {
    InputStream in = client.getInputStream();
    OutputStream out = client.getOutputStream();
    // service.serve(in, out);
    ((ProxyServer.Proxy)service).serve(in, out,client);
    catch (IOException e) {log(e);}
    finally { connectionManager.endConnection(); }
    * Here is the Service interface that we have seen so much of.
    * It defines only a single method which is invoked to provide the service.
    * serve() will be passed an input stream and an output stream to the client.
    * It should do whatever it wants with them, and should close them before
    * returning.
    * All connections through the same port to this service share a single
    * Service object. Thus, any state local to an individual connection must
    * be stored in local variables within the serve() method. State that should
    * be global to all connections on the same port should be stored in
    * instance variables of the Service class. If the same Service is running
    * on more than one port, there will typically be different Service instances
    * for each port. Data that should be global to all connections on any port
    * should be stored in static variables.
    * Note that implementations of this interface must have a no-argument
    * constructor if they are to be dynamically instantiated by the main()
    * method of the Server class.
    public interface Service {
    public void serve(InputStream in, OutputStream out) throws IOException;     
         }

  • Oracle on NT(taking 100% CPU)

    I have my Oracle running on NT.It is a Dell machine .The database isna test database.When the instance starts up it is taking 100% CPU.No activity possible on it.All querries hanging.Any suggestions ?

    Please look at patch name EM_NT_1224539.
    null

  • Issue in FM-IDOC_INPUT_DEBITOR_MDM-Taking more processing time

    Hi Friends,
            The Customer master idocs are taking lot of time to process in production. Currently one idoc needs 8 minutes to process.  This is because of the select in the DEBMAS where in the program searches for the ADRMAS idoc for the same customer.I am using FM "IDOC_INPUT_DEBITOR_MDM", Is there any way to reduce the processing Time.
    Thanks in Advance ,
    Regards,
    Veera

    Thanks Gareth for the reply. This is standard FM and after the Call transaction, SAP code reads the  BDCMSGCOLL. If it does not found ans S in that, it fails the IDOC to 51 status.  There is no Z code in this.
    I would like to know what config changes can supress the success message . I tried doing BDC thoguth SM35 and there also found that no message is coming when the Customer is created. This would mean that there is something worng in srrting rather than FM and BDC which is causing the BDC failure in Std FM.
    Regds
    Harish

  • When I start FireFox the process with the image name System and user name System (looking in Task Manager) starts taking tremendous CPU time (up to 50% or more).

    I am using FireFox 4.0.1 for Windows, and routinely check for updates. It did not do this under previous versions (not sure it is was specific to 4.0.1 or with started with 4.0) I have watched the CPU utilization when starting other applications including Thunderbird, and the high utilization by this process so far seems tied to whenever I start up the newer version of FireFox.

    Start your '''Computer''' in safe mode. Then start Firefox. Try '''Safe''' web sites.
    '''[http://encyclopedia2.thefreedictionary.com/Linux+Safe+Mode Starting The Computer In Safe Mode;<br>Free Online Encyclopedia]'''
    Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
    You can try these free programs to scan for malware, which work with your existing antivirus software:
    * [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
    * [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
    * [http://support.kaspersky.com/viruses/disinfection/5350 Anti-Rootkit Utility - TDSSKiller]
    * [http://general-changelog-team.fr/en/downloads/viewdownload/20-outils-de-xplode/2-adwcleaner AdwCleaner] (for more info, see this [http://www.bleepingcomputer.com/download/adwcleaner/ alternate AdwCleaner download page])
    * [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
    * [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
    [http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
    Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
    Did this fix your problems? Please report back to us!

Maybe you are looking for