Application Development and Automation 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: 
Read only

Select Query

rahul2000
Contributor
0 Likes
1,320

Dear All,

I have fired a select query as follows

SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT

TXGRP HWBAS HWSTE KTOSL KBETR

FROM BSET

INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG

WHERE BELNR = IT_BSEG-BELNR

AND KTOSL IN ('JP4','JP5') .

In the same query i also want documents with MWSKZ EQ 00. it is not necessary that JP4 and JP5 will have MWSKZ eq 00. So how is the query to be fired?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,293

This will select documents with KTOSL JP4 or JP5 and among those with MWSKZ '00'


SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT 
TXGRP HWBAS HWSTE KTOSL KBETR 
FROM BSET
INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG
WHERE BELNR = IT_BSEG-BELNR
AND KTOSL IN ('JP4','JP5') 
and mwskz = '00'.

If you want to select documents with KTOSL 'JP4' or 'JP5' and or mwskz 00. Do this :


SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT 
TXGRP HWBAS HWSTE KTOSL KBETR 
FROM BSET
INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG
WHERE BELNR = IT_BSEG-BELNR
AND ( KTOSL IN ('JP4','JP5')  OR mwskz = '00' ).

regards,

Advait

11 REPLIES 11
Read only

Former Member
0 Likes
1,293

Hi,

if u have the MWSKZ field in the IT_BSEG

table then you can add the condition in this where only.

Read only

0 Likes
1,293

HI CHANDRIKA..

apart from the existing documents i want 00 documents as well..

Read only

Former Member
0 Likes
1,293
SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT 
TXGRP HWBAS HWSTE KTOSL KBETR 
FROM BSET
INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG
WHERE BELNR = IT_BSEG-BELNR
AND KTOSL IN ('JP4','JP5')  and
MWSKZ = '00'.
Read only

0 Likes
1,293

hi amit...and condition cannot be used...as that will mean all 3 will have to be satisfied at a time

Read only

0 Likes
1,293

Rahul,

first select all document as per your select query than delete unwanted by comparing kostl or mwskz .

Amit.

Read only

Former Member
0 Likes
1,293

hi do like this ...

SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT

TXGRP HWBAS HWSTE KTOSL KBETR

FROM BSET

INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG

WHERE BELNR = IT_BSEG-BELNR

AND KTOSL IN ('JP4','JP5') .

AND MWSKZ = '00'.

Read only

Former Member
0 Likes
1,293

SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT

TXGRP HWBAS HWSTE KTOSL KBETR

FROM BSET

INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG

WHERE BELNR = IT_BSEG-BELNR AND

KTOSL IN ('JP4','JP5') .

Delete it_bset where KTOSL NE 00.

Regards

rajesh

Read only

Former Member
0 Likes
1,294

This will select documents with KTOSL JP4 or JP5 and among those with MWSKZ '00'


SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT 
TXGRP HWBAS HWSTE KTOSL KBETR 
FROM BSET
INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG
WHERE BELNR = IT_BSEG-BELNR
AND KTOSL IN ('JP4','JP5') 
and mwskz = '00'.

If you want to select documents with KTOSL 'JP4' or 'JP5' and or mwskz 00. Do this :


SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT 
TXGRP HWBAS HWSTE KTOSL KBETR 
FROM BSET
INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG
WHERE BELNR = IT_BSEG-BELNR
AND ( KTOSL IN ('JP4','JP5')  OR mwskz = '00' ).

regards,

Advait

Read only

Former Member
0 Likes
1,293

Put an OR condition .. If U want both conditions to be satisfied..

SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT

TXGRP HWBAS HWSTE KTOSL KBETR

FROM BSET

INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG

WHERE BELNR = IT_BSEG-BELNR

AND ( KTOSL IN ('JP4','JP5') OR

MWSKZ EQ 00 ) .

Read only

former_member787646
Contributor
0 Likes
1,293

Hi

Try the following SQL..

SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT TXGRP HWBAS HWSTE KTOSL KBETR FROM BSET

INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG

WHERE BELNR = IT_BSEG-BELNR AND ( KTOSL IN ('JP4','JP5') OR MWSKZ EQ 00 ) .

Hope it helps.

Murthy

Read only

Former Member
0 Likes
1,293

hiii

first right a query like

SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT

TXGRP HWBAS HWSTE KTOSL KBETR

FROM BSET

INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG

WHERE BELNR = IT_BSEG-BELNR

AND KTOSL IN ('JP4','JP5') AND

MWSKZ EQ '00'.

here it will fetch data for JP4 and JP5 with MWSKZ field value as 00..

or just fetch data by using

SELECT BUKRS BELNR GJAHR BUZEI MWSKZ HKONT

TXGRP HWBAS HWSTE KTOSL KBETR

FROM BSET

INTO TABLE IT_BSET FOR ALL ENTRIES IN IT_BSEG

WHERE BELNR = IT_BSEG-BELNR

AND KTOSL IN ('JP4','JP5').

then by using LOOP with where condition for MWSKZ EQ '00' you can get that record for JP4 or JP5.

regards

twinkal