Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Field Selection in Query

former_member211526
Participant
0 Kudos

Hi Experts,

I created a query with a join on 2 tables( Table A and B). B may not have records all the time so I joined them with left outer join. Now I get all records from A based on selection criteria showing blank in fields from B if no entries are found in B.

Now I have entires from B that repeat in output. I want to stop multiple entries from B (Eg: value field). I have 2 entries in table B, with value 0 and value $$. <b>I want all entries from A with entries from B ( but only those entries from B that have value $$) AND blank entries but NOT entries with value=0.</b> I cannot select value field in <i>selection</i> and do an exclusion as this will exclude my blank entries from table B.

Is there a way to select entries from 1 table based on a field entry eg: Select only those fields with value $$ but NOT Value 00, while joining tables in Query.

Thanks

ABAP, Query, Joins, Field selection, Exclusion

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

May be like this

select * from B into table itabB where <<condition>>

loop at itabB

<<<< filter records according your condition

endloop

select * from a into table itabA for all entries in itabB where <<condition if any>>

aRs

4 REPLIES 4

former_member187255
Active Contributor
0 Kudos

you can do a where condition as below example..

SELECT
    SALESREP.EMPID,
    ORDERNO,
    CUSTID,
    ORDDATE,
    BILLED,
    PAID
FROM
    SJD.SALESREP SALESREP
    LEFT OUTER JOIN SJD.SALESORD SALESORD
    ON
    SALESREP.EMPID = SALESORD.EMPID
WHERE
    SALESORD.PAID NE 00.

former_member211526
Participant
0 Kudos

Will this get me the entries 1, 2 , 4, 5 & 6 ( See Below)

<b>A______B__________B <--Tables

X _______Y _______Z <--Fields

1_______ - -_________ --

2_______ - -_________ --

<b>3______ 30_________00</b>

4_______30_________100$

5_______50_________200$

6_______60_________300$

former_member194669
Active Contributor
0 Kudos

if the VALUE field is numc then in where condition, here SPACE considered as 00


WHERE
    SALESORD.PAID NE 00.    " << here 00 also considered as space


aRs

former_member194669
Active Contributor
0 Kudos

May be like this

select * from B into table itabB where <<condition>>

loop at itabB

<<<< filter records according your condition

endloop

select * from a into table itabA for all entries in itabB where <<condition if any>>

aRs