Doubt in Inner Join.

Hi all,
In a report program i have used a inner join. I am getting error in the where condition. Here I have furnished part of my code for ur reference.
Tables : mara, makt, mard.
data : begin of itab occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
lgort like mard-lgort,
labst like mard-labst,
end of itab.
parameters : matnr like mara-matnr.
start-of-selection.
select maramatnr maktmaktx mardlgort mardlabst into corresponding fields of iab from mara inner join maktx on maramatnr = maktmatnr inner join mard on maktmatnr = mardmatnr where matnr eq matnr.
in the where condition I am getting the following error message.
matnr has two meanings in data dictionary.
Please help me in sort out this problem and also tell me more abt inner joins.
thanks.

HI,
You can achieve this in two ways:
1st:
into corresponding fields of TABLE itab
2nd:
if you have inner join you don't need where any more at all! you already have connections.
if you still need then use:
tablename~fieldname
for both sides!
if in your example matnr from left side is local or global variable then you have problem with some naming conventions which usually are used in SAP.
try 1st points at the beggining
i'd write your select in this style
Code:
         select mara~matnr
          makt~maktx
          mardlgort mardlabst
into corresponding fields of table itab
from ( mara
inner join makt on maktmatnr = maramatnr
               and makt~spras = sy-langu )
inner join mard on mardmatnr = maramatnr.
OR
    Code:
          select mara~matnr
          makt~maktx
          mardlgort mardlabst
into corresponding fields of table itab
from ( mara
inner join makt on maktmatnr = maramatnr )
inner join mard on mardmatnr = maramatnr
where
        makt~spras = sy-langu.
Cheers,
Chandra Sekhar.

