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: 

Help in the ABAP query

Former Member
0 Kudos

hi folks,

Need help in this query.

I am working on this query..

select knumv kschl kbetr kwert kinak

from konv

into table cdata for all entries in bodyitab1

where konv~knumv = bodyitab1-knumv

and ( konvkbetr > 0 or konvkwert > 0 )

The query works fine and I fetch only the records where I have 'KBETR' AND 'KWERT' have values greater than 0.

But I have a condition type 'ZBET' and for one of the records the net balance is zero i.e

kbetr and kwert both have value 0. so it does not pick that record.

But I have to pick it up .

So how can I modify this query so that this condition is not applicable for the condition type 'Zbet'

Thanks in advance.

Santhosh

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos


select knumv kschl kbetr kwert kinak
       from konv
        into table cdata for all entries in bodyitab1
               where konv~knumv = bodyitab1-knumv
                and (  kschl = 'ZBET' )
                 or ( konv~kbetr > 0 or konv~kwert > 0 )

Regards,

Rich Heilman

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos


select knumv kschl kbetr kwert kinak
       from konv
        into table cdata for all entries in bodyitab1
               where konv~knumv = bodyitab1-knumv
                and (  kschl = 'ZBET' )
                 or ( konv~kbetr > 0 or konv~kwert > 0 )

Regards,

Rich Heilman

0 Kudos

Rich,

I hope you did not get me. Let me explain in the query I will be pulling the data for every condition type based on the condition record and satisfying the WHERE CONDITION , it has so happened that for one record in the 'ZBET' condition type the value of 'kbetr' and 'kwert' is zero it is not pulling the data.

In the above case here .. if I include ( kschl = 'ZBET' )

it pulls records only for 'ZBET' but I need to pull the records for all condition types satisfying the where condition and only for 'ZBET' that condition should bypass.

i.e even if 'kbetr' and 'kwert' is 0 it should pull the value only for 'zbet'.

I hope this gives a better picture.

Thanks in advance and CONGRAGULATIONS FOR YOUR ACHIEVEMENT

santhosh

0 Kudos

Sorry...... parenthesis!!!!!




 where konv~knumv = bodyitab1-knumv
     and ( (  kschl = 'ZBET' )
      or ( konv~kbetr > 0 or konv~kwert > 0 ) ).




Regards,

Rich Heilman

0 Kudos

Rich,

I am getting only the records of 'ZBET' condition type. and not all the records from this query. But I want the records for all condition types including 'ZBET' but the

condition '( konvkbetr > 0 or konvkwert > 0 )' should bypass for 'ZBET'.

Thanks

Santhosh

0 Kudos

I was thinking about the OUTER JOIN option but it's impossible with cluster tables.

I don't think you can do what you want with a select.

You need to do it in 2 steps (select then Loop).

0 Kudos


 where konv~knumv = bodyitab1-knumv
      and ( ( konv~kbetr > 0 or konv~kwert > 0 )
         or ( konv~kschl = 'ZBET' ) ).

I'm not sure what's going on here. Am I missing something. Anyone see what we are doing wrong here.

Regards,

Rich Heilman

0 Kudos

Thanks Rich,

NOW IT IS WORKING.full points to you.

SANTHOSH

Former Member
0 Kudos

Hi,

You need to use sub-queries "EXISTS". but it'not working on cluster table and pool table...and KONV in a cluster table.