App-V Reporting: SQL query for Excel Pivot Table to display App Usage (H/M/S)

I recently posted this in the Gallery.  If anyone has any modifications or enhancements please feel free to contribute!  One thing that I'd like to be able to add to it is the ability to only display information for applications/packages that are
still published, so if anyone can figure out a crafty way to do it...  Thanks!
http://gallery.technet.microsoft.com/App-V-Reporting-SQL-query-6695d3c3

I recently posted this in the Gallery.  If anyone has any modifications or enhancements please feel free to contribute!  One thing that I'd like to be able to add to it is the ability to only display information for applications/packages that are
still published, so if anyone can figure out a crafty way to do it...  Thanks!
http://gallery.technet.microsoft.com/App-V-Reporting-SQL-query-6695d3c3

Similar Messages

  • Neea a sql query for inverting the table

    Hi,
    I am facing the problem in forming a SQL statement in oracle 10g
    Table structure:
    user field1 field2 field3 field4 field5 field6 .......
    one 11 12 13 14 15 16
    two 21 22 23 24 25 26
    three 31 32 33 34 35 36
    i want a SQL query where the out put is
    field1 11 21 31
    field2 12 22 32
    field3 13 23 33
    field4 14 24 34
    Regards,
    Balu CH

    check this Forums page
    <http://forums.oracle.com/forums/search.jspa?threadID=&q=Rows+to+Columns&objID=f75&dateRange=last90days&userID=&numResults=15>
    will help u.
    Rgds
    Sudar

  • Using Axis(1), gives error "Slicer Axis cannot be referenced" in excel pivot table, but works fine ssms

    Hi .. I am using Axis(1) to select all the retrieved records. The MDX query looks like-
    WITH MEMBER [Measures].[New Opportunity Count]
     AS SUM(
             {DESCENDANTS(
              [Opportunity].[Opportunity].CURRENTMEMBER,
              1
            iif([Measures].[Opportunity Sales Days - Invisible] > 0,1,0)
     //HAVING [Measures].[New Opportunity Count] = 1
     MEMBER [Measures].[Latest Opportunity Count]
     AS SUM(
          EXCEPT( AXIS(1),
                    [Opportunity].[Opportunity].[All]
                 ),[Measures].[New Opportunity Count])
    MEMBER [Measures].[Opportunity Sales Days]
    AS iif([Measures].[New Opportunity Count] =0,0,
          iif([Opportunity].[Opportunity].CURRENTMEMBER.MEMBER_KEY =[Opportunity].[Opportunity].[All].MEMBER_KEY,
            (SUM(
                EXCEPT(AXIS(1),
                    [Opportunity].[Opportunity].[All]
                 ),[Measures].[Opportunity Sales Days - Invisible])/[Measures].[Latest Opportunity Count]),
            [Measures].[Opportunity Sales Days - Invisible]/[Measures].[New Opportunity Count])
    SELECT 
      [Measures].[Latest Opportunity Count],
      [Measures].[New Opportunity Count],
      [Measures].[Opportunity Sales Days]
    }ON COLUMNS,
        [Opportunity].[Opportunity].&[{140D9883-6F49-E011-AEA0-00155D032A00}],
        [Opportunity].[Opportunity].&[{3A2BB124-EE85-E011-8A06-00155D032A00}],
        [Opportunity].[Opportunity].&[{60036FE8-DC48-E111-975F-00155D032A00}],
        [Opportunity].[Opportunity].&[{CA158EE5-C445-E111-975F-00155D032A00}],
        [Opportunity].[Opportunity].&[{B69F83EB-832D-E211-9861-00155D032A00}],
        [Opportunity].[Opportunity].&[{D500AE90-606C-E211-83AD-00155D03570D}],
        [Opportunity].[Opportunity].[All]
    //      [Opportunity].[Opportunity].members
    ON ROWS
    FROM [IMGROUP Base]
    It works fine in SSMS editor, but while trying to access the same query from Excel pivot table, it gives the error : "Slicer axis cannot be referenced". I have taken the MDX query from excel and it looks like -
    SELECT NON EMPTY Hierarchize({DrilldownLevel({[Opportunity].[Opportunity Hierarchy].[All]},,,INCLUDE_CALC_MEMBERS)}) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME,[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Account Manager],[Opportunity].[Opportunity
    Hierarchy].[Opportunity].[Opportunity Actual Close Date Time],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Age In Days],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Close Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Created On Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Created On Date Time],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Days In Sales Stage],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Delivery
    Owner],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Close Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project Duration In Days],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Estimated Project Duration In Months],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project Duration In Working Days],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project End Date],[Opportunity].[Opportunity
    Hierarchy].[Opportunity].[Opportunity Estimated Project First Working Day Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project Last Working Day Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated
    Project Start Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Latest News],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Latest News Updated On Date Time],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Lost Competitor],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Originating Lead Name],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Owning Organisation],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Revenue Spread],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Sales Assist],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Sales Assist-Hidden],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Sales Stage],[Opportunity].[Opportunity
    Hierarchy].[Opportunity].[Opportunity Sales Stage Updated On Date Time],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Source Full Name],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity State],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Sub Source],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Updated On Date Time],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Won Lost Description],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Won Lost
    Reason] ON COLUMNS  FROM (SELECT ({[Opportunity].[Opportunity Hierarchy].[Opportunity].&[{B69F83EB-832D-E211-9861-00155D032A00}], [Opportunity].[Opportunity Hierarchy].[Opportunity].&[{CA158EE5-C445-E111-975F-00155D032A00}], [Opportunity].[Opportunity
    Hierarchy].[Opportunity].&[{60036FE8-DC48-E111-975F-00155D032A00}], [Opportunity].[Opportunity Hierarchy].[Opportunity].&[{3A2BB124-EE85-E011-8A06-00155D032A00}], [Opportunity].[Opportunity Hierarchy].[Opportunity].&[{140D9883-6F49-E011-AEA0-00155D032A00}]})
    ON COLUMNS  FROM [IMGROUP Base]) WHERE ([Measures].[Opportunity Sales Days]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
    Any help, will be greatly apreciated.
    Sayan.

    Sorry, it was a mistake in my query. Now I have corrected each of them and individually each of them works fine. See below-
    CREATE MEMBER CURRENTCUBE.[Measures].[New Opportunity Count]
     AS SUM(
             {DESCENDANTS(
              [Opportunity].[Opportunity].CURRENTMEMBER,
              1
            iif([Measures].[Opportunity Sales Days - Invisible] > 0,1,0)
    VISIBLE = 0 , 
    ASSOCIATED_MEASURE_GROUP = 'Opportunity';  
    CREATE MEMBER CURRENTCUBE.[Measures].[Latest Opportunity Count]
     AS SUM(
          EXCEPT(Axis(0),
                   [Opportunity].[Opportunity Hierarchy].[All]
                 ),[Measures].[New Opportunity Count]), 
    VISIBLE = 0 , 
    ASSOCIATED_MEASURE_GROUP = 'Opportunity';  
    CREATE MEMBER CURRENTCUBE.[Measures].[Opportunity Sales Days]
    AS iif([Measures].[New Opportunity Count] =0,0,
          iif([Opportunity].[Opportunity].CURRENTMEMBER.MEMBER_KEY =[Opportunity].[Opportunity].[All].MEMBER_KEY,
            (SUM(
                EXCEPT(AXIS(0),
                  [Opportunity].[Opportunity Hierarchy].[All]
                 ),[Measures].[Opportunity Sales Days - Invisible])/[Measures].[Latest Opportunity Count]),
            [Measures].[Opportunity Sales Days - Invisible]/[Measures].[New Opportunity Count])
    VISIBLE = 1,  
    DISPLAY_FOLDER = 'Days',  
    ASSOCIATED_MEASURE_GROUP = 'Opportunity';  
    CREATE MEMBER CURRENTCUBE.[Measures].[Opportunity Actual Value Home Currency New]
     AS  SUM(
             {DESCENDANTS(
              [Opportunity].[Opportunity].CURRENTMEMBER,
              1
            iif([Measures].[Opportunity Sales Days] > 0,[Measures].[Opportunity Actual Value Home Currency],0)
    VISIBLE = 0,  
    ASSOCIATED_MEASURE_GROUP = 'Opportunity'  ; 
    CREATE MEMBER CURRENTCUBE.[Measures].[Opportunity Actual Revenue Per Sales Day]
    AS iif([Measures].[Opportunity Actual Value Home Currency New] =0,0,
          iif([Opportunity].[Opportunity Hierarchy].CURRENTMEMBER.MEMBER_KEY =[Opportunity].[Opportunity Hierarchy].[All].MEMBER_KEY,
            (SUM(
              EXCEPT( AXIS(0),
                    [Opportunity].[Opportunity Hierarchy].[All]
                 ),[Measures].[Opportunity Actual Value Home Currency New])/[Measures].[Opportunity Sales Days]),
            ([Measures].[Opportunity Actual Value Home Currency New]/[Measures].[Opportunity Sales Days]))
    FORMAT_STRING = "£#,##0.00;-£#,##0.00;#",
    VISIBLE = 1,
    DISPLAY_FOLDER = 'Financial',
    ASSOCIATED_MEASURE_GROUP = 'Opportunity';  
    But, when I want to select them together from Excel, I am geeing the below error-
    CellOrdinal 0
    VALUE #Error MdxScript(IMGROUP Base) (1436, 7) Members, tuples or sets must use the same hierarchies in the EXCEPT function.
    FORMAT_STRING £#,##0.00;-£#,##0.00;#
    LANGUAGE (null)
    BACK_COLOR (null)
    FORE_COLOR (null)
    FONT_FLAGS (null)
    The generated MDX in Excel as -
    SELECT {[Measures].[Opportunity Actual Revenue Per Sales Day],[Measures].[Opportunity Sales Days]} DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY Hierarchize({DrilldownLevel({[Opportunity].[Opportunity Hierarchy].[All]},,,INCLUDE_CALC_MEMBERS)})
    DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME,[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Account Manager],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Actual Close Date Time],[Opportunity].[Opportunity
    Hierarchy].[Opportunity].[Opportunity Age In Days],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Close Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Created On Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Created On Date Time],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Days In Sales Stage],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Delivery Owner],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated
    Close Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project Duration In Days],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project Duration In Months],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Estimated Project Duration In Working Days],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project End Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project First Working Day Date],[Opportunity].[Opportunity
    Hierarchy].[Opportunity].[Opportunity Estimated Project Last Working Day Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Estimated Project Start Date],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Latest News],[Opportunity].[Opportunity
    Hierarchy].[Opportunity].[Opportunity Latest News Updated On Date Time],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Lost Competitor],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Originating Lead Name],[Opportunity].[Opportunity
    Hierarchy].[Opportunity].[Opportunity Owning Organisation],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Revenue Spread],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Sales Assist],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Sales Assist-Hidden],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Sales Stage],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Sales Stage Updated On Date Time],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity
    Source Full Name],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity State],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Sub Source],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Updated On Date Time],[Opportunity].[Opportunity
    Hierarchy].[Opportunity].[Opportunity Won Lost Description],[Opportunity].[Opportunity Hierarchy].[Opportunity].[Opportunity Won Lost Reason] ON ROWS  FROM (SELECT ({[Opportunity].[Opportunity Hierarchy].[Opportunity].&[{B69F83EB-832D-E211-9861-00155D032A00}],
    [Opportunity].[Opportunity Hierarchy].[Opportunity].&[{60036FE8-DC48-E111-975F-00155D032A00}], [Opportunity].[Opportunity Hierarchy].[Opportunity].&[{3A2BB124-EE85-E011-8A06-00155D032A00}], [Opportunity].[Opportunity Hierarchy].[Opportunity].&[{E2E48CB7-8463-E411-831D-00155D035708}],
    [Opportunity].[Opportunity Hierarchy].[Opportunity].&[{140D9883-6F49-E011-AEA0-00155D032A00}]}) ON COLUMNS  FROM [IMGROUP]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
    Any help?
    sayan maity

  • Extracting the Logical sql query for the specified report  in OBIEE 11g

    Hi ,
    I want to extract the logical SQL Query for the Particular report in OBIEE 11.1.1.5.
    Any pointers related to this will be very helpful.
    Thanks,
    Sonali

    for a try please add Logical sql view to ur report it will dispaly the Logical sql for that Report..
    Hope it will helps you.

  • Excel Pivot Table with Date Hierarchies - query performance degradation

    For the sake of this explanation, I’m going to try and keep it simple. Slicing the data by additional dimensions only makes the issue worse. I’ll keep this description to one fact table and three dimensions. Also, I’m fairly new to SSAS Tabular; I’ve worked
    with SSAS Multidimensional in the past.
    We’ve got a fact table that keeps track of bill pay payments made over time. Currently, we only have about six months of data, with the fact row count at just under 900,000 rows. The grain is daily.
    There is an Account dimension (approx. 460,000 rows), with details about the individual making a payment.
    There is a Payment Category dimension (approx.. 35,000 rows), which essentially groups various Payees into groups which we like to report on: Automobile Loan, Mortgage, Insurance, etc.
    There is the requisite Date dimension  (exactly 62093 rows-more days than we need?), which allows visibility as to what is being paid when.
    Using this DW model, I’ve created a SSAS BISM Tabular model, from which Excel 2010 is ultimately used to perform some analysis, using Pivot Tables. In the tabular model, for easier navigation (doing what I’ve always done in SSAS MultiDimensional), I’ve created
    several Date Hierarchies, Year-Month, Year-Quarter-Month, etc.
    There are currently only two measures defined in the Tabular model: one for the “Sum of PaymentAmount”; one for the “PaymentsProcessed”.
    OK, in Excel 2010, using a Pivot Table, drag the “Sum of PaymentAmount” measure to the Values section, next to/under the PivotTable Field List. Not too exciting, just the grand total of all Payments, for all time.
    Drag the “YearMonth” hierarchy (from the Date dimension) to the “Column Labels” section. After expanding the year hierarchy to see the months, now the totals are for each of the months, for which we have data, for June through November, 2013.
    Drag the “PaymentCategory” (from the Payment Categories dimension) to the “Report Filter” section. Filter accordingly: We just want to see the monthly totals for “Automobile Loans”.
    Now, some details. Drag the “AccountSK” (hiding the actual account numbers) to the “Row Labels” section. This shows all accounts that have made Automobile Loan payments over the last six months, showing the actual payment amounts.
    So far, so good. Remember, I’m using a Date Hierarchy here, in this case “YearMonth”
    Now, if any of the other attributes on the Account dimension table, say “CreditScore”, or “LongName”, are subsequently dragged over to the “Row Lables” section, under the “AccountSK”, the results will never come back, before timing out or by giving up and
    pressing ESCape!
    If this exact scenario is done by removing the Date Hierarchy, “YearMonth” from the “Column Labels” and replace it with “Year” and “MonthName” attributes from the Date dimension, these fields not being in any sort of hierarchy, adding an additional “Account”
    attribute does not cause any substantial delay.
    What I’m trying to find out is why is this happening? Is there anything I can do as a work around, other than what I’ve done by not using a Date Hierarchy? Is this a known issue with DAX and the query conversion to MDX? Something else?
    I’ve done a SQL Profiler trace, but I’m not sure at this point what it all means. In the MDX query there is a CrossJoin involved. There are also numerous VertiPaq Scans which seems to be going through each and every AccountSK in the Account dimension, not
    just the ones filtered, to get an additional attribute (About 3,600 accounts which are “Automobile Loan” payments.).
    Any thoughts?
    Thanks! Happy Holidays!
    AAO

    Thanks for your reply Marco. I've been reading your book, too, getting into Tabular.
    I've set up the Excel Pivot Table using either the Year/MonthName levels, or the YearMonth hierarchy and then adding the additional attribute for the CreditScore.
    Incidentally, when using the YearMonth hierarchy and adding the CreditScore, all is well, if the Year has not been "opened". When this is done, I suspect the same thing is going on.
    From SQL Profiler, each of the individual MDX queries below (formatted a bit for readability).
    Thanks!
    // MDX query using separate Year and MonthName levels, NO hierarchy.
    SELECT 
    NON EMPTY 
    Hierarchize(
    DrilldownMember(
    CrossJoin(
    {[Date].[Year].[All],[Date].[Year].[Year].AllMembers}, 
    {([Date].[MonthName].[All])}
    ,[Date].[Year].[Year].AllMembers, [Date].[MonthName]
    DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME 
    ON COLUMNS, 
    NON EMPTY 
    Hierarchize(
    DrilldownMember(
    CrossJoin(
    {[Accounts].[AccountSK].[All],[Accounts].[AccountSK].[AccountSK].AllMembers}, 
    {([Accounts].[CreditScore].[All])}
    ,[Accounts].[AccountSK].[AccountSK].AllMembers, [Accounts].[CreditScore]
    DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME 
    ON ROWS  
    FROM [PscuPrototype] 
    WHERE ([PaymentCategories].[PaymentCategory].&[Automobile Loan],[Measures].[Sum of PaymentAmount]) 
    CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
    // MDX query using separate YearMonth hierarchy (Year, MonthName).
    SELECT 
    NON EMPTY 
    Hierarchize(
    DrilldownMember(
    {{DrilldownLevel({[Date].[YearMonth].[All]},,,INCLUDE_CALC_MEMBERS)}}, 
    {[Date].[YearMonth].[Year].&[2013]},,,INCLUDE_CALC_MEMBERS
    DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME 
    ON COLUMNS,
    NON EMPTY 
    Hierarchize(
    DrilldownMember(
    CrossJoin(
    {[Accounts].[AccountSK].[All],[Accounts].[AccountSK].[AccountSK].AllMembers}, 
    {([Accounts].[CreditScore].[All])}
    ,[Accounts].[AccountSK].[AccountSK].AllMembers, [Accounts].[CreditScore]
    DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME 
    ON ROWS  
    FROM [PscuPrototype] 
    WHERE ([PaymentCategories].[PaymentCategory].&[Automobile Loan],[Measures].[Sum of PaymentAmount]) 
    CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
    AAO

  • Oracle SQL Query from EXCEL 2007 with prompt

    Hello,
    I have many excel reports where I am pulling information from our Oracle 9 db through Excel using the following method:
    http://blog.mclaughlinsoftware.com/microsoft-excel/how-to-query-oracle-from-excel-2007/
    http://blog.mclaughlinsoftware.com/2009/11/30/sql-query-in-excel-2007/
    However, I am having trouble when I try the following query due to the prompt:
    SELECT
    IM.ITEM_GROUP,
    IM.ITEM,
    IM.DESCRIPTION
    FROM
    LAWSON.ITEMMAST IM
    WHERE
    IM.ITEM = '&ITEM';
    Does any one know how I can connect a prompt to an excel cell and then pass the query on to Oracle, or have a PL SQL prompt work from Excel?
    Thanks,
    Ben

    The 'prompt' as you call it is a sqlplus feature, so does not belong to the SQL language
    You would need to write a stored procedure returning a resultset.
    create or replace procedure foo(rc in out sys_refcursor, p_item) as
    begin
    open rc for
    'SELECT
    IM.ITEM_GROUP,
    IM.ITEM,
    IM.DESCRIPTION
    FROM
    LAWSON.ITEMMAST IM
    WHERE
    IM.ITEM = '||p_item;
    end;
    and call that using ODBC or asp.net
    Obviously this is profusely documented.
    Sybrand Bakker
    Senior Oracle DBA

  • Problem writing a sql query for a select list based on a static LOV

    Hi,
    I have the following table...
    VALIDATIONS
    ID          Number     (PK)
    APP_ID          Number     
    REQUESTED     Date          
    APPROVED     Date          
    VALID_TIL     Date
    DEPT_ID          Number     (FK)
    I have a search form with the following field item variables...
    P11_DEPT_ID (select list based on dynamic LOV from depts table)
    P11_VALID (select list based on static Yes/No LOV)
    A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
    SELECT v.APP_ID,
    v.REQUESTED,
    v.APPROVED,
    v.VALID_TIL,
    d.DEPT
    FROM DEPTS d, VALIDATIONS v
    WHERE d.DEPT_ID = v.DEPT_ID(+)
    AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
    This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
    Can anyone help me to extend my query to include this situation?
    Thanks.

    Hello !
    Let's have a look at my example:create table test
    id        number
    ,valid_til date
    insert into test values( 1, sysdate-3 );
    insert into test values( 2, sysdate-2 );
    insert into test values( 3, sysdate-1 );
    insert into test values( 4, sysdate );
    insert into test values( 5, sysdate+1 );
    insert into test values( 6, sysdate+2 );
    commit;
    select * from test;
    def til=yes
    select *
      from test
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);
    def til=no
    select *                                                                               
      from test                                                                            
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);  
    drop table test;  It's working fine, I've tested it.
    The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
    For understandings:
    1.) TRUNC removes the time part of DATE
    2.) The difference of to date-values is the number of days between.
    3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
    4.) DECODE is like an IF.
    Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
    Good luck,
    Heinz

  • SCCM 2012 All Updates report sql query

    Need build sql query for report about all MS Updates like SCCM configuration manager view in window by path:
    \Software Library\Overview\Software Updates\All Software Updates.
    But I can't find fields that can show "product" (OS that use this patch) and size of each patch in SCCM and WSUS databases. Can anybody help me?

    To get file size I create query for files in package:
    SELECT distinct ui.Title, ui.InfoURL, ui.DatePosted,
    cf.FileName, cast(cast(cf.FileSize as real)/1024/1024 as decimal(10,2)) as SizeMb, uds.AssignmentName, uds.StartTime
    FROM CI_ContentFiles cf
    INNER JOIN v_UpdateContents uc  ON cf.Content_ID  = uc.Content_ID
    INNER JOIN v_UpdateInfo ui ON uc.CI_ID = ui.CI_ID 
    INNER JOIN vSMS_UpdateDeploymentSummary uds  ON ui.CI_ID = uds.CI_ID
    join CI_ContentPackages cp on cf.Content_ID=cp.Content_ID
    join CI_Contents co on co.Content_ID = cp.Content_ID
    Where PkgID='MKL00032'
    order by ui.InfoURL

  • Excel Pivot Table within Email Body - Is there an ability for Recipients to manipulate table within email?

    Hello,
     Each morning, I paste an update to an Excel pivot table for an inner company report and circulate via Outlook email.  Is there any way for my recipients to be able to manipulate the table within the body of the Outlook email?  Or do they
    have to resort to the attached Excel file containing the original of the pivot table I've pasted into the email.
    Thank you.
    Eric Korslin

    Cant do.
    Only as file, opened from attachment.
    Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

  • Error while executing a sql query for select

    HI All,
    ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.

    I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
    1. I dont want to increase the temp space
    2. I need to tune the query, please provide your recomendations.
    insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
    (REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
    select
    REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
    carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
    carrier_item_type,carried_item_protection_type,'PACS'
    from
    (select distinct
    c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
    a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
    a.carrier_item_type,a.carried_item_protection_type,'PACS'
    from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
    where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
    AND a.carrier_items=b.mux
    and c.REPORTNUMBER=(case
    when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
    else 20
    end)
    and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
    where not exists
    (select *
    from CST_DSA.HIERARCHY_MISMATCHES B where
    A.REPORTNUMBER=B.REPORT_NUM and
    A.REPORTTYPE=B.REPORT_TYPE and
    A.REPORTDESCRIPTION=B.REPORT_DESC and
    A.CARRIED_ITEMS=B.CARRIED_ITEMS and
    A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
    A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
    A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
    A.CARRIER_ITEMS=B.CARRIER_ITEMS and
    A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
    A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
    AND B.SOURCE_SYSTEM='PACS'
    Explain Plan
    ==========
    Plan
    INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1                                                        
         20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES                                                   
              19 PX COORDINATOR                                              
                   18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                         
                        17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                    
                             15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1                               
                                  4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621                          
                                       3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                     
                                            2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                
                                                 1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621           
                                  14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448                          
                                       11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448                     
                                            8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002               
                                                 7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2           
                                                      6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2      
                                                           5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
                                            10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448                
                                                 9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448           
                                       13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1                     
                                            12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1                
                             16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1

  • Oracle SQL query for getting specific special characters from a table

    Hi all,
    This is my table
    Table Name- Table1
    S.no    Name
    1          aaaaaaaa
    2          a1234sgjghb
    3          a@3$%jkhkjn
    4          abcd-dfghjik
    5          bbvxzckvbzxcv&^%#
    6          ashgweqfg/gfjwgefj////
    7          sdsaf$([]:'
    8          <-fdsjgbdfsg
    9           dfgfdgfd"uodf
    10         aaaa  bbbbz#$
    11         cccc dddd-/mnm
    The output has to be
    S.no    Name
    3          a@3$%jkhkjn
    5          bbvxzckvbzxcv&^%#
    7          sdsaf$([]:'
    8          <-fdsjgbdfsg
    10         aaaa  bbbbz#$
    It has to return "Name" column which is having special characters,whereas some special chars like -, / ," and space are acceptable.
    The Oracle query has to print columns having special characters excluding -,/," and space
    Can anyone help me to get a SQL query for the above.
    Thanks in advance.

    You can achieve it in multiple ways. Here are few.
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'aaaaaaaa' name from dual union all
      5  select 2 id, 'a1234sgjghb' name from dual union all
      6  select 3 id, 'a@3$%jkhkjn' name from dual union all
      7  select 4 id, 'abcd-dfghjik' name from dual union all
      8  select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
      9  select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
    10  select 7 id, 'sdsaf$([]:''' name from dual union all
    11  select 8 id, '<-fdsjgbdfsg' name from dual union all
    12  select 9 id, 'dfgfdgfd"uodf' name from dual union all
    13  select 10 id, 'aaaa  bbbbz#$' name from dual union all
    14  select 11 id, 'cccc dddd-/mnm' name from dual
    15  )
    16  select *
    17    from t
    18   where regexp_like(translate(name,'a-/" ','a'), '[^[:alnum:]]');
            ID NAME
             3 a@3$%jkhkjn
             5 bbvxzckvbzxcv&^%#
             7 sdsaf$([]:'
             8 <-fdsjgbdfsg
            10 aaaa  bbbbz#$
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'aaaaaaaa' name from dual union all
      5  select 2 id, 'a1234sgjghb' name from dual union all
      6  select 3 id, 'a@3$%jkhkjn' name from dual union all
      7  select 4 id, 'abcd-dfghjik' name from dual union all
      8  select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
      9  select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
    10  select 7 id, 'sdsaf$([]:''' name from dual union all
    11  select 8 id, '<-fdsjgbdfsg' name from dual union all
    12  select 9 id, 'dfgfdgfd"uodf' name from dual union all
    13  select 10 id, 'aaaa  bbbbz#$' name from dual union all
    14  select 11 id, 'cccc dddd-/mnm' name from dual
    15  )
    16  select *
    17    from t
    18   where translate
    19         (
    20            lower(translate(name,'a-/" ','a'))
    21          , '.0123456789abcdefghijklmnopqrstuvwxyz'
    22          , '.'
    23         ) is not null;
            ID NAME
             3 a@3$%jkhkjn
             5 bbvxzckvbzxcv&^%#
             7 sdsaf$([]:'
             8 <-fdsjgbdfsg
            10 aaaa  bbbbz#$
    SQL>

  • Create dynamic report or query for piece count

    Hi abaper's
    This is a very straight forward requirement. so please give me code
    First you have to get the corresponding plant from table T320 for the given warehouse numbers in the selection screen. 
    1.     Get the sum of order qty of sales orders from the sales order tables      for the given warehouse(Plant), distribution channel and the give date      range.
    2.     Get the confirmed transfer orders qty from the TO master table where      TO confirmation date is in the given date range and WH number.
    3.     Get the total PGIed qty from the delivery master table where PGI'ed      date in the given date range, shipping point is in the corresponding      plant of the WH and for the given distribution channel.
    As you are going to use the major tables please try to write the select commands effectively to avoid further performance issues.

    How to improve the performance fo this code.....this very urgent.
    & Issue Number          : 22199                                    &
    & Programmer            : Anjaneyulu.Pabba                         &
    & Transport Number      : D01K962471                               &
    & Date of Creation      : 19/03/2008                               &
    & Description           : Dynamic report or query for piece count  &
    & Requested By          : Parvati.Polisetty                        &
    REPORT  ZR_SD_PIECE_COUNT_ALV no standard page heading
                                  line-size 255
                                  line-count 65.
                          TABLES DECLARATION
    *TABLES: T320,   "Assignment IM Storage Location to WM Warehouse Number
          VBAK,   "Sales Document: Header Data
          VBAP,   "Sales Document: Item Data
          TVKOV,  "Org. Unit: Distribution Channels per Sales Organization
          LTAK,   "WM transfer order header
          LTAP,   "Transfer order item
          LIKP,   "SD Document: Delivery Header Data
          LIPS.   "SD document: Delivery: Item data
                          TYPE-POOLS DECLARATION
    TYPE-POOLS: SLIS .
         Internal Table Declaration
    DATA : BEGIN OF TY_T320,
            WERKS TYPE WERKS_D,
            LGNUM TYPE LGNUM,
           END OF TY_T320.
    DATA : BEGIN OF TY_VBAK,
            VBELN  TYPE VBELN_VA,
            VTWEG  TYPE VTWEG,
            WERKS  TYPE WERKS_D,
            KWMENG TYPE KWMENG,
            VSTEL  TYPE VSTEL,
           END OF TY_VBAK.
    DATA : BEGIN OF TY_LTAK,
            LGNUM TYPE LGNUM,
            TANUM TYPE TANUM,
            VISTA TYPE LTAP_VISTA,
           END OF TY_LTAK.
    DATA : BEGIN OF TY_LIKP,
            VBELN TYPE VBELN_VL,
            WERKS TYPE WERKS_D,
            LFIMG TYPE LFIMG,
           END OF TY_LIKP.
    DATA : BEGIN OF TY_ITAB ,
    LGNUM  TYPE LGNUM,    "Warehouse Number / Warehouse Complex
    WERKS  TYPE WERKS_D,  "Plant
    VBELN  TYPE VBELN_VA, "Sales Document
    VTWEG  TYPE VTWEG,   "Distribution Channel
    KWMENG TYPE KWMENG,  "Cumulative order quantity in sales units
    TANUM  TYPE TANUM ,     "Transfer Order Number
    VISTA  TYPE LTAP_VISTA, "Source actual quantity in alternative
                                                 unit of measure
    LFIMG  TYPE LFIMG,  "Actual quantity delivered (in sales units)
    END OF TY_ITAB .
    DATA: T_T320 LIKE STANDARD TABLE OF TY_T320 INITIAL SIZE 0 WITH HEADER
                                                                   LINE,
          T_VBAK LIKE STANDARD TABLE OF TY_VBAK INITIAL SIZE 0 .
    DATA: T_LTAK LIKE STANDARD TABLE OF TY_LTAK INITIAL SIZE 0 WITH HEADER
                                                                    LINE.
    DATA :T_LIKP LIKE STANDARD TABLE OF TY_LIKP INITIAL SIZE 0 WITH HEADER
                                                                    LINE.
    DATA:T_ITAB LIKE STANDARD TABLE OF TY_ITAB INITIAL SIZE 0 WITH HEADER
                                                                   LINE .
    *&      Fieldcatalog Declaration
    DATA : T_FCAT TYPE SLIS_T_FIELDCAT_ALV,
           W_FCAT TYPE SLIS_FIELDCAT_ALV.
    DATA : W_LAYOUT TYPE SLIS_LAYOUT_ALV.
    ********Global Data Declaration***
    DATA :G_REPID        LIKE SY-REPID,
         G_EXIT(1)      TYPE C,
         GX_VARIANT     LIKE DISVARIANT,
         X_SAVE,                          "for Parameter I_SAVE
         GS_VARIANT TYPE DISVARIANT.      "for parameter IS_VARIANT
    data: g_lgnum type t320-lgnum,
          g_vtweg type vbak-vtweg,
          g_erdat type vbak-erdat.
    *&      Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_LGNUM FOR  g_lgnum, "Warehouse Number
                    S_VTWEG FOR g_vtweg, "Distribution Channel
                    S_ERDAT FOR g_erdat ."Date on which the record was
    **********"created
    SELECTION-SCREEN END OF BLOCK B1 .
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETER: P_VARI LIKE DISVARIANT-VARIANT.  "Layout
    SELECTION-SCREEN END OF BLOCK B2.
    *&       INITIALIZATION EVENT
    INITIALIZATION.
      CLEAR GS_VARIANT.
    'gs_variant' must at least contain the report-id to allow
    saving a variant.
      G_REPID = SY-REPID.
    § 2.At least field REPORT of this structure has to be filled!
      GS_VARIANT-REPORT = G_REPID.
    § 3.Determine saving options.
      X_SAVE = 'A'.   "The user may save all types of variants
    *******Validating selection-screen values**********************
    getting F4 value for display variant field
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
      PERFORM F4_FOR_VARIANT.
    ****validation of F4 value of display variant
    AT SELECTION-SCREEN.
      PERFORM PAI_OF_SELECTION_SCREEN.
    *&      Start-Of-Selection
    START-OF-SELECTION.
    *****Subroutine to  select Plant from T320
      PERFORM FIND_PLANT .
    *****Subroutine to select Order Quantity from VBAP
      PERFORM ORDER_QUANTITY .
    *****Subroutine to select Transfer Order Quantity from LTAK and LTAP
      PERFORM TRANSFER_ORDER_QUANTITY.
    *****Subroutine to select TDelivery Quantity from  LIKP and LIPS
      PERFORM DELIVERY_QUANTITY.
    *&      End-Of-Selection
    END-OF-SELECTION.
    *****Subroutine for Fieldcatalog
      PERFORM FIELDCATALOG .
    *****Subroutine for Final Output
      PERFORM DISPLAY_OUTPUT .
    *&     Subroutine Implementaion
    *&      Form  FIND_PLANT
          text
    -->  p1        text
    <--  p2        text
    FORM FIND_PLANT .
      SELECT  WERKS
              LGNUM
              FROM T320
              INTO  TABLE T_T320
              WHERE LGNUM IN S_LGNUM.
    ENDFORM.                    " FIND_PLANT
    *&      Form  order_quantity
          text
    -->  p1        text
    <--  p2        text
    FORM ORDER_QUANTITY .
      SELECT VK~VBELN
             VK~VTWEG
             VP~WERKS
             VP~KWMENG
             VP~VSTEL
             INTO TABLE T_VBAK FROM VBAK AS VK
             INNER JOIN  VBAP AS VP
             ON VKVBELN = VPVBELN
             FOR ALL ENTRIES IN T_T320
             WHERE VK~VTWEG IN S_VTWEG
             AND   VK~ERDAT IN S_ERDAT
             AND   VP~WERKS = T_T320-WERKS.
    ENDFORM.                    " order_quantity
    *&      Form  Transfer_order_quantity
          text
    -->  p1        text
    <--  p2        text
    FORM TRANSFER_ORDER_QUANTITY .
      SELECT LK~LGNUM
             LK~TANUM
             LP~VISTA
             INTO TABLE T_LTAK FROM LTAK AS LK
             INNER JOIN LTAP AS LP
             ON LKLGNUM = LPLGNUM
             WHERE LK~KQUIT = 'X'
             AND   LK~BDATU IN S_ERDAT
             AND   LK~LGNUM IN S_LGNUM.
    ENDFORM.                    " Transfer_order_quantity
    *&      Form  Delivery_QUANTITY
          text
    -->  p1        text
    <--  p2        text
    FORM DELIVERY_QUANTITY .
      SELECT  VBELN WERKS LFIMG FROM LIPS
              INTO TABLE T_LIKP
              FOR ALL ENTRIES IN T_T320
              WHERE WERKS = T_T320-WERKS
              AND ERDAT IN S_ERDAT
              AND VTWEG IN S_VTWEG.
    ENDFORM.                    " Delivery_QUANTITY
    *&      Form  fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCATALOG .
      W_FCAT-COL_POS       = '1' .
      W_FCAT-FIELDNAME     = 'LGNUM' .
      W_FCAT-REF_TABNAME   = 'T320'.
      W_FCAT-REF_FIELDNAME = 'LGNUM' .
      APPEND W_FCAT TO T_FCAT.
      CLEAR W_FCAT.
      W_FCAT-COL_POS       = '2' .
      W_FCAT-FIELDNAME     = 'VTWEG' .
      W_FCAT-REF_TABNAME   = 'VBAK'.
      W_FCAT-REF_FIELDNAME = 'VTWEG' .
      APPEND W_FCAT TO T_FCAT.
      CLEAR W_FCAT.
      W_FCAT-COL_POS       = '3' .
      W_FCAT-FIELDNAME     = 'KWMENG' .
      W_FCAT-REF_TABNAME   = 'VBAP'.
      W_FCAT-REF_FIELDNAME = 'KWMENG' .
    *w_fcat-seltext_m     = '# of Orders'.
      APPEND W_FCAT TO T_FCAT.
      CLEAR W_FCAT.
      W_FCAT-COL_POS       = '4' .
      W_FCAT-FIELDNAME     = 'VISTA' .
      W_FCAT-REF_TABNAME   = 'LTAP'.
      W_FCAT-REF_FIELDNAME = 'VISTA' .
    *w_fcat-seltext_m     = '# of Pcs Picked'.
      APPEND W_FCAT TO T_FCAT.
      CLEAR W_FCAT.
      W_FCAT-COL_POS       = '5' .
      W_FCAT-FIELDNAME     = 'LFIMG' .
      W_FCAT-REF_TABNAME   = 'LIPS'.
      W_FCAT-REF_FIELDNAME = 'LFIMG' .
    *w_fcat-seltext_m     = '# of Pcs Shipped'.
      APPEND W_FCAT TO T_FCAT.
      CLEAR W_FCAT.
    W_FCAT-COL_POS       = '6' .
    W_FCAT-FIELDNAME     = 'TANUM' .
    W_FCAT-REF_TABNAME   = 'LTAK'.
    W_FCAT-REF_FIELDNAME = 'TANUM' .
    **w_fcat-seltext_m     = '# of Pcs Shipped'.
    APPEND W_FCAT TO T_FCAT.
    CLEAR W_FCAT.
    W_FCAT-COL_POS       = '7' .
    W_FCAT-FIELDNAME     = 'WERKS' .
    W_FCAT-REF_TABNAME   = 'T320'.
    W_FCAT-REF_FIELDNAME = 'WERKS' .
    **w_fcat-seltext_m     = '# of Pcs Shipped'.
    APPEND W_FCAT TO T_FCAT.
    CLEAR W_FCAT.
    ENDFORM.                    " fieldcatalog
    *&      Form  display_output
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_OUTPUT .
      LOOP AT T_T320 INTO TY_T320.
        TY_ITAB-WERKS = TY_T320-WERKS.
        TY_ITAB-LGNUM = TY_T320-LGNUM.
        READ TABLE T_VBAK INTO TY_VBAK WITH KEY WERKS = TY_T320-WERKS.
        IF SY-SUBRC = 0.
        TY_ITAB-VBELN  = TY_VBAK-VBELN.
        TY_ITAB-VTWEG  = TY_VBAK-VTWEG.
        TY_ITAB-KWMENG = TY_VBAK-KWMENG + ty_itab-kwmeng.
        ENDIF.
        READ TABLE T_LTAK INTO TY_LTAK WITH KEY LGNUM = TY_T320-LGNUM.
        IF SY-SUBRC = 0.
        TY_ITAB-TANUM = TY_LTAK-TANUM.
        TY_ITAB-VISTA = TY_LTAK-VISTA + ty_itab-vista.
        ENDIF.
        READ TABLE T_LIKP INTO TY_LIKP WITH KEY WERKS = TY_T320-WERKS.
        IF SY-SUBRC = 0.
        TY_ITAB-LFIMG = TY_LIKP-LFIMG + ty_itab-lfimg.
        ENDIF.
        APPEND TY_ITAB TO T_ITAB.
      ENDLOOP.
    Function Module for Displaying Final Output ********
      W_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = SY-CPROG
          IS_LAYOUT          = W_LAYOUT
          IT_FIELDCAT        = T_FCAT[]
        TABLES
          T_OUTTAB           = T_ITAB.
    ENDFORM.                    " display_output
    *&      Form  f4_for_variant
          text
    -->  p1        text
    <--  p2        text
    FORM F4_FOR_VARIANT .
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          IS_VARIANT = GS_VARIANT
          I_SAVE     = X_SAVE
        IMPORTING
          E_EXIT     = G_EXIT
          ES_VARIANT = GX_VARIANT
        EXCEPTIONS
          NOT_FOUND  = 2.
      IF SY-SUBRC = 2.
        MESSAGE ID SY-MSGID TYPE 'S'      NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        IF G_EXIT = SPACE.
          P_VARI = GX_VARIANT-VARIANT.
        ENDIF.
      ENDIF.
    ENDFORM.                    " f4_for_variant
    *&      Form  pai_of_selection_screen
          text
    -->  p1        text
    <--  p2        text
    FORM PAI_OF_SELECTION_SCREEN .
      IF NOT P_VARI IS INITIAL.
        MOVE GS_VARIANT TO GX_VARIANT.
        MOVE P_VARI TO GX_VARIANT-VARIANT.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
          EXPORTING
            I_SAVE     = X_SAVE
          CHANGING
            CS_VARIANT = GX_VARIANT.
        GS_VARIANT = GX_VARIANT.
      ELSE.
        PERFORM VARIANT_INIT.
      ENDIF.
    ENDFORM.                    " pai_of_selection_screen
    *&      Form  variant_init
          text
    -->  p1        text
    <--  p2        text
    FORM VARIANT_INIT .
      CLEAR GS_VARIANT.
      GS_VARIANT-REPORT = G_REPID.
    ENDFORM.                    " variant_init

  • How to create sql query for item master with operator LIKE with variables?

    hi all,
    How to create sql query for item master with
    operator LIKE(Contains,Start With,End With) with variables using query generator in SAP B1 ?
    Jeyakanthan

    Hi Jeyakanthan,
    here is an example (put the like statement into the where field)
    SELECT T0.CardCode, T0.CardName FROM OITM T0 WHERE T0.CardName Like '%%test%%'
    The %% sign is a wildcard. If you need start with write 'test%%' and otherwise ends with '%%test'. For contains you need '%%test%%'. You also could combinate this statements like 'test%%abc%%'. This means starts with test and contains abc.
    Regards Steffen

  • How to write sql query for counting pairs from below table??

    Below is my SQL table structure.
    user_id | Name | join_side | left_leg | right_leg | Parent_id
    100001 Tinku Left 100002 100003 0
    100002 Harish Left 100004 100005 100001
    100003 Gorav Right 100006 100007 100001
    100004 Prince Left 100008 NULL 100002
    100005 Ajay Right NULL NULL 100002
    100006 Simran Left NULL NULL 100003
    100007 Raman Right NULL NULL 100003
    100008 Vijay Left NULL NULL 100004
    It is a binary table structure.. Every user has to add two per id under him, one is left_leg and second is right_leg... Parent_id is under which user current user is added.. Hope you will be understand..
    I have to write sql query for counting pairs under id "100001". i know there will be important role of parent_id for counting pairs. * what is pair( suppose if any user contains  both left_leg and right_leg id, then it is called pair.)
    I know there are three pairs under id "100001" :-
    1.  100002 and 100003
    2.  100004 and 100005
    3.  100006 and 100007
        100008 will not be counted as pair because it does not have right leg..
     But i dont know how to write sql query for this... Any help will be appreciated... This is my college project... And tommorow is the last date of submission.... Hope anyone will help me...
    Suppose i have to count pair for id '100002'. Then there is only one pair under id '100002'. i.e 100004 and 100005

    Sounds like this to me
    DECLARE @ID int
    SET @ID = 100001--your passed value
    SELECT left_leg,right_leg
    FROM table
    WHERE (user_id = @ID
    OR parent_id = @ID)
    AND left_leg IS NOT NULL
    AND right_leg IS NOT NULL
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to write sql query for below example.

    Hi,
    I have requirement.
    There are number of rows and I need the result through query as follows.Please help me to proved sql query for below mentioned requirement.
    example: table TEST.
    COLA COLB COLC COLD
    MANAGER 5 NULL null
    SR.MANAGE 6 3 NULL
    VP 5 5 4
    I have to write the sql query if COLA IS MANAGER THEN CONSIDER MANGER RECORD,AND IF ANY COLUMN FILED IS NULL FOR MANGER THEN CONSIDER COLA IS SR.MANGER, AND IF ANY COLUMN FILED IS NULL FOR SR,MANGER THEN CONSIDER VP records.
    I need output as below.
    COLB COLC COLD
    5(MANGER) 3(sr.manger) 5(vp)
    Please provide the for above mentioned output.
    Thanks

    <<if COLA IS MANAGER THEN CONSIDER MANGER RECORD>>
    What does this sentence means? COLA does not cnatin a single record but the number of records with diffrent values.
    Regards
    Arun

Maybe you are looking for

  • The ITunes application could not be opened.  an unknown error 50 occurred

    I have a new Sony Vaio computer (64 bit) with Windows 7 Professional SP1. I have downloaded, installled, uninstalled and reinstalled itunes three different occassions.  I've disabled Firewall and antivirus software but nothing is working.  Please hel

  • How to bind a column name in PL/SQL

    i have this code in a transaction report. DECLARE q VARCHAR2 (1000); t VARCHAR2 (15); BEGIN t := '11110000'; q := q || 'select STARTDATE, PHONESOURCE, PHONETO, DURATION '; q := q || 'from TRANSACTION '; q := q || 'where TRANS_ID = ' ||t|| 'and STARTD

  • Change Location of Database at Runtime for Report based on a Command

    Post Author: srr CA Forum: Crystal Reports I am using Crystal Reports Developer XI 11.5.8.826 - My database is MS Access 2003 I have created a report definition that is based on a query of multiple tables in the database, which is saved in Crystal Re

  • Net value calculation in returns

    Hi Experts, Scenario. Line Item 10 - M1- TAN - 10 -  Rs. 1000.00                 11-  M1- TANN- 5 - Rs. 0.00 This means i am offering 50% discount. If i take returns of 10 items then i need to issue credit memo for Rs. 500. System need not check free

  • Broadcasting issue

    Hi all, We are having a scenario where user will get some error reports through broadcasting once in a week. Last week, the same error report is going to the users multiple times. Is there any way to restrict the report to be sent only once to the us