Best way to query

Hello All,
    I have a scenario.
I read a DB table MARA, i will get few records .
now i have to query a Z* table, based on the mara entries, what i got earlier.
but in Z* table contains the material, with two extra characters than mara-matnr.
for eg: if mara-matnr = 12345
         Z*-matnr can be 1234500 or/and 12345AB like this.......
I know i can loop through mara entries and select Z* for each of mara entry using like statement.
is there any other better way.
I cant use 'for all entries' with 'like'  it is giving  a sytax error saying this combination cant be used.
Thanks in advance.
Best Regards
Amrender Reddy B

Hi,
1) Declare 3 tables and corresponding WA of type of your Z*table say suppose gt_table1,gt_table2 and gt_table3
2) Do a select on Z*table and get all the data in table gt_table1. 
    Loop at gt_table1 into wa_table1.
      wa_tbale2 = wa_tbale1.
      wa_table2-matnr = wa_table-matnr+(5).  << if MATNR is 12345AB then it will take only 12345
                                             << this logic will only work when MATNR lenght is constant
     append wa_table2 to gt_table2.
    Endloop.
Then,
Loop at gt_table2 into wa_table2.
   Read table gt_mara with key wa_mara-matnr = wa_table2-matnr.
    if sy-subrc ne 0.
       wa_table3 = wa_table2.  <<u can delete entries here but it can give some performance problm
   endif.
Endloop. 
delete gt_table2 from gt_table3.
This way u will get the required records in gt_table2.
Regards,
Mukesh.

