Select Query info req for ZMKPFMSEG: View of MSEG and MKPF table

Hi
I am fetching 7-8 records frm ZMKPFMSEG: View of MSEG and MKPF table,which based on matnr,werks & budut,which is taking a large time,there is no index in the table,so can nay one tell me how to fetch the data,to make code more effictient.
SELECT  budat
          matnr
          menge
          bwart
          meins
          bwtar
          waers
          dmbtr
          shkzg
          matkl
          FROM  zmkpfmseg
          INTO  CORRESPONDING FIELDS OF TABLE it_mseg
          WHERE budat GE r_ytd-low
            AND matnr IN so_matnr
            AND werks = p_werks
            AND lgort IN so_lgort
            AND matkl IN so_matkl.
plz tell me what changes have to be done in where condtion to make it run fast.
regds

Hi,
Try the alternate Methods,
ACCESS VIA SUBQUERY.
SELECT * FROM MKPF AS M INTO CORRESPONDING FIELDS OF SWAP
                                    WHERE  BUDAT IN BUDAT AND
                                           MBLNR IN MBLNR AND
                                           VGART = 'WA' AND
                                           EXISTS ( SELECT * FROM MSEG
                                                    WHERE MBLNR = M~MBLNR
                                                    AND   MJAHR = M~MJAHR
                                                   AND   WERKS = P_WERKS
AND matnr IN so_matnr
AND lgort IN so_lgort
AND matkl IN so_matkl.
    APPEND SWAP.CLEAR SWAP.
  ENDSELECT.
  LOOP AT SWAP.
    SELECT  * FROM MSEG
                             WHERE MBLNR = SWAP-MBLNR AND
                                    MJAHR = SWAP-MJAHR AND
      IF SY-SUBRC EQ 0.
        MOVE-CORRESPONDING SWAP TO ITAB.
        MOVE-CORRESPONDING MSEG TO ITAB.
        APPEND ITAB.CLEAR ITAB.
        CLEAR MSEG.
      ENDIF.
    ENDSELECT.
    CLEAR : SWAP,ITAB.
  ENDLOOP.
Try this,
SELECT budat
matnr
menge
bwart
meins
bwtar
waers
dmbtr
shkzg
matkl
FROM zmkpfmseg
INTO CORRESPONDING FIELDS OF TABLE it_mseg
WHERE budat GE r_ytd-low
AND matnr IN so_matnr
AND lgort IN so_lgort
AND matkl IN so_matkl.
delete it_mseg where WERKS NE p_WERKS .
Reward Points if helpful.
Regards,
Balakumar.G

Similar Messages

  • Are there any alternatives for mseg and mkpf

    I had to display from table S032...following fields.
    S032-LETZTABG --> Date: last (i.e. most recent) goods issue
    S032-LETZTVER --> Date: last (i.e. most recent) consumption
    However the data was not properly filled in s032 table.  So I went for mseg and mkpf table to get budat based on moment types.
        SELECT   MSEG~MATNR
                 MSEG~WERKS
                 MSEG~LGORT
                 MSEG~BWART
                 MKPF~BUDAT
                 INTO TABLE IT_MSEG
                 FROM MKPF AS MKPF  INNER JOIN MSEG AS MSEG
                 ON
                     MKPFMBLNR  =  MSEGMBLNR  AND
                     MKPFMJAHR  =  MSEGMJAHR
                 FOR ALL ENTRIES  IN  T_OUT_TMP
                WHERE MSEG~MATNR  EQ  T_OUT_TMP-MATNR
                  AND MSEG~WERKS  EQ  T_OUT_TMP-WERKS.
    Are there any other alternative table for mseg and mkpf...
    Because my above coding  ( which includes above  SELECT of mseg and mkpf )got performance issue...
    Could you please suggest me anyu other alternative for mseg and mkpf ...

    Try to include the BUDAT in the selection of the MKPF.. if you don't have any restriction in MKPF than just pass an empty range.
    RANGES: S_BUDAT FOR MKPF-BUDAT.
    SELECT
    MKPF~BUDAT   "<<<
    MSEG~MATNR
    MSEG~WERKS
    MSEG~LGORT
    MSEG~BWART
    INTO TABLE IT_MSEG
    FROM MKPF AS MKPF INNER JOIN MSEG AS MSEG
    ON
    MKPF~MBLNR = MSEG~MBLNR AND
    MKPF~MJAHR = MSEG~MJAHR
    FOR ALL ENTRIES IN T_OUT_TMP
    WHERE
    MKPF~BUDAT IN S_BUDAT   " <<<
    MSEG~MATNR EQ T_OUT_TMP-MATNR
    AND MSEG~WERKS EQ T_OUT_TMP-WERKS.
    Regards,
    Naimesh Patel

  • Select query based LOV for tabular form attributes

    Hi HTMLDB Team,
    Congrats u all for the new release of HTMLDB in htmldb.oracle.com.
    I badly need a solution of the below problem.
    Say , i have table called user_col_comments now i want to display the table_name ,column_name and comments in a tabular form.I displayed only one row for the tabular form.Now i create a select query based LOV for attribute table_name where i got all table_name in drop down list.
    Point is that after selecting any data from drop down table list i want to get the corresponding fields to be populated in column_name attributes.How can i wrote the select query based LOV for the attibute column_name.
    I wrote it as 'select column_name d,column_name r from user_col_comments where table_name=:TABLE_NAME Its not working?
    Similarly i want same thing to display for comments after matching both table_name and column_name.
    Any solution to get rid of those problem will be highly appreciable...
    If u need my htmldb.oracle.com userid and password to solve the problem i will sure let u email it.
    Cheers,
    Eman

    hi rchalton,
    can u plz little bit more clearer .I know hopefully u can imagine the problem and may u guide me thru proper way.....One think i understand that there must be multiple process and submit but "only when..." that u have said i cant understand that part........
    U are welcome to give me proper solution.....
    Thanks for the reply ....atleast one can pay hid to me.....
    Cheers,
    Eman

  • Clip inspector in imovie not working properly - when I select a picture - and select clip adjustment it tells me that I need to select one or more clips to view Inspector tools and in a clip the audio adjustment only shows a speaker? help

    Clip inspector in imovie not working properly - when I select a picture (in project library) - and select clip adjustment it tells me that I need to select one or more clips to view Inspector tools and when I select a movie clip and then click on audio adjustments the audio adjustment appears as a speaker icon and I don't know how to get to the various audio options? It was working fine one minute and then I seemed to lose the functionality. Also editing a photo in a photo or getting rid of ken burns effect etc does not seem to work. help

    Can anyone shed any light on this as I am having the same problem? One minute it works fine, the next you get the error message above.
    Many thanks.

  • App-V PowerShell: Script to Query XenApp Servers for App-V Publishing Errors and Output an Excel Document with the Results

    Please Vote if you find this to be helpful!
    App-V PowerShell:  Script to Query XenApp Servers for App-V Publishing Errors and Output an Excel Document with the Results
    Just posted this to the wiki:
    http://social.technet.microsoft.com/wiki/contents/articles/25323.app-v-powershell-script-to-query-xenapp-servers-for-app-v-publishing-errors-and-output-an-excel-document-with-the-results.aspx

    Hi petro_jemes,
    Just a little claritification, you need to add the value to the variable "[string]$ou", and also change the language in the variable "$emailbody" in the function "Get-ADUserPasswordExpirationDate".
    I hope this helps.

  • How can I use TopLink for querys that have two and more tables?

    I use TopLink today, and I can use one table to query, but how can I use TopLink for querys that have two and more tables?
    Thank you for see and answer this question.

    You can write a custom SQL query and map it to an object as needed. You can also use the Toplink query language "anyOf" or "get" commands to map two tables as long as you map them as one to one (get command) or one to many (anyOf command) in the toplink mapping workbench.
    Zev.
    check out oracle.toplink.expressions.Expression in the 10.1.3 API

  • View on RESB and MBEW tables

    Hi gurus,
    I want to create view on RESB and MBEW tables. Can any one tell me which field i need to take as delta field in the Generic datasource for this view.
    Thanks in advance.

    Hi,
         Go through this link http://rlaan.mine.nu/SAP-Tables/SAP%20Table%20Listing.htm.
    Regards
    Sridhar

  • What does it mean when the usecounts of Parse Tree for a view is incrementing when a select query is issued against the view?

    I'm using SQL Server 2008 R2 (10.50.4033) and I'm troubleshooting an issue that a select query against a specific view is taking more than 30 seconds consistently.   The issue just starts happening this week and there is no mass changes in data.  
    The problem only occur if the query is issued from an IIS application but not from SSMS.  One thing I noticed is that sys.dm_exec_cached_plans is returning 2 Parse Tree rows for the view -  one created when the select query is issued
    1st time from the IIS application and another one created when the same select query is issued 1st time from SSMS.   The usecounts of the Parse Tree row for the view (the IIS one) is increasing whenever the select query is issued.  The
    usecounts of the Parse Tree row for the view (the SSMS one) does not increase when the select query is issued again. 
    There seems to be a correlation between the slowness of the query and the increasing of the usecounts of the Parse Tree row for the view.  
    I don't know why there is 2 Parse Tree rows for the view.  There is also 2 Compiled Plan rows for the select query.  
    What does the Parse Tree row mean especially the usecounts column?

    >> The issue just starts happening this week and there is no mass changes in data.  
    There might be a mass changes in the execution plan for several reason without mass changes in data
    If you have the old version and a way to check the old execution plan, and compare to the new one, that this should be your starting point. In most cases you don't have this option and we need to monitor from scratch.
    >> The problem only occur if the query is issued from an IIS application but not from SSMS.
    This mean that we know exactly what is the different and you can compare both execution plan. once you do it, you will find that they are no the same. But this is very common issue and we can know that it is a result of different SETting while connecting
    from different application. SSMS is an external app like any app that you develop in Visual studio but the SSMS dose not use the Dot.Net default options.
    Please check this link, to find the full explanation and solutions:
    http://www.sommarskog.se/query-plan-mysteries.html
    Take a look at sys.dm_exec_sessions for your ASP.Net application and for your SSMS session.
    If you need more specific help, then we need more information and less stories :-)
    We need to see the DDL+DML+Query and both execution plans
    >> What does the Parse Tree row mean
    I am not sure what you mean but the parse tree represents the logical steps necessary to execute the query that has been requested. you can check this tutorial about the execution plan: https://www.simple-talk.com/sql/performance/execution-plan-basics/ or
    this one: http://www.developer.com/db/understanding-a-sql-server-query-execution-plan.html
    >> regarding the usecount column or any other column check this link:
    https://msdn.microsoft.com/en-us/library/ms187404.aspx?f=255&MSPPError=-2147217396.
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Restrict user SELECT query time on a particular VIEW

    Hi - I am trying to restrict user SELECT statemnet time on a particular view.There is a user called ABC and he is accessing many objects in database.All SELECT statments are fine execept when he query a particular VIEW.That view SELECT causing performance problem.So I am trying to restrict the SELECT query time on a VIEW.
    Can you please help me to achive this task through some SQL command like ALTER USER etc...
    Thanks for your help.

    user2538196 wrote:
    Hi - I am trying to restrict user SELECT statemnet time on a particular view.There is a user called ABC and he is accessing many objects in database.All SELECT statments are fine execept when he query a particular VIEW.That view SELECT causing performance problem.So I am trying to restrict the SELECT query time on a VIEW.
    Can you please help me to achive this task through some SQL command like ALTER USER etc...
    Thanks for your help.It sounds like you are really trying to solve a performance problem with the view. I agree with Justin that the solution to restrict access to the view dynamically sounds unwieldy.
    Consider tuning the view, or perhaps the query using the view. Post the view and see if anyone can help you tune it.

  • Select Query Resutls - operand for WebI Rich Client XI3.0 not available?

    Hi ,
    Using Deski we put a filter condition on a query using the deski query panel.  Also we can select resutls from another query in the same report (query from a differen dataprovider) using the operand Select Query Resutls(any).
    However in Web Intelligence Rich Client for XI3.0 we don't have this operand so we can not filter using results from another query in the same report.
    Does anyone know how to work around this problem?
    Know any plans for this feature ?  As you all know, this is an extremely powerful feature.
    Rgds,

    Minkook,
    Does anyone know how to work around this problem?
    Rich client allows you to import a text or excel file on the fly to your report.  To filter what you have you could build entries into the excel file, import, merge dimensions and voila, have your filtering done.  It does seem dumb to do it this way when a quick filter is all you want.  I'm with you in that the quick filter functionality would be highly desirable.
    Thanks,
    John

  • Select query case insensitive for data type VARG

    Hi Experts,
    I am having trouble in retrieving the results from a table using select query.
    I have a table (Users) as below
    Name (VARG)        Number(INTEGER)
    Murthy             0001
    murthy             0002
    when I am querying the table with select query as -
    select * from Users where Name = 'Murthy'
    this query is returning only one record which matches with capital letter of 'M', though both the record names are same.
    I have seen in IBM forum to make the select query as case insensitive using the UPPER key word, I have tried this as below -
    select * from Users where UPPER(Name) = 'MURTHY'
    But this query is not working in my case...
    My DB2 version is 8.1.5
    Can any one please help in fixing this problem...
    Thanks in Advance,
    Murthy

    Hi Murthy,
    your query is the right to one to select both records. I don't see why it doesn't work.
    Are you sure you posted the query that you have executed ?
    What is the result of this query ?
    But i don't really know how an VARG (Varying-length graphic string) will work. It could be that the UPPER-Function will work in another way as it works on VARCHAR.
    regards
    Kay

  • Select query taking too much time to fetch data from pool table a005

    Dear all,
    I am using 2 pool table a005 and a006 in my program. I am using select query to fetch data from these table. i.e. example is mentioned below.
    select * from a005 into table t_a005 for all entries in it_itab
                       where vkorg in s_vkorg
                       and     matnr in  s_matnr
                       and     aplp   in  s_aplp
                       and     kmunh = it_itab-kmunh.
    here i can't create index also as tables are pool table...If there is any solutions , than please help me for same..
    Thanks ,

    it would be helpful to know what other fields are in the internal table you are using for the FOR ALL ENTRIES.
    In general, you should code the order of your fields in the select in the same order as they appear in the database.  If you do not have the top key field, then the entire database is read. If it's large then it's going to take a lot of time.  The more key fields from the beginning of the structure that you can supply at faster the retrieval.
    Regards,
    Brent

  • Different behavior for Power View between Excel and Power Bi Site

    Hello,
    this problem is driving me crazy...
    I have a PowerPivot Data Model and created a PowerView that includes three charts for the 
    Year, Quarter, Brand and a matrix that allow me to drill down the different projects. Each Project in the matrix can be clicked to view the project details.
    The strange thing is that in Excel on my Desktop and in the Power Bi App for Surace RT when i press the Project in the drill down the previous filters remains set, while if i do the same in Power Bi Sites the filters are lost. I tried with Chrome and IE
    but behavior the same. Am i missing something?
    Thank you so much

    Dear Will,
    thank you so much for your reply.
    I'm attaching come screenshots from Power bi site i remove the clases and the data, but you should have an idea of the scenario. Actually I'm not setting the Year and Quarter filter as view filters in the Power View.
    I'm just using Cross filtering and i realize that the behavior is different between Excel Desktop and Power Bi Surface RT app and the bi sites (with all browsers).
    First image with 2014 set (just clicked on 2014) the data on the Matrix have been deleted.
    After i select the drill down:
    Thank you so much for your help, I really appreciate it!
    --silvano

  • Query FI - coding for including fields from doc and clearing doc

    Hi!
    I am a functional FI consultant and need to create a query (SQ01) with information from the payment document and the invoice which was cleared by the payment. I need to know which coding to use to include two fields from the invoice document in the query.
    Thank you
    Claudia

    Hi,
    Try something like this. I could not try it in my system, if there are some error let me know.
    FIELD-SYMBOLS
         : <SOURCE_PACKAGE> LIKE LINE OF SOURCE_PACKAGE.
    LOOP AT SOURCE_PACKAGE ASSIGNING <SOURCE_PACKAGE>.
    LOOP AT it_docu_condition into wa_docu_condition
                   where Order = <SOURCE_PACKAGE>-Order  and
                            item   = <SOURCE_PACKAGE>-item.
    CASE wa_docu_condition-condition_type.
    when u2019bonusu2019.
    <SOURCE_PACKAGE>-bonus = wa_docu_condition-condition_value.
    when u2019skontou2019.
    <SOURCE_PACKAGE>-skonto = wa_docu_condition-condition_value.
    when u2019taxu2019.
    <SOURCE_PACKAGE>-tax = wa_docu_condition-condition_value.
    ENDCASE.
    ENDLOOP.
    Regards

  • VB code for executing pl/sql procedure, and displaying TABLE OUT parameter

    Does anybody have any sample VB code (using OO4O) for executing a PL/SQL stored procedure, and then displaying (in Excel preferably) the following OUT parameters from the procedure:
    (1) variable(s) of TYPE PL/SQL RECORD
    (2) variable of TYPE PL/SQL TABLE defined as TABLE%ROWTYPE
    (3) n variables of TYPE PL/SQL TABLE'S defined as table.column%TYPE;
    Thanks.

    Here is what we use to bring in arrays of data from plsql. Here will be some sample vba code and plsql.
    What the plsql need to run in an array of input dates and an array of ids to lookup for the dates (also needs the number of values in the arrray.
    vba code...
    Sub Bull()
    Dim oDoc As Object
    Dim oTable As Object
    Dim oCell As Object
    Dim ArrCtr As Integer
    Dim iCount As Integer 'Counter
    Dim DataDynaset As Object 'Dynaset for retrieved values
    Dim DischDataDynaset As Object 'Dynaset for retrieved values
    Dim TWDataDynaset As Object 'Dynaset for retrieved values
    Dim PDDataDynaset As Object 'Dynaset for previous day retrieved values
    Dim MSTssCodes As Variant ' TS Codes Array
    Dim NumRows As Integer 'Number of rows in the table
    Dim NumColumns As Integer 'Number of columns in the table
    Dim NumArrayVals As Integer 'Number of array values (actual number - 1)
    OraLogin
    NumRows = 83
    NumColumns = 11
    'One less than number because we start at 0
    'NumArrayVals = 5
    NumArrayVals = 117
    ReDim DateArr(NumArrayVals)
    MSTssCodes = Array(3398, 3406, 3391, 3385, 3413, 3378, _
    2254, 2254, 2254, _
    3398, 3406, 3391, 3385, 3413, _
    3460, 3455, 3450, 3447, 3505, 3444, 2254, 2254, _
    4974, 2803, 4735, 4719, 2837)
    ****** NOW THIS WILL GET READY TO SEND TO PLSQLGetData MSTssCodes, DateArr, DataDynaset, NumArrayVals + 1
    .... more suff in the sub
    Sub GetData(Tssids, DateArray, TmpDataDynaset, NumRetVals)
    'Retrieves data from the Oracle database
    Dim I As Integer 'Counter
    Dim TssidDynaset As Object 'Temporary array for Tssids
    Dim DateDynaset As Object 'Temporary array for dates
    OraDatabase.Parameters.addTable "TSCODES", 1, 68, NumRetVals, 0
    OraDatabase.Parameters("TSCODES").ServerType = ORATYPE_UINT
    OraDatabase.Parameters.addTable "DATES", 1, 12, NumRetVals, 0
    OraDatabase.Parameters("DATES").ServerType = ORATYPE_DATE
    OraDatabase.Parameters.addTable "VALS", 3, 2, NumRetVals, 0
    OraDatabase.Parameters("VALS").ServerType = ORATYPE_NUMBER
    OraDatabase.Parameters.Add "NUM_VALS", NumRetVals, 3
    OraDatabase.Parameters("NUM_VALS").ServerType = ORATYPE_NUMBER
    OraDatabase.Parameters.Add "ERR_NUM", 0, 2
    OraDatabase.Parameters("ERR_NUM").ServerType = ORATYPE_NUMBER
    Set TssidDynaset = OraDatabase.Parameters("TSCODES")
    Set DateDynaset = OraDatabase.Parameters("DATES")
    'Fill the arrays
    For I = 0 To NumRetVals - 1
    TssidDynaset.Put_Value Tssids(I), I
    DateDynaset.Put_Value DateArray(I), I
    Next I
    OraDatabase.DbExecuteSQL ("Begin DBCALLS.SELECT_VALUES (:TSCODES, :DATES, :VALS, :NUM_VALS, :ERR_NUM); End;")
    If OraDatabase.LastServerErr <> 0 Or OraDatabase.LastServerErrText <> "" Then
    MsgBox "Error Getting Data"
    End If
    Set TmpDataDynaset = OraDatabase.Parameters("VALS")
    'MsgBox (OraDatabase.Parameters("NUM_VALS") & " " & OraDatabase.Parameters("ERR_NUM"))
    OraDatabase.Parameters.Remove "TSCODES"
    OraDatabase.Parameters.Remove "DATES"
    OraDatabase.Parameters.Remove "VALS"
    OraDatabase.Parameters.Remove "NUM_VALS"
    OraDatabase.Parameters.Remove "ERR_NUM"
    End Sub
    Now here is the plsql called from the DBCALL package......
    --Select time series values for give ts_codes.
    PROCEDURE select_values (
    ts_codes IN IntArrayTyp,
    dates IN DateArrayTyp,
    vals IN OUT NumArrayTypIB,
    --quality   IN  OUT RawArrayTyp,
    num_vals IN INTEGER,
    err_num OUT INTEGER) IS
    BEGIN
    --initialize variables
    err_num := 0;
    FOR i IN 1..num_vals LOOP
    BEGIN
    SELECT value INTO vals(i)
    FROM table_name
    WHERE ts_code = ts_codes(i)
    AND date_time = dates(i);
    EXCEPTION
    WHEN OTHERS THEN
    --dbms_output.put_line (ts_codes(i) || ' ' || SQLCODE);
    vals(i) := -1.0;
    err_num := SQLCODE;
    END;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    --dbms_output.put_line (tssid || ' ' || SQLCODE);
    err_num := SQLCODE;
    END select_values;

Maybe you are looking for

  • Sales Order Materials from Notification

    Hi All, Request your help. From Notification creation, after we create Tasks in All tasks tab, when we try to create the Sales Order, we have a requirement to pull the details from the Task long text using Read_text( here in the long text, we give th

  • How can you delete old mail addresses?

    When sending an email (with iPhone 4, iOS5, Gmail) and you are starting to type the recipient's name at the "To:" field, the autofill function suggests addresses some of which are dated / no longer valid / unwanted ones, from previous recipients. How

  • Tables for Confirmation Production Order.

    Hi Friends! we want to be find Tables for Confirmation Production Order[PP]. reply, Rahul

  • File LookUp in the MM : FileNotFound Exception

    Hello Friends, I am trying to fetch a file during the message mapping. The code I have written in the UDF is as follows : <u> String company = ""; HashMap fileMap = new HashMap(); BufferedReader reader = new BufferedReader(new FileReader("C: testfold

  • How to Check for Default Applet Selection

    Hello all, I'm new to the Java Card world, so I'll warn you in advance my questions will be basic. I appreciate your willingness to help us newbies out. I've been given a smart card and applets to dissect an reverse engineer. Currently, Applet 1 is l