Inner Join Subquery data display

I have a query that uses a sub query on a INNER JOIN 
SELECT  SUM(A.qtyord), A.Item, A.Description, A.Class, B.Forecast, 
                CASE 
                        WHEN B.Forcast = 0
                THEN A.Item 
                ELSE 
                        CASE 
                        WHEN (SUM(A.ORDQ)/B.Forcase) > 0.20  
                        THEN A.Item 
                        ELSE '' 
                    END  
                END AS SKU
            FROM        tableA A
        INNER JOIN ((SELECT Item, ( SUM(BBAL) + SUM(RECV) + SUM(ADJU) - SUM(ALOC)) as onhand FROM tableD GROUP BY Item)) D ON A.Item = D.Item
        INNER JOIN tableB B ON A.Item=B.Item
        INNER JOIN tableC C ON B.Item=C.Item
    GROUP BY A.Item, A.Description, A.Class, B.Forecast
    ORDER BY A.Class DESC
How do I get the data from the sub query to display.

Hello,
Please check whether the following statement meet your requirment:
;With cte as
SELECT Item, ( SUM(BBAL) + SUM(RECV) + SUM(ADJU) - SUM(ALOC)) as onhand
FROM tableD GROUP BY Item)
SELECT SUM(A.qtyord), A.Item, A.Description, A.Class, B.Forecast, cte.onhand,
CASE
WHEN B.Forcast = 0
THEN A.Item
ELSE
CASE
WHEN (SUM(A.ORDQ)/B.Forcase) > 0.20
THEN A.Item
ELSE ''
END
END AS SKU
FROM tableA A
INNER JOIN cte ON A.Item = cte.Item
INNER JOIN tableB B ON A.Item=B.Item
INNER JOIN tableC C ON B.Item=C.Item
GROUP BY A.Item, A.Description, A.Class, B.Forecast
ORDER BY A.Class DESC
Regards,
Fanny Liu
If you have any feedback on our support, please click here.
Fanny Liu
TechNet Community Support

