Self join using ABAP Query

Hello all,
How to create a self join using ABAP Query?
Say, I have this table EKBE with belnr (materials doc num) and lfbnr (reference material doc num). I have to pick the PO's from EKBE whose belnr doesnt have any lfbnr.
Regards
Madhumathi A

hi madhu,
tables : ekbe.
data itab like standard table of ekbe with header line.
select * from ekbe into table itab where belnr >< 0 and lfbnr = ' '.
loop at itab.
write :/ itab-belnr,itab-lfbnr.
endloop.
check this code this works to select the orders whose belnr doesnt have any lfbnr
reward points if useful.

Similar Messages

  • How to add the fields to the transaction 'Z10SD25' using ABAP Query

    Hello,
    I want to add the new fields like 'From' and 'To' depending on some conditiions. But i have to do this using ABAP Query.
    Can any one help me with this as I am not much aware of ABAP Query .
    Regards,
    Darshana

    Hi,
    ABAP/4 query can be designed in four steps
    1.     Creation of a user group
    2.     Creation of Infoset
    3.     Assignment of user group to Infoset
    4.     Creation of the query based on Infoset
    By executing the transaction codes mentioned below
    u2022     SQ01   ABAP/4 Query
    u2022     SQ02   Infosets
    u2022     SQ03   User group
    Step 1: To create an Infoset without a logical database
    One of the following can be selected
    u2022     Based on a single table
    u2022     Using an ABAP/4 program
    u2022     Using Table Joins
    u2022     Using Sequential Dataset
    NOTE: The tables to be used in the join should have at least one field in common i.e. it should have the same name, domain or data element.
    Step 2: Here you specify the users who should be authorized to run the query. A user group is always associated with a Infoset.
    Step 3: In Query Definition you can define the Selections Screen. Here you can check against the fields(fields from the tables specified in the infoset above) that you require to be shown on the selection screen.
    Now we Finally need to specify the output type for the query as Basic List, Statistics or Ranked List. Choose the option Basic List and also select the fields to be displayed in the output list(in your case from and to fields...)
    After providing all the above options you can save the query and execute it by clicking the Execute button twice.
    Hope this helps
    Regards
    Shiva
    Edited by: Shiva Kumar Tirumalasetty on Sep 15, 2009 12:44 PM

  • Generating a report using ABAP query

    Hi All,
    I want to generate a anlytical report using ABAP query, There are 3 different transactions/steps have to be executed to get this data in an actionable form.
    1. MB52 - Unrestricted Stock
    2. ZCustomquery - Custom query in SAP R3
    3. Combine above two in a single report.
    Please suggest me how can i proceed,
    1. Example i have created query name called Finalrepot
    2. How can i call above zcustomquery and Transaction (MB52) in the Query.
    Thanks for your help
    Pradeep

    Hi,
    Check below link to create ABAP query (SAP Query)
    http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Create_The_Query.asp
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVQUE/BCSRVQUE.pdf
    Best regards,
    Brijesh

  • Programs generated using ABAP query vanishes after upgrade

    Hi all,
    The programs generated using abap query in sq01 vanishes after upgrading from 4.6C to ECC 6.0 system.
    Is this a know issue, do we have a solution for this?
    Can anyone help
    Thanks
    Senthil

    Hi,
    Try to generate the Queries again in the new system...using the FM : RSAQ_GENERATE_PROGRAM
    The input needed is the Query name and the usergroup...The details can be obtained from the table AQLQCAT(local queries areas) and AQGQCAT(global areas queries).
    Once you generate the query , a program gets created...
    if you have lots of queries to be genretated, write a custom report by fetching the data from the above tables and use the FM to generate the same...
    Hope this helps you..
    Reward if useful
    Regards
    Shiva

  • Extraction using ABAP Query

    Hi Experts,
    I have a data source in which the extraction is using ABAP Query. From RSA2 I got the infoset name. I would like to know if the extraction logic is put inside this infoset. If so how to see the extractor ouput in R/3 and how to debugg the infoset. I can't put break point in infoset. I tried to debugg the extractor through rsa3 and it is not going to the infoset also.
    Please help me as I don't have any experience in BI.
    Thanks,
    Soumya.

    Hi Soumya,
    Infosets are similar to views created on different tables by linking them with one another. So instead of debugging one should look for how this tables have been linked in tcode SQ01.
    Hope that helps.
    Regards
    Mr Kapadia

  • Development of Reports using ABAP Query

    Hi
    can anyone please tell me about 'Development of Reports using ABAP Query' and how to use it in real time
    Thanks
    jay

    look here:
    http://help.sap.com/saphelp_47x200/helpdata/en/b7/26ddebb1f311d295f40000e82de14a/frameset.htm
    A.

  • Need to delete a table join in ABAP query

    Hi
      I have created an ABAP query with a join over AUFK, AFIH, AFKO, AFVV, AFVC and AFRU.
      I need to delete the table AFRU from the join. I tried to delete the table in the edit option in the Join table option. I deleted the links between the table AFVC and AFRU and clicked on delete table option. I get the message Table AFRU not used. Please let me know if there is any method to delete the table.
    Thanks and Regards,
    Ajith

    u have to break the link between this table and other tables...U need to delete where conditions and then delete the join...

  • Interactive reports using ABAP query

    I have developed an ABAP query which prints the sales documents in ALV list display.
    In that  list display I would do develop a functionality is , when ever i double click on the sales doc number it will directly go to the VA03 transaction for the corresponding VBELN.
    Can anybody explain how to do this?

    Hi,
    When you double-click on any cell of alv, use this code to fetch the data of the line that you currently clicked, its working:-
    When you double click on the ALV line, you will have sy-ucomm = '&IC1'.
    So when you define a i_callback_user_command for the FM reuse_alv_list_display,
         i_callback_user_command           = 'COMMAND' " for User-Command
    and create it as:-
    FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA : ok_code TYPE sy-ucomm.
      ok_code = ucomm.
      CASE ok_code.
        WHEN '&IC1'. "for double click on alv line
          " your code
      ENDCASE.
    ENDFORM.
    As you have used selfield TYPE slis_selfield, the field selfield will hold all the values.
    To know on which row you have clicked and to retain that line, use code:-
    Suppose you are currently displaying data from internal table itab and corresponding to it you have work area wa.
    read table itab into wa index selfield-tabindex. "index value of line you clicked
    " now you have the contents of line that you double clicked currently
    Now to know the field name that you clicked, use:-
    selfield-fieldname " will fetch you the name of field that you clicked
    Now using the work-area and the name of field that you clicked, you can easily make out the details of the field i.e., field name and field value and you can code as per your requirement.
    Refer:-
    CASE selfield-fieldname.
      WHEN 'VBELN'.
        SET PARAMETER ID 'AUN' FIELD <wa-vbeln>. "value for work area for vbeln
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    ENDCASE.
    Hope this helps you.
    Regards,
    Tarun

  • Hoe top create summary and detail report using ABAP QUERY

    Hi ,
    Can any one suggest me how to create summary and detailed report using ABAP Quey.
    Regards,
    Raghu.

    Hi,
    Table Declaration
    tables:mara,mast.
    *Declaring the internal table
    data: begin of itab_new occurs 0,
          matnr like mara-matnr,     "Material No
          ernam like mara-ernam,     "Material Created by
          mtart like mara-mtart,     "Material Type
          matkl like mara-matkl,     "Material Desc
          werks like mast-werks,     "Plant
          aenam like mast-aenam,     "BOM created
          stlal like mast-stlal,     "Alternative BOM
          end of itab_new.
    select-options: p_matnr for mara-matnr.
    CODE A : Retrieving the data from the database
         select  f~matnr f~ernam f~mtart f~matkl m~werks m~aenam m~stlal
         into table itab_new
         from mara as f inner join mast as m
         on f~matnr = m~matnr
         where f~matnr in p_matnr.
    CODE B : Retrieving the data from the database.
        SELECT FMATNR FERNAM FMTART FMATKL MWERKS MAENAM M~STLAL
        INTO TABLE ITAB_NEW
        FROM MARA AS F INNER JOIN MAST AS M
        ON FMATNR = MMATNR
        WHERE F~MATNR = P_MATNR.
        SORT ITAB_NEW BY ERNAM.
    loop at itab_new.
    write:/5  itab_new-matnr,itab_new-ernam,itab_new-mtart,itab_new-matkl,itab_new-werks,itab_new-aenam,itab_new-stlal.
    endloop.
    *TABLES: MARA , MAST.
    *DATA:BEGIN OF ITAB_NEW OCCURS 0,
                 MATNR LIKE MARA-MATNR,
                 ERNAM LIKE MARA-ERNAM,
                 MTART LIKE MARA-MTART,
                 MATKL LIKE MARA-MATKL,
                 END OF ITAB_NEW.
       SELECT MATNR ERNAM MTART MATKL
       INTO TABLE ITAB_NEW
       FROM MARA
       WHERE MTART = 'T'
       ORDER BY MATNR ERNAM MTART MATKL.
    *DATA: BEGIN OF ITAB OCCURS 0,
         MATNR LIKE MARA-MATNR,
         END OF ITAB.
    Thank U,
    Jay....

  • Excess Inventory/Scheduled Receipts Report using ABAP Query.

    Hi All,
    I want to create a ABAP query for Excess inventory & Scheduled receipts in a single report. I have identified tables, fields and some extra calculated fields in the report. Here are the following tables and fields.
    EKPO-MATNR      ( Material number)
    EKPO-WERKS     ( Plant)
    MAKT-MAKTX       (Material Discription)
    MARC-MAABC      ( ABC indicator)
    LFA1-NAME1        ( Supplier name)
    MBEW-STPRS      (Total value)
    EKET-EINDT         ( Item delivery date)
    RIBOF-AMOUNT
    S939-SPWOC or S032-SPWOC
    Calculation fields : Value execess this week.extend value, over or under this week, onhand inventory for last week and this week.
    Here my question is, when i was creating a infoset, how do i maintain relationship or joins from one table to another table...Is there any sequence for the above tables? Pl suggest. When i was adding all the tables in a infoset and try join the tables...it says illegal join...
    Pl suggest me.
    Thanks for your help
    PRadeep
    Edited by: Venkata Pr Papulugari on Jul 18, 2008 1:37 AM

    Hi Gordon,
    What i need to display is the remainder of the transaction that was received... if it is zero (0), i don't want to display it.
    i.e.
    transact # 100 inqty = 5
    transact # 200 outqty =1
    I'd like to display
    transact # 100     qty on hand = 4
    right know the transaction # that i am displaying is transact # 200.
    And also, it needs to be warehouse oriented. because i can have multiple warehose transactions.... and i am getting that wrong too.
    Regards,
    Manuel Roman

  • Table Join in ABAP Query

    Hi,
    I'm new to ABAP Query. I want to include a table and join with an existing table in abap query. how to do this?

    Hi
    select lipsvbeln lipslfimg likp~wadat
            into corresponding fields of table ltab_orders
            from lips join likp on ( lipsvbeln = likpvbeln )
            join vbfa on ( lipsvbeln = vbfavbelv )       
            where lips~matnr = matnr
            and   lips~vbeln in vbeln
            and   likp~vbeln in vbeln         
            and   vbfa~vbelv in vbeln
            and   lips~werks in werks
            and   likp~wadat in datum
            and   vbfa~vbtyp_n = 'Q'            
            and   vbfa~vbtyp_v = 'J'. 
    Thanks,
    Neelima.

  • Self Joining and Inline Query. A tricky report.

    I am stuck with a very tricky situation.Please help.This is PROD issue.
    I have written a SQL code which has 1 inline queries,and displays the right results
    with the right report output
    Dont get confused.Just go thru this.
    select   pie.id_inst_code,
             ISNULL(PN.Active, 0)                 'Active',
    from position_master_input_event pie,
    (select  insx.id_inst_xref_type,insx.id_inst_xref,count(*) 'PrimaryListing'
    from instrument ins, instrument_xref insx
    where ins.id_inst = insx.id_inst
    and   insx.flg_active = 'Y'
    and   ins.flg_active  = 'Y'
    group by insx.id_inst_xref_type,insx.id_inst_xref
    )PN
    where     id_entity = 'AGL'
    and       pie.id_inst_code *= PN.id_inst_xref
    and       pie.id_src_inst_code_type*= PN.id_inst_xref_type
    group by  pie.id_inst_code,PN.Active,
    Table :Instrument_xref
    id_inst      id_inst_xref_type    id_inst_xref  flg_active
    0372285      SE                   B0DV8Y9       Y
    0372285      IS                   GB00B03MLX29  Y
    Table :Instrument
    id_inst      id_inst_xref_type    id_inst_xref  flg_active  flg_primary_listing
    0372285      SE                   B0DV8Y9       Y           N 
    OUTPUT:
    id_inst_xref                      Active
    B0DV8Y9                           1
    PERFECT.Works fine
    2) Now comes the tricky part.:
        0372285 also has GB00B03MLX29 which has flg_active to Y and which also maps to 0372285.
        Am I right?
        New reportOutput
        id_inst_xref                      Active   PRIMARY ISIN
        B0DV8Y9                           1        1
        So,now I want a SELF JOIN this way built into the code:
        (hardcoded values work)
        (i)
        select  a.id_inst_xref
        from instrument_xref a,
             instrument_xref b
        where b.id_inst_xref ='B0DV8Y9'
        and   b.id_inst = a.id_inst
        and   b.id_inst_xref_type in ('SE','IS')
        and   a.id_inst_xref =  'GB00B03MLX29'
        (ii)
         select count(*) 'PrimaryISIN'
         from instrument ins,
             instrument_xref insx
         where ins.id_inst = insx.id_inst
         and   insx.flg_active = 'Y'
         and   ins.flg_primary_listing = 'Y'
         and   ins.flg_active = 'Y'
         And now LINKING ALL :
        select   pie.id_inst_code,
             ISNULL(PN.Active, 0)                 'Active',
        from position_master_input_event pie,
        (select  insx.id_inst_xref_type,insx.id_inst_xref,count(*) 'PrimaryListing'
         from instrument ins, instrument_xref insx
         where ins.id_inst = insx.id_inst
         and   insx.flg_active = 'Y'
         and   ins.flg_active  = 'Y'
         group by insx.id_inst_xref_type,insx.id_inst_xref
        )PN,
        (select count(*) 'PrimaryISIN'
         from instrument ins,
             instrument_xref insx
         where ins.id_inst = insx.id_inst
         and   insx.flg_active = 'Y'
         and   ins.flg_primary_listing = 'Y'
         and   ins.flg_active = 'Y'
          and     insx.id_inst_xref = ( 
                                           select  DISTINCT  a.id_inst_xref
                                            from    instrument_xref a,
                                            instrument_xref  b
                                      where b.id_inst_xref = 'B0DV8Y9'
                                          and     b.id_inst = a.id_inst
                                          and     b.id_inst_xref_type in ('SE','IS')
                                       and    a.id_inst_xref =  'GB00B03MLX29'
        where     id_entity = 'AGL'
        and       pie.id_inst_code *= PN.id_inst_xref
        and       pie.id_src_inst_code_type*= PN.id_inst_xref_type
        group by  pie.id_inst_code,PN.Active,
        THE Self join works fine as long as it is hardcoded.
        But assume there can br multiple such situations as the above,and I dont want to
        hardcode the values,how can I build the NEW REPORT by SELF JOINING.
        Please can someome help.This is a tricky one.
        Is there a better way to this

    Isn't this the same question as:
    Passing values dynamically Froman 'INLINE Query' to a 'SUB QUERY'
    and
    Another query regarding Inline Query and Self Join and pass Column Values

  • Customer Notes using abap Query

    HI Experts,
    Can any body suggest me abap query for extracting customer notes?? I have to go thru only this option.
    the text i am supposed to extract is here.......VA42 > goto>header>texts> completion notes ..
    READ_TEXT is not a solution for me...i need only ABAP Query..
    thanks
    sony
    Edited by: sony on Jan 6, 2009 1:32 PM

    hi jay,
    thanks for ur reply..but as mentioned read_text is not a solution..
    thanks
    sony
    Edited by: sony on Jan 6, 2009 1:43 PM

  • Creation of Program using ABAP Query (SQ01)

    Hi All,
    I have a program called "AQL4FI==========INVOICE_CHECK=" in my 4.6 server but a similar program doesnot exist in ECC.
    From the name, it looks like a program created using SQ01.
    Can anyone please help as to how to create the same program in ECC using SQ01 by looking at the program in 4.6?
    Please help.
    Helpful answers will be fully rewarded.
    Thanks a ton.
    Naba

    First thing is this is not the way to convert the SAP Query to Report.
    First check that how many table in your query they have used.To check this if you go in SQ02 press display button left side you can see the tables.To check the fields selecting from tables check in field groups.
    In record processing check are there any conditions are there.
    Now wrire a select statement by joing all tables which you found above and in this select statement extract all fields which you found in field group into one internal table .Here you give the selection screen fields as condition fields in select statement.If you found any conditions in record processing event ,Loop that internal table and check the conditions or modifications.
    If you need more help let me know.
    Pls. reward points for helpful answers
    Thanks
    Murali Poli

  • Can we join two totals tables in ABAP Query

    Hey Gurus!
    Can we join two totals tables in ABAP query.
    I am tyring to join FAGFLEXT with internal orders totals table.
    Thanks
    S

    Hi,
    Report painter majorily operates around characteristics and key figures.
    ABAP query comes even more handy.  The advantage is -
    1. You can link many tables
    2. Create selection screen as you like to have
    3. User friendly report creation
    4.  Logic can also be coded.
    5. Authorization can be set
    I have written a article in SDN, which gives you an idea as to how to go about using ABAP query.  Have a look on this - [Article - Practical Usage of ABAP Query|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20f6b256-23be-2b10-8b93-cad83a617634]
    Regards,
    Sridevi

Maybe you are looking for

  • How do I add the rotate button to the main toolbar for all users

    How do I add the rotate button to the main toolbar for all users. I have a Windows 2003 Citrix farm with Adobe Reader 8. I can add it user by user but I want to add it to all users at once. All users need this rotate button, Thanks in advance ND

  • Backupping from single-user mode

    I am currently only able to use the single-user mode, and am looking for possibilities to take some backup of certain files before I venture reinstalling or something. Is it possible to write to disk from S-U mode? How? Can I do it in another way, e.

  • ITunes 7.3.1 cannot run as it has detected a problem with your audio..

    Hey I installed iTunes 7.3.1 last night, and when I click to open it, a message comes up saying 'iTunes 7.3.1 cannot run as it has detected a problem with your audio configeration' Please help Thanks

  • /n problem with JEditorPane

    I wonder if anyone can help. I am developing an editor to edit java programs. I have a compile and run button as you would expect. When I compile the program in my editor, if I have an error I wish to highlight the line. I am using the select(int, in

  • Apple prores 422

    Hello, I have a question about importing a movie file. When I import a 5dm2 Movie in Final cut pro X 10.1 and select that I want to encode it to Apple prores 422  or a proxy file it still imports as a original movie Quiktime -H264. I tried all sorts