Similar Messages

  • What is the best way to query planned orders or work orders for make items and identify the buy component that is short for supply and vice versa?

    What is the best way to query planned orders or work orders for make items and identify the buy component that is short for supply and vice versa?

    What is the best way to query planned orders or work orders for make items and identify the buy component that is short for supply and vice versa?

  • Best way to query extended events file in sql server 2012

    Hello all,
    is there any best way to xquery extended events async file i am having hard time sorting  out data in GUI and using xquery.
    Any help highly appreciated.
    thanks,
    ashwin.

    Yes, there might be better way to write it the way you did it. But since I don't know what you wrote or what you are looking for I can't give any advice. You need to be more specific.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • What is the best way to Query for a PXI Chassis in TestStand

    Hi All,
    I have some benches that have a PXI Chassis and others without. 
    I would like to Query for the Chassis and if it isn't there I will use another method of testing.
    Is there a way to query for the chassis and if there is how?
    Thanks
    Message Edited by glennjammin on 10-09-2009 09:23 AM
    Test Engineer
    L-3 Communications
    Solved!
    Go to Solution.

    Hi,
    You could use the VISA Find Resource function. If you get back PXI[bus]::device[::function][::INSTR] or PXI[interface]::[bus-]device[.function][::INSTR] then you have a PXI chassis
    regards
    Ray Farmer
    Regards
    Ray Farmer

  • Best way to query data with varchar (max) cloumn.

    Hi,
    I have joined  three table and selected 15colmuns over a period of 6months it tooks 10sec .
    I selected two more columns with varchar(max) datatype it took me 60sec.
    whats the best way to select varchar(max) over a period?
    Can anyone please help me on this?
    Thanks,

    I have joined  three table and selected 15colmuns over a period of 6months it tooks 10sec .
    I selected two more columns with varchar(max) datatype it took me 60sec.
    That appears to be normal behavior for any RDBMS.
    You can use the LEFT function to limit transmission volume from server to client:
    SELECT A.Title, A.DocumentSummary INTO tempdb.dbo.DocText
    FROM Production.Document A
    CROSS JOIN Production.Document B CROSS JOIN Production.Document C
    CROSS JOIN Production.Document D CROSS JOIN Production.Document E;
    -- (59049 row(s) affected)
    SET STATISTICS TIME ON
    DBCC DROPCLEANBUFFERS
    SELECT A.Title, A.DocumentSummary FROM tempdb.dbo.DocText A
    DBCC DROPCLEANBUFFERS
    SELECT A.Title, Prefix=LEFT(A.DocumentSummary,10) FROM tempdb.dbo.DocText A
    SET STATISTICS TIME OFF
    SQL Server Execution Times:
    CPU time = 172 ms, elapsed time = 787 ms.
    DBCC execution completed. If DBCC printed error messages, contact your system administrator.
    (59049 row(s) affected)
    SQL Server Execution Times:
    CPU time = 62 ms, elapsed time = 560 ms.s.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Best way to query cache - get() vs filters?

    Hi,
    I am in a dillemma. Whether to use NamedCache.get() or entrySet(filter) methods to query the cache. Please guide me..
    My understanding is that when using
    1. get() or getAll(), Coherence checks whether the entry is in the cache, if it does exist in the cache, Coherence get its from the DataStore
    2. entrySet(Filters), Coherence just checks the cache and returns results based on whats available in the cache.
    In that case, Isnt it better to use get instead of entrySet in a case where one is not sure whether up to date data is available in the Cache?
    1. What is the difference between using a get and using entrySet ?
    2. How does one make sure that up to date data is available in the cache when not using a write-behind scenario?
    I am newbie...Gurus, please guide me..

    sjohn wrote:
    Hi,
    I am in a dillemma. Whether to use NamedCache.get() or entrySet(filter) methods to query the cache. Please guide me..
    My understanding is that when using
    1. get() or getAll(), Coherence checks whether the entry is in the cache, if it does exist in the cache, Coherence get its from the DataStoreThat's not the relevant part.
    In this case because you specified the keys to the entries, Coherence knows exactly where each entry resides, and optimally communicates with the owner nodes (1 network call / owner node) to get the data, and it will return the data without deserialization on the owner node.
    2. entrySet(Filters), Coherence just checks the cache and returns results based on whats available in the cache.
    In this case, depending on the actual filter (hierarchy) Coherence has to contact all nodes (if you did not filter it with KeyAssociatedFilter or PartitionFilter), which is not scalable, then depending on the filter(s) used it may have to deserialize possibly all cached entries (which is expensive) to evaluate the filter. On the other hand this method is usable for non-key-based access, which the get/getAll is not able to do.
    In that case, Isnt it better to use get instead of entrySet in a case where one is not sure whether up to date data is available in the Cache?
    1. What is the difference between using a get and using entrySet ?Heaven and earth...
    2. How does one make sure that up to date data is available in the cache when not using a write-behind scenario?
    You have to preload it, or trigger fetching it from a cache-store.
    Best regards,
    Robert

  • Best way to query sap tables

    hi everyone. i am new to data services, so here we go. we are using an sql2005 server for our end data repository. i am trying to create a temp table of sap po data. i have split the queries up so that query 1 is 2 sap tables, query 2 pulls in another sap table, etc. so that i only have one sap table, other then the first query, being queried at a time. it takes a really long time - i end up killing the job. is there a better way to pull sap data?
    thanks - sandra.

    Try here:-
    http://wiki.sdn.sap.com/wiki/display/BOBJ/SAP
    This is an incredibly useful set of pages.

  • Best way to query on a non-table item?

    Hi,
    I have a form that has customer_name (non-table item) and customer_id (table item). Customer_id is not visible to the user. We need to be able to query on the customer_name. I have tried using the pre-query trigger but I get an error ORA-01422. Any suggestions would be appreciated. I am a non-technical person, so the simpler, the better.
    Thanks in advance.
    Trish

    Hi ,
    I know two alternatives:
    1) Use the POST-QUERY trigger not the PRE-QUERY... But, you would have the same problem because i think that the customer_id column is not unique. So you should select a combination of columns which guarantee the uniqueness of the selected column...
    2)Other design. Read the doc at :
    http://www.oracle.com/technology/products/forms/pdf/BlockOnAJoin.pdf
    Using this way you should not use the trigger POST-QUERY....
    Regards,
    Simon

  • What is the best way to query for the roles of a 2013 Lync server?

    I am new to Lync.
    I am not able to find, but if anyone already asked and got answers in this forum, or documentation I will be much appreciate. 
    I would like to programmatically ( powershell wmi most likely)
    Get-WmiObject –query ‘select * from win32_product’ | where {$_.name –ilike “*Lync*”}
    Typically returns a lot of installed components, is there a way to tell whether a lync ( 2013) installation and deployment is either a Front/Back, or Edge or Mediation?
    Thanks

    thanks. Although I was expecting  (hoping) to be able to query for roles like : Front/Back, Edge , Mediation, Director and etc.
    PS C:\Users\labuser> get-csservice | select PoolFqdn,Role,SiteId
    PoolFqdn                   Role                       SiteId
    lab-lync2013-01.lab.exc13  UserServer                 Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  Registrar                  Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  UserDatabase               Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  FileStore                  Site:lab-lync2013-01
    LAB-EXCH2013CAS            WacServer                  Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  WebServer                  Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  ConferencingServer         Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  MediationServer            Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  ApplicationServer          Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  ApplicationDatabase        Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  CentralManagement          Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  CentralManagementDatabase  Site:lab-lync2013-01
    lab-lync2013-01.lab.exc13  MonitoringDatabase         Site:lab-lync2013-01
    10.199.4.4                 PstnGateway                Site:lab-lync2013-01
    What if, I use get-counter instead?
    E.g. if I am able to get something returned for 
    \LS:A/V Edge - UDP Counters(_Total)\A/V Edge - Packets Dropped/sec  , then I know it has Edge role
    \LS:MediationServer then it has Mediation role
    But then I really cannot tell for sure for FF or just Standard Editor Server.
    It is the list of server roles described in here that I am interested in. I understand Lync is very flexible in terms of deployment roles.
    http://technet.microsoft.com/en-us/library/gg398536.aspx
    Thanks
    Ben

  • Best way to query SQLite db in mobile app

    I have created a mobile app with a directory screen.  I'd like to query and display records from a SQLite DB and my question is what is the best method for doing that? I've created a SQL db with dummy records via SQLite Manager and I want to create a screen/article in Indesign that queries that DB and displays the resulting records.

    When you say access for later, do you mean between application launches or at runtime?  If you want to persist sometihng between launches, you can use the persistenceManager object on the application.  This object allows you to save and retrieve key-value pairs.  If you want to do this at runtime, I would suggest just having some sort of service or object (such as an ArrayCollection) in the global scope so that you can easily retrieve the information as necessary.
    When pushing on a new view, you can pass data to the new view using the pushView api.  This allows you to send some identifier or data object for a specific card to the next view so that i can properly display it.  For example:
    navigator.pushView(CardView, cardData);
    The new CardView will have the cardData object you sent set to its data property.  See http://opensource.adobe.com/wiki/display/flexsdk/View+and+ViewNavigator for more information.
    Chiedo

  • Best way to spool DYNAMIC SQL query to file from PL/SQL

    Best way to spool DYNAMIC SQL query to file from PL/SQL [Package], not SqlPlus
    I'm looking for suggestions on how to create an output file (fixed width and comma delimited) from a SELECT that is dynamically built. Basically, I've got some tables that are used to define the SELECT and to describe the output format. For instance, one table has the SELECT while another is used to defined the column "formats" (e.g., Column Order, Justification, FormatMask, Default value, min length, ...). The user has an app that they can use to customize the output...which leaving the gathering of the data untouched. I'm trying to keep this formatting and/or default logic out of the actual query. This lead me into a problem.
    Example query :
    SELECT CONTRACT_ID,PV_ID,START_DATE
    FROM CONTRACT
    WHERE CONTRACT_ID = <<value>>Customization Table:
    CONTRACT_ID : 2,Numeric,Right
    PV_ID : 1,Numeric,Mask(0000)
    START_DATE : 3,Date,Mask(mm/dd/yyyy)The first value is the kicker (ColumnOrder) as well as the fact that the number of columns is dynamic. Technically, if I could use SqlPlus...then I could just use SPOOL. However, I'm not.
    So basically, I'm trying to build a generic routine that can take a SQL string execute the SELECT and map the output using data from another table to a file.
    Any suggestions?
    Thanks,
    Jason

    You could build the select statement within PL/SQL and open it using a cursor variable. You could write it to a file using the package 'UTL_FILE'. If you want to display the output using SQL*Plus, you could have an out parameter as a ref cursor.

  • Best way to outer join a table that is doing a sub query

    RDBMS : 11.1.0.7.0
    Hello,
    What is the best way to outer join a table that is doing a sub query? This is a common scenario in EBS for the date tracked tables.
    SELECT papf.full_name, fu.description
      FROM fnd_user fu
          ,per_all_people_f papf
    WHERE fu.user_id = 1772
       AND fu.employee_id = papf.person_id(+)
       AND papf.effective_start_date = (SELECT MAX( per1.effective_start_date )
                                          FROM per_all_people_f per1
                                         WHERE per1.person_id = papf.person_id)Output:
    No output produced because the outer join cannot be done on the sub queryIn this case I did a query in the FROM clause. Is this my best option?
    SELECT papf.full_name, fu.description
      FROM fnd_user fu
          ,(SELECT full_name, person_id
              FROM per_all_people_f papf
             WHERE papf.effective_start_date = (SELECT MAX( per1.effective_start_date )
                                                  FROM per_all_people_f per1
                                                 WHERE per1.person_id = papf.person_id)) papf
    WHERE fu.user_id = 1772
       AND fu.employee_id = papf.person_id(+)Output:
    FULL_NAME     DESCRIPTION
    {null}            John DoeThanks,
    --Johnnie                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    BrendanP wrote:
    ... See the adjacent thread for the other with Row_Number().Do you mean {message:id=10564772} ? Which threads are adjacent is always changing. Post a link.
    I think RANK suits the requirements better than ROW_NUMBER:
    WITH    all_matches     AS
         SELECT  papf.full_name
         ,      fu.description
         ,     RANK () OVER ( PARTITION BY  papf.person_id
                               ORDER BY          papf.effective_start_date     DESC
                        )           AS r_num
         FROM             fnd_user             fu
         LEFT OUTER JOIN      per_all_people_f  papf  ON  fu.employee_id  = papf.person_id
         WHERE   fu.user_id  = 1772
    SELECT     full_name
    ,     description
    FROM     all_matches
    WHERE     r_num     = 1
    Johnnie: I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    See the forum FAQ {message:id=9360002}

  • What is the best way to Optimize a SQL query : call a function or do a join?

    Hi, I want to know what is the best way to optimize a SQL query, call a function inside the SELECT statement or do a simple join?

    Hi,
    If you're even considering a join, then it will probably be faster.  As Justin said, it depends on lots of factors.
    A user-defined function is only necessary when you can't figure out how to do something in pure SQL, using joins and built-in functions.
    You might choose to have a user-defined function even though you could get the same result with a join.  That is, you realize that the function is slow, but you believe that the convenience of using a function is more important than better performance in that particular case.

  • Best way of creating request for a query

    hi,
        what will be the best process to create the request for the query.
    1.go to rsa1-> transport connection -> select query -> select  BEx bus-> create the request, then change the query and save
                                                                                    OR
    2. change the query first and assign the request in the transport connection
    Please help me put.

    Hi,
    You would get problems when you transport it by the second method, like the Variable might get missed out when you edit the query and save it to the request.
    First method through Transport connection is the best way to do it, to make sure all the objects are collected.
    Regards,
    Mani

  • What's the best way to sort query results?

    Hello All,
    I have a standard CRUD UI that now needs the results sorted, based on input from the UI. What's the best way to sort results by entity fields?
    I'm familiar with the conventional Java methodology using a TreeSet and comparator. Is this the best route, does BDB JE offer more convenient or performant alternatives?
    I looked through the documentation and saw how to change the indexes, but I'm just looking to change the order in the scope of the query.
    If my application were an address book, the UI would be sortable, ascending and descending, by date added, first name, last name, etc. based on which column the user clicked on.
    Thanks in advance,
    Steven
    Harvard Children's Hospital Informatics Program

    Hi Steven,
    Using standard Java collections is probably the best approach.
    One thing that may be useful is to get a SortedMap (Primary or SecondaryIndex.sortedMap) for the case where you have an index sorted the way you want, and then copy the primary index into a TreeMap (with a comparator) for other cases. That way, you always have a SortedMap to work with, whether you're copying the index or not.
    I haven't tried this myself, just a thought.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Pdf reader X has problems with small pdf and printer with post script driver

    Hi friends. I have installed new Reader X and then i saw that, when i print a very small pdf with about 50 kb and i print it on a Laserjet 4000 printer the printer has problem with the amount of data that reader 10 produces. When i install a Postscri

  • Removing Scroll Bar from JPanel..emergency

    Can any one tell me please, that i wan that when i hav 6 or greater than 6 components in my panel then there appear Scoll bar else if i hav less than 6 componets then there is no need of Scroll bar.. Any help will be Appreciated..

  • Audio from Flash CS3 Video overlapping

    audio from Flash CS3 Video overlapping help stopping the FLVPlayback instance (which has an instance name of theVideo) when another button is clicked! How do I stop flv playback when user clicks a navigation button ... Excuse me in advance for asking

  • Select list filter in a tabular form problem

    Hello everyone: I need to filter a list in a tabular form, depend on another column value in the same row of the Tabular Form Try using the syntax *#COLUMN#* in the query of select list but did not work. This is my query SELECT   nombre_respuesta, co

  • Landscape and Portrait command

    Hello, can u give me a help? How can we send by command the layout to the report. I have this report in portrait layout disposicton but i want to send the landscape command to printer.... There is anything for that....???'