Similar Messages

  • Inner join with data also from non having join column

    I have an Dim table which has to be joined with Fact Table using inner join, but also display the Dimension value " MasterGroup " inspite of data present or not in the fact table.
    My Query:  .. This is an part of my stored procedure with more tables
    SELECT a.SalesAmount, b.HeaderGroup ,c.CityName
    FROM dbo.FactItem a
    inner join dbo.[DimHeader] b
    on a.sid = b.sid
    left join dbo.DimCity c
    on a.cityid = c.id
    My DimHeader Table will have data like
    MasterGroup
    ChildGroup
    etc...
    which is an attribute.
    There might not be any relevent fact data, but still i want the dimension data to display the "MasterGroup"
    ShanmugaRaj

    hello ,
    usually this is not possible when the column you want to display when the matches not found from a table having a distinct values which are hard to declared static..
    you can incorporate something like this if you cant change the join type ..
    select distinct HeaderGroup from dbo.[DimHeader] tbl_outerleft join (SELECT a.sid,a.SalesAmount, b.HeaderGroup ,c.CityName
    FROM dbo.FactItem a
    inner join dbo.[DimHeader] b
    on a.sid = b.sid
    left join dbo.DimCity c
    on a.cityid = c.id) tbl_Main on tbl_Main.sid =tbl_outer.sid
    Dilip Patil..

  • Retriveial of data based on inner joins

    I have Five tables (Subject,English,Hindi,Maths,Science,Social)
    where Subject is the Primary table and rest all lookup table For Subject
    My select Statement need to display all chapter names Based on the ID's in subject table
    SELECT English.ChapterName AS English, Hindi.ChapterName AS Hindi, Maths.ChapterName AS Maths, Social.ChapterName AS Social,
    Science.ChapterName AS Science
    FROM Subjects INNER JOIN
    English ON Subjects.English = English.ChapterNo INNER JOIN
    Hindi ON Subjects.Hindi = Hindi.ChapterNo INNER JOIN
    Maths ON Subjects.Maths = Maths.ChapterNo INNER JOIN
    Science ON Subjects.Science = Science.ChapterNo INNER JOIN
    Social ON Subjects.Social = Social.ChapterNo
    WHERE (Subjects.SubjectID = 1)
    If it's SubjectID 1 we can get the result set as complete data is populated What about SubjectID 3and 4 as some value's are null
    How can I retrive the output for them
    Sample Data
    Create table English (ChapterNo int,ChapterName varchar(50))
    Insert into English values (1,'English1')
    Insert into English values (2,'English2')
    Insert into English values (3,'English3')
    Insert into English values (4,'English4')
    Insert into English values (5,'English5')
    Insert into English values (6,'English6')
    Create table Maths (ChapterNo int,ChapterName varchar(50))
    Insert into Maths values (1,'Maths1')
    Insert into Maths values (2,'Maths2')
    Insert into Maths values (3,'Maths3')
    Insert into Maths values (4,'Maths4')
    Insert into Maths values (5,'Maths5')
    Insert into Maths values (6,'Maths6')
    Create table Hindi (ChapterNo int,ChapterName varchar(50))
    Insert into Hindi values (1,'Hindi1')
    Insert into Hindi values (2,'Hindi2')
    Insert into Hindi values (3,'Hindi3')
    Insert into Hindi values (4,'Hindi4')
    Insert into Hindi values (5,'Hindi5')
    Insert into Hindi values (6,'Hindi6')
    Create table Science (ChapterNo int,ChapterName varchar(50))
    Insert into Science values (1,'Science1')
    Insert into Science values (2,'Science2')
    Insert into Science values (3,'Science3')
    Insert into Science values (4,'Science4')
    Insert into Science values (5,'Science5')
    Insert into Science values (6,'Science6')
    Create table Social (ChapterNo int,ChapterName varchar(50))
    Insert into Social values (1,'Social1')
    Insert into Social values (2,'Social2')
    Insert into Social values (3,'Social3')
    Insert into Social values (4,'Social4')
    Insert into Social values (5,'Social5')
    Insert into Social values (6,'Social6')
    Create Table Subjects (SubjectID int,English int,Maths int ,Hindi int ,Science int,Social int )
    Insert into Subjects (SubjectID,English,Maths,Hindi,Science,Social) values (1,1,1,1,1,1)
    Insert into Subjects (SubjectID,English,Maths,Hindi,Science,Social) values (2,1,2,3,2,4)
    Insert into Subjects (SubjectID,English,Maths) values (3,1,2)
    Insert into Subjects (SubjectID,English,Social) values (2,1,4)
    Insert into Subjects (SubjectID,English,Maths,Social) values (2,1,3,4)
    Insert into Subjects (SubjectID,English,Maths,Hindi,Science) values (2,1,2,3,2)

    I have Tried Using Inner joins other than this i donot find any other way of doing this .If I insert Default values in all the tables it works and my Lead wont agree.
    There Should Be Some way I hope which i am not able to figure it out .
    I hope someone must have faced this problem and they can definitely work it out

  • SUBQUERY with INNER JOIN in ABAP

    Hi Expert
    How Can I write SUBQUERY with INNER JOIN in ABAP.
    thanks

    Thanks Sidhharth for your Respose
    Actually I need data from VBAP, VBAK, VBUP, VBUK and VBKD with all functional validation satisfied for a sales order item data. The requirement is to report all item data with other information from table VBAK, VBUP, VBUK and VBKD in a corresponding record with ALL data in VBAP.
    Your help is appriciated.
    see the below query for reference
    select   alias_vbap~vbeln from  vbap as
    alias_vbap inner join vbak as alias_vbak
    on  alias_vbapvbeln eq  alias_vbakvbeln
    "and  alias_vbak~bukrs_vf eq '2400'
    inner join vbuk as alias_vbuk
    on alias_vbukvbeln = alias_vbapvbeln
    inner join vbup as alias_vbup
    on alias_vbupvbeln = alias_vbapvbeln
    and alias_vbupposnr = alias_vbapposnr
    left OUTER join veda as alias_veda
    on alias_vedavbeln = alias_vbapvbeln
    and alias_vedavposn = alias_vbapposnr
    left outer join vbkd as alias_vbkd
    on alias_vbkdvbeln = alias_vbapvbeln
    and alias_vbkdposnr = alias_vbapposnr

  • Data is not fetching in inner join

    Hi Experts,
    I developed a select query using inner joins, all the fields data is gettting appended, but one field DISPO data is not getting appeneded. please check the innerjoin and suggest me ur soluitons.
    MODULE GET_DATA OUTPUT.
      select   arbpl
             sptag
             aufnr
             plnum
             posnr
             plnfl
             werks  from s022
                        into table it_s022
                         where arbpl in s_arbpl
                          and  werks in s_werks
                          and  sptag in s_sptag
                          and  matnr in s_matnr.
    if sy-subrc eq 0.
    select a~aufnr
           a~posnr
           a~kdauf
           a~pgmng
           a~plnum
           a~strmp
           b~plnty
           b~gamng
           b~igmng
           b~iasmg
           b~rmnga
           b~gstrp
           b~rsnum
           b~plnbez
           b~dispo
           c~maktx
           b~plnnr
           b~plnty
           b~zaehl
           d~vornr
           d~ltxa1
           b~aufpl
           b~aplzt
           e~astnr
           into corresponding fields of table it_afpo from  afko as b
                    inner join afpo as  a
                     on a~aufnr = b~aufnr
                    inner join makt as c
                     on b~plnbez = c~matnr
                    inner join plpo as d
                     on b~plnnr  = d~plnnr
                      and b~plnty = d~plnty
                      and b~zaehl  = d~zaehl
                     inner join aufk as e
                      on b~aufnr = e~aufnr
                    inner join marc as f
                     on bplnty = fmatnr
                    for all entries in it_s022
                     where b~aufnr = it_s022-aufnr.
                         and e~erdat = it_s022-sptag
                     and  a~posnr = it_s022-posnr
                    and  a~plnum = it_s022-plnum .  .
      if sy-subrc eq 0.
        it_afpo1[] = it_afpo[].
        sort it_afpo1 by aufpl." aplzt."""
        delete ADJACENT DUPLICATES FROM it_afpo1 COMPARING aufpl." aplzt ."""
        select aufpl
               aplzl
               fsavd
               fsavz
               ssedd
               ssedz
               mgvrg
                FROM  afvv  INTO TABLE It_afvv
                               FOR ALL ENTRIES IN IT_afpo1
                               WHERE aufpl = IT_afpo1-aufpl.
                                and aplzl = it_afpo1-aplzt.
       endif.
    loop at it_afpo into wa_afpo.
    DATA : G_SLNO(8) TYPE C.
    G_SLNO = G_SLNO + 1.
    wa_afpo-slno = g_slno.
        move-corresponding wa_afpo to wa_final.
       move-corresponding wa_afko to wa_final.
      read table it_afvv into wa_afvv with key
                aufpl = wa_afpo-aufpl binary search."aplzl = wa_afpo-aplzt binary search."""
    *read table it_afko into wa_afko with key aufnr = wa_final-aufnr.
      IF SY-SUBRC EQ 0.
        move-corresponding wa_afvv to wa_final.
    bal_qty = wa_final-gamng - wa_final-igmng.
        move : wa_afpo-slno  to wa_final-slno,
               wa_afpo-aufnr to wa_final-aufnr,
               wa_afpo-posnr to wa_final-posnr,
               wa_afpo-kdauf to wa_final-kdauf, " Sales order Number
               wa_afpo-pgmng to wa_final-pgmng, " Order item qty
               wa_afpo-plnum to wa_final-plnum, " Planned  Order Qty
               wa_afpo-strmp to wa_final-strmp, " Planned Order Date
               wa_afpo-gstrp to wa_final-gstrp, " Basic Finish  date
               wa_afpo-rsnum to wa_final-rsnum, " Number of Reservation
               wa_afpo-plnbez to wa_final-plnbez, " Material Number
               wa_afpo-maktx to wa_final-maktx,
               wa_afpo-plnnr to wa_final-plnnr,
               wa_afpo-plnty to wa_final-plnty,
               wa_afpo-zaehl to wa_final-zaehl,
               wa_afpo-vornr to wa_final-vornr,
               wa_afpo-ltxa1 to wa_final-ltxa1,
               wa_afpo-aufpl to wa_final-aufpl,
               wa_afvv-fsavd to wa_final-fsavd,
               wa_afvv-fsavz to wa_final-fsavz,
               wa_afvv-ssedd to wa_final-ssedd,
               wa_afvv-ssedz to wa_final-ssedz,
               wa_afvv-mgvrg to wa_final-mgvrg,
               wa_afko-igmng to wa_final-igmng,
               wa_afko-iasmg to wa_final-iasmg,
               wa_afko-rmnga to wa_final-rmnga,
               wa_afko-dispo to wa_final-dispo,
              wa_afko-bal_qty to wa_final-bal_qty,
               wa_aufk-astnr to wa_final-astnr,
               wa_afpo-text  to wa_final-text.
    *bal_qty = wa_final-gamng - wa_final-igmng.
    *bal_qty = wa_afko-bal_qty.
      endif.
      append wa_final to it_final.
      clear:wa_final ,wa_afpo,wa_afvv,wa_aufk,wa_afko.
    endloop.
    endif.
    ENDMODULE.                 " GET_DATA  OUTPUT
    *&      Module  DISPLAY_DATA  OUTPUT
          text
    MODULE DISPLAY_DATA OUTPUT.
      IF REF_CONTAINER IS INITIAL.
         PERFORM FIELD_CAT.
      CREATE OBJECT REF_CONTAINER
      EXPORTING
           PARENT                      =
        CONTAINER_NAME              = 'CUSTOM_CONTROL'
           STYLE                       =
           LIFETIME                    = lifetime_default
           REPID                       =
           DYNNR                       =
           NO_AUTODEF_PROGID_DYNNR     =
          EXCEPTIONS
            CNTL_ERROR                  = 1
            CNTL_SYSTEM_ERROR           = 2
            CREATE_ERROR                = 3
            LIFETIME_ERROR              = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5
            others                      = 6
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      L_LAYO-ZEBRA = 'X'.
      L_LAYO-GRID_TITLE = 'JOB CARD'.
      data: variant type disvariant.
      CREATE OBJECT REF_ALV_GRID
        EXPORTING
           I_SHELLSTYLE      = 0
           I_LIFETIME        =
          I_PARENT          = REF_CONTAINER
           I_APPL_EVENTS     = space
           I_PARENTDBG       =
           I_APPLOGPARENT    =
           I_GRAPHICSPARENT  =
           I_NAME            =
           I_FCAT_COMPLETE   = SPACE
          EXCEPTIONS
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4
            others            = 5
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    l_variant-report = sy-cprog.
    *data: l_prnt type lvc_s_prnt.
    *l_prnt-print = 'X'.
      SORT T_FCAT.
      call method ref_alv_grid->set_ready_for_input
       exporting
        i_ready_for_input = 1.
    create object event_receiver.
       set handler event_receiver->handle_top_of_page for ref_alv_grid.
      CALL METHOD REF_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
           EXPORTING
           I_BUFFER_ACTIVE               =
           I_BYPASSING_BUFFER            =
           I_CONSISTENCY_CHECK           =
           I_STRUCTURE_NAME              =
            is_variant                     =  variant   "l_variant
            i_save                        = 'X'
           I_DEFAULT                     = 'X'
             IS_LAYOUT                     = L_LAYO
           IS_PRINT                      =
           IT_SPECIAL_GROUPS             =
           IT_TOOLBAR_EXCLUDING          =
           IT_HYPERLINK                  =
           IT_ALV_GRAPHICS               =
           IT_EXCEPT_QINFO               =
           IR_SALV_ADAPTER               =
        CHANGING
          IT_OUTTAB                     = IT_final[]
          IT_FIELDCATALOG               = T_FCAT
           IT_SORT                       =
           IT_FILTER                     =
          EXCEPTIONS
            INVALID_PARAMETER_COMBINATION = 1
            PROGRAM_ERROR                 = 2
            TOO_MANY_LINES                = 3
            others                        = 4
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
       create object g_event_receiver.
       set handler g_event_receiver->handle_user_command for ref_alv_grid.
       set handler g_event_receiver->handle_toolbar for ref_alv_grid.
    § 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
       call method ref_alv_grid->set_toolbar_interactive.
       call method cl_gui_control=>set_focus exporting control = ref_alv_grid.
    ENDIF.
    ENDMODULE.                 " DISPLAY_DATA  OUTPUT
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN001'.
    SET TITLEBAR 'xxx'.
    Regards,
    Bharath Kumar

    I agree with Shiva Kumar - most likely there is no such field in it_afpo. A few more suggestions though:
    1) Do not post large pieces of code here - if you have a question about a particular SELECT statement, post only that statement and relevant data definitions. No one is going to read your whole program  anyway - we have work to do too.
    2) Your JOIN is way too big and would be difficult to analyze if anything goes wrong. You might want to start with smaller SELECTs and, when you're sure everything is working correctly, then combine them into one. Also huge JOINT is not necessarily more efficient.
    3) You don't have to use aliases "AS a... AS b", etc. Instead, just use the table name, e.g. AFKO... AFPO... .It is much easier to read this way. The aliases are needed only if you're joining the same table more than once. Also they're not limited to one letter either.

  • Inner join in ABAP and exporting the data

    Hi,
    I want to use inner join in ABAP for retrieving data from 2 tables and export that data.How will i do it?

    Hi,
    Refer following code
    *--Select query to pick the data from table VBRK
    VBRP and VBPA using inner join
      SELECT a~vbeln                            "Billing document
             a~fkdat                            "Billing date
             a~fktyp                            "Billing category
             a~fkart                            "Billing type
             a~vtweg                            "Distribution channel
             a~knumv                            "Number of doc condition
             b~posnr                            "Billing item
             b~matnr                            "Material Number
             b~werks                            "Plant
             b~vgbel                            "Referance
             b~netwr                            "Net value of billing item
             b~wavwr                            "Cost in document currency
             c~kunnr                            "Partner function
             FROM vbrk AS a
             INNER JOIN vbrp AS b
             ON avbeln EQ bvbeln
             INNER JOIN vbpa AS c
             ON  bvbeln EQ cvbeln
            AND bposnr EQ cposnr
             INTO CORRESPONDING FIELDS OF TABLE it_vbrp
             WHERE fkdat IN s_erdat
             AND   parvw EQ 'ZS'.
      IF sy-subrc EQ 0.
    *--Sort table by
        SORT it_vbrp BY vgbel1.
      ENDIF.
    Regards,
    Prashant

  • INNER JOIN Display Issues

    Hello,
    I am haing troubles displaying the author_name using the
    author_id in a testcase table and author table were author_id is
    the primary key in the author table and the foreign key in the
    author table. Here is my INNER JOIN SQL:
    $query_rsListAuthor = "SELECT author_name FROM author INNER
    JOIN testcase WHERE author.author_id = testcase.author_id";
    $rsListAuthor = mysql_query($query_rsListAuthor, $QA) or
    die(mysql_error());
    $row_rsListAuthor = mysql_fetch_assoc($rsListAuthor);
    $totalRows_rsListAuthor = mysql_num_rows($rsListAuthor);
    I can't seem to display the author_name when I use this:
    <?php echo $row_rsListAuthor['author_name'];
    ?></p>
    Any thoughts as to what I am doing wrong?
    Thanks,
    Ron

    How many matching records do you actually have between the 2
    tables?
    Are you seeing only 1 match on the web page or when you hit
    test in the recordset dialog window? If it is the web page you may
    need to slap a repeat region on it. Also make sure you have the
    correct recordset selected in the repeat region from the drop down
    menu. If you have multiple recordsets on the page because it always
    defaults to the first one in the menu

  • How to produce the effect of a date range inner join without actually doing one

    I have a T-SQL inner date range join that has done the job, but now that I am starting to learn about query optimization (as in just starting), I'm scratching my head on how to make it better. I see the non-equi join as being the issue because the optimizer
    scans through the entire table.  As you will see from the DDL code pasted below, there are no possible equi-joins. The enrollment history table has about 6000 rows so far, whereas the calendar table has only 10 so far, but is subject to change, which
    is why I have it as a table join.
    Another way to describe this is in the necessary outcome, which you see in the "Is_FAY" column in the Select statement. For each row in the Enrollment History table, I use the Case statement to determine whether the pair of Entry and Exit dates
    are within the Calendar date ranges (and if so, which row the match is found). There are no nulls in either table by design.
    At first, I thought of adding a non-clustered index, but the credible resources and blogs are mixed. Some sources say to use them, others say not to use them, and the remainder are on the fence. That and the
    fact that I drop and recreate the table every 24 hours (there are many updates to the Black Box) makes me very leery about having indices other than the primary key.
    I have pasted DDL language below with sample data.  Change the "Use Learning_Curve" statement to whatever database you want to use -- the rest will run as written.
    Now that I've given you some background and what I hope to accomplish, I hope that someone has encountered this issue before and can suggest an avenue of further inquiry, because I am out of usable research sources and ideas. 
    Thank you
    USE Learning_Curve;
    GO
    IF OBJECT_ID('dbo.Enrollment_History', 'U') IS NOT NULL
    DROP TABLE dbo.Enrollment_History;
    CREATE TABLE dbo.Enrollment_History
    (ID INT NOT NULL identity(1, 1) PRIMARY KEY,
    Campus_ID INT NOT NULL,
    Student_ID INT NOT NULL,
    Entry_Date DATE NOT NULL,
    Exit_Date DATE NOT NULL);
    INSERT INTO dbo.Enrollment_History
    VALUES (1, 103934, '2014-08-11', '2015-01-10'),
    (1, 102912, '2014-09-10', '2015-05-10'),
    (1, 199234, '2014-08-07', '2015-05-01');
    IF OBJECT_ID('dbo.Calendar_FAY_Dates', 'U') IS NOT NULL
    DROP TABLE dbo.Calendar_FAY_Dates;
    CREATE TABLE dbo.Calendar_FAY_Dates
    (ID INT NOT NULL identity(1, 1) PRIMARY KEY,
    FY VARCHAR(4) NOT NULL,
    Start_B DATE NOT NULL,
    Start_E DATE NOT NULL,
    End_B DATE NOT NULL,
    End_E DATE NOT NULL);
    INSERT INTO dbo.Calendar_FAY_Dates
    VALUES ('FY14', '2013-08-05', '2013-08-29', '2014-04-30', '2014-05-15'),
    ('FY15', '2014-08-07', '2014-08-28', '2015-04-30', '2015-05-15');
    SELECT eh.ID,
    eh.Campus_ID,
    eh.Student_ID,
    eh.Entry_Date,
    eh.Exit_Date,
    cfd.FY,
    case
    when eh.Entry_Date >= cfd.Start_B
    and eh.Entry_Date <= cfd.Start_E
    and eh.Exit_Date >=cfd.End_B
    and eh.Exit_Date <= cfd.End_E
    then 1 else 0 end as Is_FAY
    FROM dbo.Enrollment_History eh
    inner join dbo.Calendar_FAY_Dates cfd
    on eh.Entry_Date >= cfd.Start_B
    and eh.Exit_Date <= cfd.End_E

    This definitely a case where an indexes on the two tables will speed things up significantly. 
    It's also one of those strange cases where you can't really rely on the numbers you see in the execution plan. To really get an idea the impact to need to actually time the query...
    For example. Running your final query with out any additional indexes took ~4,000 microseconds...
    Adding the following index, dropped that time down to ~3,000 microseconds...
    CREATE NONCLUSTERED INDEX ix_Enrollment_History_EntryDates ON dbo.Enrollment_History (
    Entry_Date,
    Exit_Date)
    INCLUDE (
    ID,
    Campus_ID,
    Student_ID)
    WITH (DATA_COMPRESSION = PAGE)
    Adding the following index (and keeping the 1st) dropped it again, down to ~2,000 microseconds
    CREATE NONCLUSTERED INDEX ix_CalendarFAYDates_Detes ON dbo.Calendar_FAY_Dates (
    Start_B,
    End_E)
    INCLUDE (
    Start_E,
    End_B,
    ID,
    FY)
    WITH (DATA_COMPRESSION = PAGE)
    Keep in mind that 5 rows of data doesn't even begin to provide an accurate representation of read execution times against actual production data (the smallest changes in background processes on my computer caused the time to vary pretty drastically between
    executions).
    Anyway, the following is a quick & dirty way to test execution times when you're query tuning or checking the impact of different indexes on a query.
    DECLARE @b DATETIME2(7) = SYSDATETIME()
    SELECT eh.ID,
    eh.Campus_ID,
    eh.Student_ID,
    eh.Entry_Date,
    eh.Exit_Date,
    cfd.FY,
    case
    when eh.Entry_Date >= cfd.Start_B
    and eh.Entry_Date <= cfd.Start_E
    and eh.Exit_Date >=cfd.End_B
    and eh.Exit_Date <= cfd.End_E
    then 1 else 0 end as Is_FAY
    FROM dbo.Enrollment_History eh
    inner join dbo.Calendar_FAY_Dates cfd
    on eh.Entry_Date >= cfd.Start_B
    and eh.Exit_Date <= cfd.End_E
    SELECT DATEDIFF(mcs, @b, SYSDATETIME())
    HTH,
    Jason
    Jason Long

  • INNER JOIN DATA IN A CUBE

    Hi,
    I extracted data from two datasources a FI data source and 2LIS_03_BF.
    I matched these two data sources through:
    MBLNR-----AWREF = 0REF_DOC_NR
    MJAHR-----AWGJA = 0DOC_YEAR
    When the data is merged in the cube its a outer join and the data isnt matched.
    HOW DO I DO AN INNER JOIN TO MATCH ALL THE DATA TOGETHER?
    Cheers~

    it is going in the same cube... what would an ifo set do? would it merge my data? i have never used one before
    Scenerio is :
    Cube A has data from 2lis_03_bf
    Cube B has data from 0fi_gl_4
    Cube C im extracting data from A and B to merge data
    Edited by: DANIEL GREEN on May 2, 2008 2:10 AM

  • Edit form with an Inner Join - Can not update/delete data?!

    Hi all,
    I have an Edit form which shows me data from 2 tables (through an Inner Join SQL-Statement). I just realized that I can not edit data anymore, the following error msg appears:
    Error in mru internal routine: ORA-20001: no data found in tabular form
         Error     Unable to process update.
    OK     
    Can someone please help me?

    The ringed in red are from the second table, but the first table has some more data. Here is the SQL Statement I have (D1 and D2 are from the second table - Whereas the DOBJ_NR1 and the DOBJ_NR2 are both primary keys and foreign keys in table one, but the user selects the key from table two...):
    SELECT
    D1.DOBJ_NR DOBJ_NR1,
    D1.NAMSP NAMSP1,
    D1.DOBJ_NAME DOBJ_NAME1,
    D2.DOBJ_NR DOBJ_NR2,
    D2.NAMSP NAMSP2,
    D2.DOBJ_NAME DOBJ_NAME2,
    R.RS_NAME,
    R.ROLE1TO2,
    R.CARDMIN1TO2,
    R.CARDMAX1TO2,
    R.ROLE2TO1,
    R.CARDMIN2TO1,
    R.CARDMAX2TO1,
    R.ON_DELETE,
    R.ON_UPDATE,
    R.O_RS_COMMENT,
    R.INS_BY REL_INS_BY
    FROM
    DO_RELATIONSHIP R
    INNER JOIN DATAOBJECT D1 ON R.DOBJ1_NR = D1.DOBJ_NR
    INNER JOIN DATAOBJECT D2 ON R.DOBJ2_NR = D2.DOBJ_NR
    Edited by: user12067949 on Dec 5, 2009 3:18 AM

  • Convert SSRS dropdown MDX query to INNER JOIN w/ NONEMPTY? Having hard time with this.

    I'm having an incredibly hard time with this, mostly because I'm very new with MDX.
    I created a simple report (with AdventureWorksDW) whose datasource is an SSAS cube. I select a datekey from the dropdown menu, and the report displays [Measures].[Order Quantity] for that day.
    The problem is that the dropdown displays every single value from the dimdate dimension. DimDate goes from 20050101 to 20201231, so the dropdown is very long.
    How can I alter the SSRS-generated MDX so that it does an INNER JOIN with Fact table and only the dates shown in the dropdown are the ones where there's data in the Fact table?
    Currently, the fact table only has 2 days of data (20141015, 20141016), which means that the dropdown should only display those two dates. I'm including the generated code MDX that populates the dropdown menu:
    WITH MEMBER [Measures].[ParameterCaption] AS
    [Dim Date].[Date Key].CURRENTMEMBER.MEMBER_CAPTION
    MEMBER [Measures].[ParameterValue] AS
    [Dim Date].[Date Key].CURRENTMEMBER.UNIQUENAME
    MEMBER [Measures].[ParameterLevel] AS
    [Dim Date].[Date Key].CURRENTMEMBER.LEVEL.ORDINAL
    SELECT {[Measures].[ParameterCaption],
    [Measures].[ParameterValue], [Measures].[ParameterLevel]}
    ON COLUMNS , [Dim Date].[Date Key].ALLMEMBERS ON ROWS
    FROM [Adventure Works cube]
    Any help is appreciated.
    VM

    Hi vmhatup,
    you can get rid of blank data using nonempty function and get rid of negative values using filter function nonempty should be inside of filter so it applies first, otherwise it is too slow.
    Your statement could look like this
    WITH MEMBER [Measures].[ParameterCaption] AS
    [Dim Date].[Date Key].CURRENTMEMBER.MEMBER_CAPTION
    MEMBER [Measures].[ParameterValue] AS
    [Dim Date].[Date Key].CURRENTMEMBER.UNIQUENAME
    MEMBER [Measures].[ParameterLevel] AS
    [Dim Date].[Date Key].CURRENTMEMBER.LEVEL.ORDINAL
    SELECT {[Measures].[ParameterCaption],
    [Measures].[ParameterValue], [Measures].[ParameterLevel]}
    ON COLUMNS
    , filter(
    nonempty([Dim Date].[Date Key].[Date Key],measures.measureName)
    ,measure.measurename >0
    ON ROWS
    FROM [Adventure Works cube]
    Jiri Neoral

  • Inner Join of 3 tables is correct or not?

    Hi Guys ,
                 I have a requirement where i have to join 3 tables i  dont know whether the inner Join which i wrote for 3 tables is correct or not.I am not getting any Syntax error but whether the logci below which i wrote gets all the records or not.
    The Requirement is
    "c.     Select the BOL Number entered in the screen and query the table LIKP with the BOL number in the field LIKP-BOLNR.  Gather the list of ALL delivery documents (LIKP-VBELN) that is outputted.
    d.     Query the list of the delivery documents obtained into the table VBFA in the field VBFA- VBELV.  From the output that is displayed, select the Follow-On Document Field (VBFA-VBELN) for that item whose Subsequent Document Category (VBFA- VBTYP_N) is R and the Movement Type (VBFA- BWART) is 641.  Get the Follow-On document number for each of the above Delivery Document number.
    e.     Query the table EKBE with the Follow On document obtained above in the field Material Document (EKBE- BELNR).  Perform this activity for each of the follow on document obtained above.  Get the resultant Purchase Order (EKBE-EBELN) and Item Number (EKBE-EBELP) from the query.  After querying will all the Follow-On Documents, get the unique list of PO number and Item Number.
    The logic which i wrote is
                    Begin of t_PoolSTO_out,
                  BOLNR type LIKP-BOLNR,
                  EBELN type EKBE-EBELN,
                  EBELP type EKBE-EBELP,
                  VBELN type LIKP-VBELN,
                  VBELNV type VBFA-VBELN,
             End of t_PoolSTO_out.
          Data: i_PoolSTO type Standard table of t_PoolSTO_out.
      Select
            a~BOLNR
            c~EBELN
            c~EBELP
            a~VBELN
            b~VBELN
            from LIKP as a
            Inner Join VBFA as b on aVBELN = bVBELV
            Inner Join EKBE as c on bVBELN = cBELNR
            into Table i_PoolSTO
            Where a~BOLNR in S_LBLNE and
                  b~VBTYP_N = 'R' and
                  b~BWART = '641'.
              My doubt is whether the logic works or not i Mean does i getall the rrecords based on the requirement.?
                      If not please tell any alternative logic?
    Thanks,
    Gopi Anne.

    Hi Gopi,
    Your code is Good.
    But try to avoid Inner join with more number of Tables ...because this is a performance issue..
    try to use..
    select (primary key fields mainly,other fields) from LIKP into itab where bolnr in p_bolnr(paramater).
    next try to use for all entries option..
    select (primary key fields mainly,other fields) from VBFA for all entries in itab where (give the condition)....
    simillarly do for the other select ....ok this will try to reduce the performance issue....
    <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

  • Problem with a query inner-join

    Hello;
    I'm trying to innerjoin these 2 tables in my query for a page that will allow you to add / edit records. Right now, it's telling me I have a data mismatch. I don't see where I went wrong. Can someone help me out?
    This is my code:
    <cfparam name="url.CategoryID" type="integer" default="0">
    <cfparam name="subID" type="integer" default="#url.CategoryID#">
    <cfparam name="subName" default="">
    <cfparam name="CategoryID" default="">
    <cfparam name="Name" default="">
    <cfif url.CategoryID GT 0>
    <cfquery name="categRec" dataSource="#APPLICATION.dataSource#">
    SELECT merchSubCat.subName, merchSubCat.subID, Categories.CategoryID, Categories.Name
    FROM merchSubCat
    INNER JOIN Categories
        ON merchSubCat.CategoryID = Categories.CategoryID
    WHERE merchSubCat.subID = <cfqueryparam value="#url.CategoryID#" cfsqltype="cf_sql_integer">
    </cfquery>
    <!--- if the record was found, store the values --->
    <cfif categRec.RecordCount EQ 1>
    <cfset CategoryID = categRec.subID>
    <cfset subName = categRec.subName>
    <cfset CategoryID = categRec.CategoryID>
    <cfset Name = categRec.Name>
    </cfif>
    </cfif>
    this is my error:
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Type mismatch in expression.
    The error occurred in C:\Websites\187914kg3\admin\cms\merchant\merchSub-edit.cfm: line 16
    14 : INNER JOIN Categories
    15 :     ON merchSubCat.CategoryID = Categories.CategoryID
    16 : WHERE merchSubCat.subID = <cfqueryparam value="#url.CategoryID#" cfsqltype="cf_sql_integer">
    17 : </cfquery>
    18 :
    I don't see what I did wrong, can another pair of eyes see where I missed something?
    Thank you

    I changed it to number, and it works now.
    I have one other problem.. I'm trying to use a drop down menu in this form to edit a record. I want the drop down to show what is being used in the database when you go to edit a record. It runs on one query, to populate the select, but it pulls info from another and this isn't working. Actually, it's the innerjoin I just made.. can you help me?
    <!--- query that runs the select --->
    <cfquery name="catList" datasource="#APPLICATION.dataSource#">
    SELECT DISTINCT merchCategory.CategoryID, merchCategory.CatName AS cat_name
    FROM merchCategory
    ORDER BY CatName
    </cfquery>
    <cfselect enabled="No" name="CategoryID" size="1" class="smallText" multiple="no" query="catList" value="CategoryID" display="cat_name" queryPosition="below" selected="#categRec.Name#">
                      <option value="">--Select a Category--</option>
                  </cfselect>
    As you see, in the selected part of the tag, I'm trying to pull info from the other query we just fixed. I know this is wrong, how do I do this?

  • Help on Inner Join Query

    Hi ABAPers,
    I was trying to develop a report for which query is something like this.
    *& Report  ZT_SERIAL
    REPORT  ZT_SERIAL.
    TABLES : SER01,SER03,OBJK,LIKP,LIPS. " LIKP - SD invoice header table, LIPS - SD invoice details table
    TYPE-POOLS: SLIS.
    DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    MANDATORY WHILE DECLARING ALV ***
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV..
    DATA: V_EVENTS TYPE SLIS_T_EVENT.
    DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
    DATA: I_TITLE_SL_NO_TRACK TYPE LVC_TITLE VALUE 'SERIAL NO TRACKER'.
    DATA : BEGIN OF ITAB OCCURS 0,
           OBKNR LIKE OBJK-OBKNR,     "OBJECT LIST
           OBZAE LIKE OBJK-OBZAE,     "OBJECT COUNTER
           KUNDE LIKE SER01-KUNDE,    "CUSTOMER NO
           MATNR LIKE OBJK-MATNR,     "PART NO
           SERNR LIKE OBJK-SERNR,     "SERIAL NO
           MBLNR LIKE SER03-MBLNR,    "GRN/MATERIAL DOC NO
           LIEF_NR LIKE SER01-LIEF_NR,"OUTBOUND DELV NO
           DATUM LIKE SER01-DATUM,    "OUTBOUND DELV DATE
           TASER LIKE OBJK-TASER,     "HEADER TABLE
           ANZSN LIKE SER01-ANZSN,    "NO OF SERIAL NOS
           VGBEL LIKE LIPS-VGBEL,     "SALES ORDER NO
           END OF ITAB.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_KUNDE FOR SER01-KUNDE,
                      S_VGBEL FOR LIPS-VGBEL,
                      S_MATNR FOR OBJK-MATNR,
                      S_SERNR FOR OBJK-SERNR,
                      S_MBLNR FOR SER03-MBLNR,
                      S_LIFNR FOR SER01-LIEF_NR,
                      S_DATUM FOR SER01-DATUM.
    SELECTION-SCREEN : END OF BLOCK B1.
    PERFORM TRACKING.
    PERFORM FLDCAT.
    PERFORM BUILD_LAYOUT.
    ***CALL FUNCTION TO DISPLAY IN ALV FORMAT*******
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM = SY-REPID
        I_GRID_TITLE       = I_TITLE_SL_NO_TRACK
        IS_LAYOUT          = LAYOUT
        IT_FIELDCAT        = P_FIELDTAB[]
        I_SAVE             = 'A'
        IT_EVENTS          = V_EVENTS
      TABLES
        T_OUTTAB           = ITAB.
    ***END OF CALL FUNCTION
    FORM TRACKING.
    SELECT OBJKOBKNR OBJKOBZAE OBJKMATNR OBJKSERNR OBJK~TASER
           SER01KUNDE SER01LIEF_NR SER01DATUM SER01ANZSN
           SER03~MBLNR
           LIPS~VGBEL
           INTO TABLE ITAB FROM OBJK
           INNER JOIN SER01 ON OBJKOBKNR = SER01OBKNR
           INNER JOIN SER03 ON OBJKOBKNR = SER03OBKNR
           INNER JOIN LIPS ON SER01LIEF_NR = LIPSVBELN
           WHERE
           OBJKTASER = 'SER01' OR OBJKTASER = 'SER03'.
           OBJK~MATNR IN S_MATNR AND
           OBJK~SERNR IN S_SERNR AND
           SER01~KUNDE IN S_KUNDE AND
           SER01~LIEF_NR IN S_LIFNR AND
           SER01~DATUM IN S_DATUM AND
           SER03~MBLNR IN S_MBLNR AND
           LIPS~VGBEL IN S_VGBEL.
    ENDFORM.
    *&      Form  fldcat
          text
    FORM FLDCAT.
      PERFORM FLDCAT1 USING 'KUNDE' 'Customer No'.
      PERFORM FLDCAT1 USING 'VGBEL' 'Sales Order No'.
      PERFORM FLDCAT1 USING 'MATNR' 'Tejas Part No'.
      PERFORM FLDCAT1 USING 'SERNR' 'Serial No'.
      PERFORM FLDCAT1 USING 'MBLNR' 'Material Doc No'.
      PERFORM FLDCAT1 USING 'LIEF_NR' 'Outbound Delv No'.
      PERFORM FLDCAT1 USING 'DATUM' 'Outbound Delv Date'.
    ENDFORM.                    "fldcat
    *&      Form  fldcat1
          text
         -->FNAM       text
         -->FTEXT      text
    FORM FLDCAT1 USING FNAM FTEXT.
        DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
              L_FIELDCAT-FIELDNAME  = FNAM.
              L_FIELDCAT-SELTEXT_M = FTEXT.
      IF FNAM EQ 'MATNR'."OR fnam EQ 'PKUNAG'.
        L_FIELDCAT-KEY = 'X'.
      ENDIF.
      LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
    CLEAR fldcat1.
    ENDFORM.                                                    "fldcat1
    *&      Form  build_layout
          text
    FORM BUILD_LAYOUT .
      LAYOUT-NO_INPUT          = 'X'.
      LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      LAYOUT-ZEBRA = 'X'.
      LAYOUT-TOTALS_TEXT       = 'Totals'(256).
    layout-coltab_fieldname = 'CELL_COLOUR'.
    *clear layout.
    ENDFORM.                   
    But when I run this query,the program gets terminated.Can you please help me in rectifying the query and generate the output?
    Thanks in advance
    Bhavin

    Hi
    I have corrected the code please copy and past it and then try.
    Report ZT_SERIAL.
    TABLES : SER01,SER03,OBJK,LIKP,LIPS.
    " LIKP - SD invoice header table, LIPS - SD invoice details table
    TYPE-POOLS: SLIS.
    DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
         + MANDATORY WHILE DECLARING ALV ***
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV..
    DATA: V_EVENTS TYPE SLIS_T_EVENT.
    DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
    DATA: I_TITLE_SL_NO_TRACK TYPE LVC_TITLE VALUE 'SERIAL NO TRACKER'.
    DATA : BEGIN OF ITAB OCCURS 0,
    OBKNR LIKE OBJK-OBKNR, "OBJECT LIST
    OBZAE LIKE OBJK-OBZAE, "OBJECT COUNTER
    KUNDE LIKE SER01-KUNDE, "CUSTOMER NO
    MATNR LIKE OBJK-MATNR, "PART NO
    SERNR LIKE OBJK-SERNR, "SERIAL NO
    MBLNR LIKE SER03-MBLNR, "GRN/MATERIAL DOC NO
    LIEF_NR LIKE SER01-LIEF_NR,"OUTBOUND DELV NO
    DATUM LIKE SER01-DATUM, "OUTBOUND DELV DATE
    TASER LIKE OBJK-TASER, "HEADER TABLE
    ANZSN LIKE SER01-ANZSN, "NO OF SERIAL NOS
    VGBEL LIKE LIPS-VGBEL, "SALES ORDER NO
    END OF ITAB.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_KUNDE FOR SER01-KUNDE,
    S_VGBEL FOR LIPS-VGBEL,
    S_MATNR FOR OBJK-MATNR,
    S_SERNR FOR OBJK-SERNR,
    S_MBLNR FOR SER03-MBLNR,
    S_LIFNR FOR SER01-LIEF_NR,
    S_DATUM FOR SER01-DATUM.
    SELECTION-SCREEN : END OF BLOCK B1.
    PERFORM TRACKING.
    PERFORM FLDCAT.
    PERFORM BUILD_LAYOUT.
    ***CALL FUNCTION TO DISPLAY IN ALV FORMAT*******
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    I_GRID_TITLE = I_TITLE_SL_NO_TRACK
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = P_FIELDTAB[]
    I_SAVE = 'A'
    IT_EVENTS = V_EVENTS
    TABLES
    T_OUTTAB = ITAB.
    ***END OF CALL FUNCTION
    FORM TRACKING.
    *SELECT OBJK~OBKNR
          OBJK~OBZAE
          OBJK~MATNR
          OBJK~SERNR
          OBJK~TASER
          SER01~KUNDE
          SER01~LIEF_NR
          SER01~DATUM
          SER01~ANZSN
          SER03~MBLNR
          LIPS~VGBEL
      INTO TABLE ITAB FROM OBJK
      INNER JOIN  SER01 ON OBJKOBKNR = SER01OBKNR
      INNER JOIN  SER03 ON OBJKOBKNR = SER03OBKNR
      INNER JOIN  LIPS ON SER01LIEF_NR = LIPSVBELN
      WHERE
    *( OBJKTASER = 'SER01' OR OBJKTASER = 'SER03' ) and
    *OBJK-MATNR IN S_MATNR AND
    *OBJK~SERNR IN S_SERNR AND
    *SER01~KUNDE IN S_KUNDE AND
    *SER01~LIEF_NR IN S_LIFNR AND
    *SER01~DATUM IN S_DATUM AND
    *SER03~MBLNR IN S_MBLNR AND
    *LIPS~VGBEL IN S_VGBEL.
    SELECT a~OBKNR         "OBJK
           a~OBZAE
           a~MATNR
           a~SERNR
           a~TASER
           b~KUNDE         "SER01
           b~LIEF_NR
           b~DATUM
           b~ANZSN
           c~MBLNR        "SER03
           D~VGBEL        "LIPS
       INTO TABLE ITAB FROM  ( OBJK as a
       INNER JOIN  SER01 as b ON aOBKNR = bOBKNR
       INNER JOIN  SER03 as c ON aOBKNR = cOBKNR
       INNER JOIN  LIPS as  d ON bLIEF_NR = dVBELN )
       WHERE
    ( aTASER = 'SER01' OR aTASER = 'SER03' ) and
    a~MATNR IN S_MATNR AND
    a~SERNR IN S_SERNR AND
    b~KUNDE IN S_KUNDE AND
    b~LIEF_NR IN S_LIFNR AND
    b~DATUM IN S_DATUM AND
    c~MBLNR IN S_MBLNR AND
    d~VGBEL IN S_VGBEL.
    ENDFORM.
    *& Form fldcat
       * text
    FORM FLDCAT.
    PERFORM FLDCAT1 USING 'KUNDE' 'Customer No'.
    PERFORM FLDCAT1 USING 'VGBEL' 'Sales Order No'.
    PERFORM FLDCAT1 USING 'MATNR' 'Tejas Part No'.
    PERFORM FLDCAT1 USING 'SERNR' 'Serial No'.
    PERFORM FLDCAT1 USING 'MBLNR' 'Material Doc No'.
    PERFORM FLDCAT1 USING 'LIEF_NR' 'Outbound Delv No'.
    PERFORM FLDCAT1 USING 'DATUM' 'Outbound Delv Date'.
    ENDFORM. "fldcat
    *& Form fldcat1
        text
        -->FNAM text
        -->FTEXT text
    FORM FLDCAT1 USING FNAM FTEXT.
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    L_FIELDCAT-FIELDNAME = FNAM.
    L_FIELDCAT-SELTEXT_M = FTEXT.
    IF FNAM EQ 'MATNR'."OR fnam EQ 'PKUNAG'.
    L_FIELDCAT-KEY = 'X'.
    ENDIF.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    APPEND L_FIELDCAT TO P_FIELDTAB.
       * CLEAR fldcat1.
    ENDFORM. "fldcat1
    *& Form build_layout
       * text
    FORM BUILD_LAYOUT .
    LAYOUT-NO_INPUT = 'X'.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    LAYOUT-ZEBRA = 'X'.
    LAYOUT-TOTALS_TEXT = 'Totals'(256).
       * layout-coltab_fieldname = 'CELL_COLOUR'.
    *clear layout.
    ENDFORM.
    Regards,
    Venkat

  • Reply to vj (qery on the inner joins v/s performane test)

    this is ravi shiva's friend.
    hi vj,
             u r working for intelli group....and i had met u twice. by the way give u r contact number i want to speak to u personally.
              here is the code... 
    REPORT  rv_sid_purchase_order_status NO STANDARD PAGE HEADING MESSAGE-ID zrv_message_cl LINE-COUNT 65 LINE-SIZE 110 .
    This include contains declarations
    INCLUDE zrv_sid_purchase_order_t.
    This include contains code for the performs
    INCLUDE zrv_sid_purchase_order_f.
                          Initialization
    INITIALIZATION.
    This perform will initialize the values.
      PERFORM f_initilaize.
    This perform will initialize the field catalog.
      PERFORM f_e01_fieldcat_init USING gt_fieldcat[].
                         Start-Of-Selection
    START-OF-SELECTION.
    This perform will read the values from the database.
      PERFORM f_selection.
    This perform will call the function module to display the values on the list.
      PERFORM f_display.
              End-Of-Selection
    END-OF-SELECTION.
    *&  Include           ZRV_SID_PURCHASE_ORDER_T                         *
               T a b l e s   D e c l a r a t i o n s                     *
    TABLES: ekko,ekpo,ekbe,ekkn,mkpf.
               Type Pools  D e c l a r a t i o n s                       *
    TYPE-POOLS: slis.
          Selection Screen Declaration
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-100.
    SELECT-OPTIONS: ebeln FOR ekko-ebeln,
                    aedat FOR ekko-aedat.
    SELECTION-SCREEN END OF BLOCK b1.
               V a r i  a b l e s                                        *
    DATA : gt_fieldcat         TYPE  slis_t_fieldcat_alv,
           g_repid             LIKE  sy-repid,
           gs_keyinfo          TYPE  slis_keyinfo_alv,
           g_tabname_header    TYPE  slis_tabname,
           g_tabname_item      TYPE  slis_tabname,
           ls_layout           TYPE  slis_layout_alv,
           gt_list_top_of_page TYPE  slis_t_listheader.
               I n t e r n a l  T a b l e s                               *
    DATA: BEGIN OF itab OCCURS 0,
           ebeln LIKE ekko-ebeln,
           lifnr LIKE ekko-lifnr,
           aedat LIKE ekko-aedat,
           submi LIKE ekko-submi,
           name1 LIKE lfa1-name1,
           netwr LIKE erev-netwr,
          END OF itab.
    DATA: BEGIN OF jtab OCCURS 0,
           ebeln      LIKE  ekpo-ebeln,
           ebelp      LIKE  ekpo-ebelp,
           aedat      LIKE  ekpo-aedat,
           txz01      LIKE  ekpo-txz01,
           menge1     LIKE  ekpo-menge,
           menge2     LIKE  ekbe-menge,
           effwr1     LIKE  ekpo-effwr,
           mwskz1     LIKE  ekpo-mwskz,
           ps_psp_pnr LIKE  ekkn-ps_psp_pnr,
           bewtp1     LIKE  ekbe-bewtp,
           belnr1     LIKE  ekbe-belnr,
           dmbtt      LIKE  ekbe-dmbtr,
           mblnr1     LIKE  mkpf-mblnr,
           bldat1     LIKE  mkpf-bldat,
           xblnr1     LIKE  mkpf-xblnr,
           frbnr      LIKE  mkpf-frbnr,
          END OF jtab.
    *&  Include           ZRV_SID_PURCHASE_ORDER_F                         *
    FORM f_initilaize .
      g_repid = sy-repid.
      g_tabname_header            = 'itab'.
      g_tabname_item              = 'jtab'.
      CLEAR gs_keyinfo.
      gs_keyinfo-header01         = 'EBELN'.
      gs_keyinfo-item01           = 'EBELN'.
      gs_keyinfo-header02         = space.
      gs_keyinfo-item02           = 'EBELP'.
      ls_layout-group_change_edit = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-zebra             = 'X'.
      ls_layout-detail_popup      = 'X'.
      ls_layout-get_selinfos      = 'X'.
      ls_layout-window_titlebar   = 'PURCHASE ORDER STATUS'.
      ls_layout-no_keyfix         = 'X'.
    ENDFORM.                    " f_INITILAIZE
    *&      Form  f_e01_fieldcat_init
          text
         -->E01_LT_FIELtext
    FORM f_e01_fieldcat_init  USING  e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: ls_fieldcat TYPE slis_fieldcat_alv.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'SUBMI'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'SUBMI'.
      ls_fieldcat-ref_tabname   = 'EKKO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'EBELN'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'EBELN'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'LIFNR'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'LIFNR'.
      ls_fieldcat-ref_tabname   = 'EKKO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'NAME1'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'NAME1'.
      ls_fieldcat-ref_tabname   = 'LFA1'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'NETWR'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'NETWR'.
      ls_fieldcat-ref_tabname   = 'EREV'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-do_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'EBELP'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'EBELP'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'TXZ01'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'TXZ01'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-just = 'L'.
      ls_fieldcat-fieldname     = 'MWSKZ1'.
      ls_fieldcat-seltext_l     = 'Tax code'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'MWSKZ1'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-just          = 'L'.
      ls_fieldcat-fieldname     = 'PS_PSP_PNR'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'PS_PSP_PNR'.
      ls_fieldcat-ref_tabname   = 'EKKN'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'MENGE1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'Po quantity'.
      ls_fieldcat-ref_fieldname = 'MENGE1'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'MENGE1'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'EFFWR1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'Po value'.
      ls_fieldcat-ref_fieldname = 'EFFWR1'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'BEWTP1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'Cat'.
      ls_fieldcat-ref_fieldname = 'BEWTP1'.
      ls_fieldcat-ref_tabname   = 'EKBE'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'BELNR1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'GR/IR MDoc'.
      ls_fieldcat-ref_fieldname = 'BELNR1'.
      ls_fieldcat-ref_tabname   = 'EKBE'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'MENGE2'.
      ls_fieldcat-seltext_l     = 'GR/IR quantity'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'MENGE2'.
      ls_fieldcat-ref_tabname   = 'EKBE'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'MBLNR1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'GR No'.
      ls_fieldcat-ref_fieldname = 'MBLNR1'.
      ls_fieldcat-ref_tabname   = 'MKPF'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'BLDAT1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'GR Date'.
      ls_fieldcat-ref_fieldname = 'BLDAT1'.
      ls_fieldcat-ref_tabname   = 'MKPF'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'FRBNR'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'FRBNR'.
      ls_fieldcat-ref_tabname   = 'MKPF'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'XBLNR1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'Invoice No in GR'.
      ls_fieldcat-ref_fieldname = 'XBLNR1'.
      ls_fieldcat-ref_tabname   = 'MKPF'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'DMBTT'.
      ls_fieldcat-seltext_l     = 'Invoice value W/O tax'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'DMBTT'.
      ls_fieldcat-ref_tabname   = 'EKBE'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
    ENDFORM.                    " f_e01_fieldcat_init
    *&      Form  f_selection
          text
    FORM f_selection .
      SELECT   ekko~ebeln
               ekko~lifnr
               ekko~aedat
               ekko~submi
               lfa1~name1
               erev~netwr
                               FROM ekko  INNER JOIN lfa1 ON ( ekkolifnr = lfa1lifnr )
                                          INNER JOIN erev ON ( ekkoebeln = erevedokn )
                                          INTO TABLE itab WHERE ekko~ebeln IN ebeln AND
                                                                ekko~aedat IN aedat AND
                                                                bsart <> 'AN'.
      SELECT
             ekpo~ebeln
             ekpo~ebelp
             ekpo~aedat
             ekpo~txz01
             ekpo~menge
             ekbe~menge
             ekpo~effwr
             ekpo~mwskz
             ekkn~ps_psp_pnr
             ekbe~bewtp
             ekbe~belnr
             ekbe~dmbtr
             mkpf~mblnr
             mkpf~bldat
             mkpf~xblnr
             mkpf~frbnr
                            FROM  ekpo INNER JOIN ekkn      ON ( ekpoebeln = ekknebeln
                                                                           AND
                                                                 ekknebelp = ekpoebelp )
                                       INNER JOIN ekbe      ON ( ekknebeln = ekbeebeln
                                                                           AND
                                                                 ekknebelp = ekbeebelp )
                                       LEFT OUTER JOIN mkpf ON ( ekbebelnr = mkpfmblnr )
                                       INTO TABLE jtab FOR ALL ENTRIES IN itab WHERE ekpo~ebeln = itab-ebeln AND
                                                                                    ekpo~aedat = itab-aedat.
    ENDFORM.                    " f_selection
    *&      Form  f_display
          text
    FORM f_display .
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
          i_callback_program = g_repid
          it_fieldcat        = gt_fieldcat[]
          i_tabname_header   = g_tabname_header
          i_tabname_item     = g_tabname_item
          is_keyinfo         = gs_keyinfo
          is_layout          = ls_layout
        TABLES
          t_outtab_header    = itab
          t_outtab_item      = jtab.
    ENDFORM.                    " f_display

    Hi Ravi,
    1. To check performance of a report we use the perfromance trace. The transaction code is ST05.
    You can also refer the link :
         http://help.sap.com/saphelp_erp2005/helpdata/en/8a/3b834014d26f1de10000000a1550b0/content.htm
    2.  Also we can do the run time analysis of the code uising transaction code SE30.
    3. To do a general check on the code , you can use the SAP Code Inspector. The transaction code for this is SCI. This will defentely give you a detailed analysis of the program.
    4 . To have a general idea about the performance tuning of a report , you should refer the link :
       http://www.sapgenie.com/abap/performance.htm.
    Hope this solves yopur query.
    Regards,
    Kunal.

Maybe you are looking for

  • Safari crashes when launched - any suggestions

    Safari works fine on my iMac. However, recently, it has started to crash on launch on my PC which uses Windows XP SP2. Reinstalling Safari does not help. I send the standard MS error report, but I don't expect much help there. I did note others have

  • How can I deal with long sql by the oo4o?

    I am using VB and oo4o to develop a sql executor which is a extention of an old system. For some reason, I have to use oo4o v8.1.7 to deal with Oracle Database 8i to 11g. But when I send a very long sql(11KB) to it I got a error in the VB enviroment.

  • Bluetooth adapter missing from Lenovo L440

    Hi, My bluettoth adapter went missing one day suddely. I checked in network connection and device manager but its not showing up anywhere. Went to lenovo website and installed drivers but still nothing is happening

  • How do I restore iMovie if I deleted it by accident and have not set up Time Machine

    Hello, I am aware there is another post similar to this however I do not have Time Machine set up therefore I can not restore to a previous date before I deleted iMovie. Is there a way to restore it without having to purchase it? Thanks!

  • Maintain Text in Different Language

    Hi PS Expert, I have query for maintaining text in multiple language, let me elaborate my query.. I created std project having all WBS element & maintain WBS Text ( description) in English lanuage.Now my client prefers that if a person in other count