Similar Messages

  • Doubt in inner joins

    what is the max no of tables that can be joined in inner joins?
    Thanks in advance
    srinivas k

    hi,
    there is no limit for table number in inner join
    just need to follow some rules..
    1. You can use cluster table in innner join e.g. BSEG
    2. You system performance depends on number of tables..
    3. In innner join try to use all primary key fieds in where condition.
    have a nice day!
    sachin

  • For All Entries is NOT better than INNER JOIN in most cases

    I quote from Siegfried Boes' excellent post here: Will writing an inner join be better or creating a view?
    For all the FOR ALL ENTRIES lovers ... there is no proof for these reappearing recommendation.
    There is nearly nobody who receives forum points, who recommends FOR ALL ENTRIES instead of Joins. What is the reason ???
    It is easier to prove the opposite. A Join is a nested loop inside the database, a FOR ALL ENTRIES is partly outside of the database. FOR ALL ENTRIES works in blocks, joins on totals.
    FOR ALL ENTRIES are not recommded on really large tables, because the chances are too high that
    too many records are transferred.
    People prefer FOR ALL ENTRIES, because JOINs are not so easy to understand. Joins can go wrong, but with a bit of understanding they can be fixed.
    Some Joins are slow and can not be fixed, but then the FOR ALL ENTRIES would be extremely slow.
    There are several kinds of views:
    - projection views, i.e. only one table involved just fields reduced
    - join views, several tables, joins conditions stored in dictionary
    - materialized views, here the joined data are actually stored in the database. Storing and synchronisation has to be done manually.
    Only the last one creates real overhead. It should be the exception.
    Join Views and Joins are nearly identical. The view is better for reuse. The join is better in complicated, becuase if the access goes wrong, it can often be fixed by adding a hint. Hints can not be added to views.
    Abraham Bukit  points out:
    If it is cluster table, (you can't use join). If it is buffered table, I would also say avoid join.
    If they all are transaction table which are not buffered and are not cluster tables.  
    He further supports Siegfried's statement that FAE is easier to undestand than INNER JOINs.
    Thomas Zloch says, regarding buffered tables:
    At least think twice, maybe compare runtimes if in doubt. 
    So, unless someone has some EVIDENCE that FOR ALL ENTRIES is better, I don't think we want to see this discussed further.
    Kind regards
    Matt

    To give food for thought here's an example I  gave in a thread:
    If you have a statement like
    SELECT ... FOR ALL ENTRIES IN FAE_itab WHERE f = FAE_itab-f.
    SAP sends it to the database depending how the parameter rsdb/prefer_union_all is set:
    rsdb/prefer_union_all = 0 =>
    SELECT ... WHERE f = FAE_itab[1]-f
              OR    f = FAE_itab[2]-f
              OR    f = FAE_itab[N]-f
    You have some influence  of the generated statement type: Instead of OR'ed fields an IN list can be used
    if you have only a single coulmn N to compare:
    rsdb/prefer_in_itab_opt parameter:
    SELECT ... WHERE f IN (itab[1]-f, itab[2]-f, ..., itab[N]-f)
    rsdb/prefer_union_all = 1 =>
    SELECT ... WHERE f = FAE_itab[1]-f
    UNION ALL SELECT ... WHERE f = FAE_itab[2]-f
    UNION ALL SELECT ... WHERE f = FAE_itab[N]-f
    see: Note 48230 - Parameters for the SELECT ... FOR ALL ENTRIES statement
    As you can see for the 2nd parameter several statements are generated and combined with a UNION ALL,
    the first setting generates statements with OR's (or uses IN  if possible) for the entries in FAE_itab.
    I give you a little example here (my parameters are set in a way that the OR's are translated to IN lists; i traced the execution in ST05)
    Select myid into table t_tabcount from mydbtable
      for all entries in t_table    " 484 entries
        where myid = t_table-myid .
    ST05 trace:
    |Transaction SEU_INT|Work process no 0|Proc.type  DIA|Client  200|User |
    |Duration |Obj. name |Op.    |Recs.|RC    |Statement|
    | 640|mydbtable |PREPARE|   |  0|SELECT WHERE "myid" IN ( :A0 , :A1 , :A2 , :A3 , :A4 ) AND "myid" = :A5|
    | 2|mydbtable |OPEN   |   |  0|SELECT WHERE "myid" IN ( 1 , 2 , 3 , 4 , 5 ) AND "myid" = 72 |
    | 2.536|mydbtable |FETCH  |    0|  1403|   |
    | 3|mydbtable |REOPEN |   |  0|SELECT WHERE "myid" IN ( 6 , 7 , 8 , 9 , 10 ) AND "myid" = 72 |
    | 118|mydbtable |FETCH  |  0|  |
    | 2|mydbtable |REOPEN |  |  0|SELECT WHERE "myid" IN ( 11 , 12 , 13 , 14 , 15 ) AND "myid" = 72     |
    | 3|mydbtable |REOPEN |  |  0|SELECT WHERE "myid" IN ( 475 , 476 , 477 , 478 , 479 ) AND "myid" = 72  |
    | 94|mydbtable |FETCH  | 0| 1403|   |
    | 2|mydbtable |REOPEN |   |  0|SELECT WHERE "myid" IN ( 480 , 481 , 482 , 483 , 484 ) AND "myid" = 72 |
    You see the IN list contained 5 entries each , wich made up about 97 statements for all 484 entries.
    For every statment you have a single fetch operation wich means a separate access to the database.
    If you would replace the FAE with a join you would only have one fetch to the database.
    With the example above we can derive these observations:
    1. From database point of view these settings kill performance when you access a big table and/or have a lot of entries or columns in your FAE_itab. Furthermore, you hide information what data you will access
    at all and thus you block the database from creating a more efficient execution plan because it DOESN'T KNOW wich data you will select in the next step. I.e. it may be more efficient to scan the table in one shot instead of having many index accesses - but the database can make this decision only if it can examine ONE statement that has ALL the information of what data to retrieve.
    2. A second impact is that with every statement execution you trigger the allocation of database resources
    wich will contribute to the overhead described above.
    Said that, FAE  can never be a replacement for joining big tables (think of having a table with thousands of records in a FAE table )
    Edited by: kishan P on Nov 2, 2010 2:16 PM - Format Fixed

  • 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

  • Report -without inner join

    hi,
    this is report i created in this i used two tables and used inner join to make relation b/t these tables...
    so my doubt is ..if we r using three diff.. tables without inner join we can do this report ......if u can.. plz can u show me wit example...
    TABLES: VBAP,VBAK.
    DATA :  BEGIN OF ITAB OCCURS 0,
      vbeln like VBAK-VBELN, "Sales Document No.
      kunnr like VBAK-KUNNR,"customerno
      VKORG like VBAK-VKORG,"salesorg
      audat like VBAK-AUDAT,"documentdate
      matnr like VBAP-MATNR,"materialno
      netwr like VBAK-NETWR,"netamount
      end of itab.
    selection-screen : begin of block a1. "SCREEN 500 AS WINDOW..
    select-options : KUNNR for VBAK-kunnr.
    select-options : VKORG FOR VBAK-vkorg.
    select-options : AUDAT for VBAK-audat.
    select-options : MATNR for VBAP-matnr.
    select-options : NETWR FOR VBAK-netwr.
    SELECTION-SCREEN :end of block a1.
    SELECT vbakvbeln vbakkunnr vbakvkorg vbakaudat  vbapmatnr vbaknetwr into table itab from vbak
      INNER JOIN vbap on vbakvbeln = vbapvbeln
      where
      VBAK~kunnr in kunnr
    AND
       VBAK~VKORG in VKORG
    and vbak~audat in audat
    AND vbap~matnr in matnr.
      write sy-dbcnt.
    write:/ 'CUSTOMERNO' ,20 'SALESORG',40 'DOCUMENTDATE',60 'MATERIAL',80 'NETAMOUNT'.
    ULINE.
    loop at itab.
        write :/ itab-kunnr,20 itab-vkorg, 40 itab-audat, 60 itab-matnr, 80 itab-netwr.
        endloop.
    thanx
    bhanu

    Refer to this psuedo code
    SELECT vbak~vbeln vbak~kunnr vbak~vkorg vbak~audat vbap~matnr vbak~netwr into table itab from vbak
    INNER JOIN vbap on vbak~vbeln = vbap~vbeln
    where
    VBAK~kunnr in kunnr
    AND
    VBAK~VKORG in VKORG
    and vbak~audat in audat
    AND vbap~matnr in matnr.
    SELECT vbak~vbeln vbak~kunnr vbak~vkorg vbak~audat vbak~netwr vbak~matnr
                 into table itab
    from vbak
    where kunnr in kunnr....
    select vbeln matnr
          into table itab2
    from vbap
    for all entries in itab
    where vbap~matnr = itab~matnr....
    loop at itab assigning <fs_itab>.
    read table itab2 into wa_itab2 with key vbeln = <fs_itab>-vbeln
                                                             matnr = <fs_itab>-matnr.
    " your move's to final table
    endloop.

  • ANSI inner join syntax

    Hi,
    Is there a way to configure BI Server 11g to generate ANSI join sytax ("INNER JOIN" clause) for Oracle, as it does when using OUTER JOINs?
    Thank you.

    OBIEE will not generate ANSI syntax for Inner Joins and as you said it only generates for Outer joins. Hope this clears your doubt.

  • Inner join and outer  join in infosets

    hi everyone,
    i have a doubt in infosets...
    when and why we use inner and outer joins(right outer join and left outer join) for infoset
    please give a real time scenario........
    Thanks in advance.
    Bye.

    Hello,
    Inner join:
    For example, the requirement is to show all sales documents where you have delivery exists. In this case, you join both sales ods and delivery ods in a infoset as inner join. This will match the record against the reference documents and pull only matched records.  
    Outer Join:
    Suppose you want to pull all billing/invoice details along with their FI documents related data in a report. Assume that always there might be a situation that invoice exists but not posted to FI, however, you want to have all billing documents details either it has FI document or not. In this case, you link both Billing data and FI document data in a outer join.  This will pull all invoices data either FI document exists or not.   Other words, you want to show one side of data always but adding additional details from differenent source if data exists.
    Hope, it clarifies your doubt. Let me know if any questions.
    Thanks
    Viswa

  • Unable to create a inner join

    Hello Experts!
    I am creating a NW7.1 Laptop application ,I am creating the queries using the query editor in NW DS, I have a scenario where in I need to display data from 2 Data objects using a join condition. In the query editor I am able to see the button Add join conditions for relations in it, but when I click on it I am not able to set the join condition. Please suggest the right way of creating the join.
    I also have one more doubt in this, for displaying data using inner joins between 2 data objects Do i need to create association between the data objects in DOE?
    Thanks
    Regards
    Sagar
    Edited by: sagark on Jun 8, 2010 2:45 PM

    please check the documentation link:
    http://help.sap.com/saphelp_nwmobile71/helpdata/en/8F/0B674240449C60E10000000A1550B0/frameset.htm
    Regards,
    Nipun

  • Problem in Accession inner join with [Microsoft][SQLServer 2000 Driver

    Hi
    Can you tell me what can be cause my sql statement is correct gives result but
    if i used below statement in my JSP ,cause error
    1)
    ps1=connection.prepareStatement("select RQM_IN_RQSTN_ID_PK,RQD_IN_ITM_ID_FKPK,RQD_VC_ITM_DSCRPTN,RQD_IN_STTS_ID_FK,C.SMT_VC_STTS_NM,a.RQM_DT_PRPSD_DLVRY_DT"+
    "from PAS_RQM_RQSTN_MSTR a "+
    "inner join PAS_RQD_RQSTN_DTLS b on a.RQM_IN_RQSTN_ID_PK = b.RQD_IN_RQSTN_ID_FKPK and RQD_IN_STTS_ID_FK = 4"+
    "INNER JOIN PAS_SMT_STTS_MSTR C ON C.SMT_IN_STTS_ID_PK=B.RQD_IN_STTS_ID_FK" +
    "where a.RQM_VC_DTRTMNT_INVLV='Technology' ");
    2) Error Generate
    java.sql.SQLException
    [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 1: Incorrect syntax near 'a'.
    What can be the cause
    Thanks

    ps1=connection.prepareStatement("select
    RQM_IN_RQSTN_ID_PK,RQD_IN_ITM_ID_FKPK,RQD_VC_ITM_DSCRP
    TN,RQD_IN_STTS_ID_FK,C.SMT_VC_STTS_NM,a.RQM_DT_PRPSD_D
    LVRY_DT"+
    "from PAS_RQM_RQSTN_MSTR a "+
    "inner join PAS_RQD_RQSTN_DTLS b on
    a.RQM_IN_RQSTN_ID_PK = b.RQD_IN_RQSTN_ID_FKPK and
    RQD_IN_STTS_ID_FK = 4"+
    "INNER JOIN PAS_SMT_STTS_MSTR C ON
    C.SMT_IN_STTS_ID_PK=B.RQD_IN_STTS_ID_FK" +
    "where a.RQM_VC_DTRTMNT_INVLV='Technology' ");This is a problem due to not providing spaces where they are needed. See the places where I have highlighted.
    A better way is to generate the String first [use StringBuffer as a good practice for appending instead of String "+"] and print it out to check if it is correct.
    ***Annie***

  • 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.

  • Link for BUT000 table and ADRC in CRM and inner join is not working in PCUI

    Hi Gurus,
       Please tell me the link btween BUT000 and ADRC table. and i wrote one inner join between BUT000 and BUT0id table but it not working. I m in CRM 4.0 version working with PCUI.
    select but000partner but000name_org1 but000name_org2 but000bus_sort1 but0id~parnter1
          but0ididnumber from but000 inner join but0id on but0idpartner = but000~parnter
    into corresponding fields of table it_result where partner in s_partner.
    It is giving error as partner unknown from but000 table. I delcared everything and tried with alias names also.
    please clarify me.
    regards,
    Ramakrishna.

    Hi Frederic,
       thanks a lot. But is inner join between BUT000 and BUT0ID will work. for me it is not working. plesae see this code.
    tables : but000,
             but0id,
             crmm_but_custno,
             adrc.
    types : begin of typ_but000,
            partner type bu_partner,
            name_org1 type BU_NAMEOR1,
            name_org2 type BU_NAMEOR2,
            bu_sort1  type BU_SORT1,
            idnumber type BU_ID_NUMBER,
            partner1 type bu_partner,
            end of typ_but000.
    data: lt_but000 type table of typ_but000,
          ls_but000 like line of lt_but000.
    *select-options : s_partnr for but000-partner.
    start-of-selection.
          select but000partner but000name_org1 but000name_org2 but000bu_sort1 but0id~parnter1
                    but0id~idnumber into corresponding fields of table lt_but000 from  but000
                    inner join but0id on but0idpartner = but000parnter. " where partner in s_partner.
    it is giving error as but000-partner is not know or but0id-partner not known.
    So, i think if it not works then i should write two select stmts.
    please clarify me.
    i gave u rating.
    thanks
    ramakrishna.

  • Relationship between tables while using inner joins.

    Hi,
    I had a few clarifications on "inner joins", and as i was going through the forum, i came across two points,
    1. In one of the threads it said " inner joins is applicable for tables that have a parent child relationship.
    2. In another thread it said " inner join is established from master table (the table on the left) to the transcation table (the table on the right)".
    I have two clarifications based on the above points.
    1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
    2.  Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
    Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>.
    Edited by: Narayananchandran on Dec 27, 2010 12:31 PM

    have two clarifications based on the above points.
    1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
    2. Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
    Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>
    1) NO
                      2) NO

  • 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

  • Help needed in rewriting the code using inner joins

    Hi all,
    I need help in rewriting this code
    DATA :  FLD LIKE ZTABLE-ZFLD,
            FLD1 LIKE ZTABLE2-ZFLD2.
    select single ZFLD from zTABLE1 into FLD
                            where MATNR  = '123' and
                                  werks = 'ABC'.
    select single ZFLD1 from zTABLE2 into FLD1
                            where  zFLD = FLD.    
    iS there way that we can write this with inner joins
    Thanks

    Hi,
    help me out
    TABLE 1 HAS
    MATNR , WERKS , FLD1.
    TABLE 2 HAS
    FLD1, FLD2.
    I KNOW MATNR AND WERKS BASED ON THAT I HAVE TO GET FLD2
    I WANT IT BE WRITTEN WITH INNEWR JOINS
    WITH FOLLOWING COD E I GET AN ERROR MESSAGE SAYING
    comma without preccing colon (after select?)
    data : FLD1 like zTABLE1-ZFLD1.
    data : FLD2 like ZTABLE2-ZFLD2.
    SELECT FZFLD1 BZFLD2
        INTO ( FLD1, FLD2)
        FROM ZTABLE1 AS F INNER JOIN ZTABLE2 AS B
               ON FZFLD1 = BFLD2
        WHERE F~MATNR = '123'
          AND F~WERKS   = 'ABC' .
    Thanks

  • How to use Inner join of table as Source in Merge statement in SQL

    Hi All,
        I am trying to make source as multiple tables output using Join while coding there is no any syntax error but when i am executing this statement is giving following error
    Following is the query 
    Merge Into EmpDept Target
    Using (select E.Address,e.Design,e.EmailId,e.EmpId,e.Ename,e.ManagerId, e.Salary,D.DeptId,D.DeptName,D.Location from Employee E Inner join Dept D on E.DeptId=D.DeptId )As Source (Address,Design,EmailId,EmpId,EName,ManagerId,Salary,DeptId,DeptName,Location)
    On Source.EmpId=Target.EmpId
    when not matched then
    Insert (Target.Address,Target.Design,Target.EmailId,Target.EmpId,Target.Ename,Target.ManagerId, Target.Salary,Target.DeptId,Target.DeptName,Target.Location)
    values
    (Address,Design,EmailId,EmpId,EName,ManagerId, Salary,DeptId,DeptName,Location)
    When matched then 
    Update set Target.Address = Source.Address ,Target.Design = Source.Design,Target.EmailId      = Source.EmailId     ,Target.Ename       = Source.Ename      ,Target.ManagerId = Source.ManagerId , Target.Salary        = Source.Salary       ,Target.DeptId      = Source.DeptId      ,Target.DeptName = Source.DeptName ,Target.Location    = Source.Location;
    This is error while executing the above merge statement 
    The insert column list used in the MERGE statement cannot contain multi-part identifiers. Use single part identifiers instead.
    Please suggest me where i am wrong.. 
    Niraj Sevalkar

    MERGE INTO EmpDept Target
    Using (SELECT E.Address,
    e.Design,
    e.EmailId,
    e.EmpId,
    e.Ename,
    e.ManagerId,
    e.Salary,
    D.DeptId,
    D.DeptName,
    D.Location
    FROM Employee E
    INNER JOIN Dept D
    ON E.DeptId = D.DeptId) AS Source (Address, Design, EmailId, EmpId, EName, ManagerId, Salary, DeptId, DeptName, Location)
    ON Source.EmpId = Target.EmpId
    WHEN NOT matched THEN
    INSERT (Address,
    Design,
    EmailId,
    EmpId,
    Ename,
    ManagerId,
    Salary,
    DeptId,
    DeptName,
    Location)
    VALUES (Address,
    Design,
    EmailId,
    EmpId,
    EName,
    ManagerId,
    Salary,
    DeptId,
    DeptName,
    Location)
    WHEN matched THEN
    UPDATE SET Address = Source.Address,
    Design = Source.Design,
    EmailId = Source.EmailId,
    Ename = Source.Ename,
    ManagerId = Source.ManagerId,
    Salary = Source.Salary,
    DeptId = Source.DeptId,
    DeptName = Source.DeptName,
    Location = Source.Location;

Maybe you are looking for