‎2007 May 30 10:12 PM
Select * from bsik into table it_bsik
WHERE LIFNR in p_client and
bukrs eq so_cia and
budat LE so_fec and
AUGDT LE so_fec and
* blart <> 'KZ'.
( BSCHL <> 50 or
BSCHL <> 11 or
BSCHL <> 01 or
BSCHL <> 25 ) and
umskz NE 'T' and
umskz NE 'F' and
umskz NE 'R' and
umskz NE 'P' and
umskz NE 'J' and
umskz NE 'L'.is this Select Right ? , it get me the right info but i feel that is not right
because the and and and part , i want get all Open Item from bsik except the Special GL , so i am looking for the umskz field , so i feel that the multiple and things dont check all situation but i have a doc with value F in umskz so look like the select is doing it right can somebody show me and guide me i have only few months trying learning myself abap.
Thanks
pd: i dont know much sql either.
‎2007 May 30 11:12 PM
‎2007 May 30 10:27 PM
Query looks alright to me.
You can use this as well:
Select * from bsik into table it_bsik
WHERE LIFNR in p_client and
bukrs eq so_cia and
budat LE so_fec and
AUGDT LE so_fec and
blart <> 'KZ'.
( BSCHL <> 50 or
BSCHL <> 11 or
BSCHL <> 01 or
BSCHL <> 25 ) and
umskz not in ('T' , 'F' , 'R' , 'P' , 'J' , 'L' ).
‎2007 May 30 11:12 PM
‎2007 May 31 12:27 AM
Hi Edgar
Firstly i would like to tell you few things and also my understanding of what you want to achieve:
1.Its always better to mention the exact fields you want to get in your select
query rather than giving ' * '.By mentioning the exact fields , you improve the
performance of your SQL.
2. From your query below i am assuming that p_client is a select option and
so_cia is a parameter. In actual practice , we always use so_ for a select
option and p_ for a parameter. I am not sure if you have your reasons to name it
that way but i will be going as per the standards . So i will rename p_client to
so_lifnr , so_cia to p_werks , so_fec to p_date.
3. You want to fetch all the records where document type (BLART) is not equal
to 'KZ'.
4. You want to fetch all the records for which the posting key(BSCHL) is not equal
to 50 or 11 or 01 or 25.I am not sure if this is what you want or do you want all of them not to appear in the result table. If that is the case you will have to use 'AND' to connect all.
5. You want to fetch all the records for which Special G/L Indicator(UMSKZ) is not
equal to T , F , R , P , J , L. ( please note that I could not find the value 'L' for
the domain UMSKZ )
So based on the above understanding your SQL would be:
CLEAR :it_bsik[].
Select * FROM BSIK INTO TABLE it_bsik
WHERE lifnr in so_lifnr
AND bukrs = p_bukrs
AND budat LE p_date
AND augdt LE p_date
AND ( bschl <> 50
OR bschl <> 11
OR bschl <> 01
OR bschl <> 25 )
AND umskz NE 'T'
AND umskz NE 'F'
AND umskz NE 'R'
AND umskz NE 'P'
AND umskz NE 'J'
AND umskz NE 'L'.
IF sy-subrc EQ 0.
*Check for sy-subrc
ENDIF.
Note: Always check for sy-subrc after a select. I have changed p_client to so_lifnr , so_cia to p_bukrs and so_fec to p_date above. Correct me if my understanding is wrong.
Hope this would be of some help to you.
Cheers
shivika
Message was edited by:
Shivika Bhorchi
‎2007 May 31 12:50 AM
I think it should be like this, you must be careful with your OR and AND as well as the ( )
Select * from bsik into table it_bsik
WHERE LIFNR in p_client and
bukrs eq so_cia and
budat LE so_fec and
AUGDT LE so_fec and
* blart <> 'KZ'.
( BSCHL <> 50 and
BSCHL <> 11 and
BSCHL <> 01 and
BSCHL <> 25 ) and
( umskz NE 'T' and
umskz NE 'F' and
umskz NE 'R' and
umskz NE 'P' and
umskz NE 'J' and
umskz NE 'L' ).Regards,
RIch Heilman
‎2007 May 31 12:33 PM
thx all
i will check,test and look all your suggestions
pd: Shivika Bhorchi you was right that is was i am looking for , btw blart was comment, i don't want it in the query.
‎2007 May 31 11:49 PM